OneLoneCoder / olcPixelGameEngine

The official distribution of olcPixelGameEngine, a tool used in javidx9's YouTube videos and projects
Other
3.84k stars 912 forks source link

Outdated PGEX_Sound in /Videos/ and not working one in /Extensions/ #197

Open hatkidchan opened 3 years ago

hatkidchan commented 3 years ago

So, I've just tried to build Videos/OneLoneCoder_PGE_SoundTest.cpp and it throws this:

In file included from OneLoneCoder_PGE_SoundTest.cpp:58:
olcPGEX_Sound.h: In member function ‘olc::rcode olc::SOUND::AudioSample::LoadFromFile(std::string, olc::ResourcePack*)’:
olcPGEX_Sound.h:297:23: error: ‘sEntry’ is not a member of ‘olc::ResourcePack’
  297 |    olc::ResourcePack::sEntry entry = pack->GetStreamBuffer(sWavFile);
      |                       ^~~~~~
olcPGEX_Sound.h:298:21: error: ‘entry’ was not declared in this scope
  298 |    std::istream is(&entry);
      |                     ^~~~~

Then I've changed olcPGEX_Sound.h to one from Extensions, and then it's compiles successfully, BUT when I ran compiled binary, in pavucontrol volume is over 100%, but nothing is playing. Also waveform is showing normally, but no sound at all, except "clicking sound" on start.

Screenshot of pavucontrol
Screenshot of waveform in application I think waveform is showing normally because it's processed before writing samples chunk into sound sink

Also I've tried to play sound after loading WAV and playing it inside OnUserCreate, and I got "beautiful" glitchy noise.

I'm using this command to compile: g++ -lX11 -lGL -lpthread -lpng -lasound -lstdc++fs -std=c++17 -o OneLoneCoder_PGE_SoundTest OneLoneCoder_PGE_SoundTest.cpp

Some other info (which I hope should help)

pactl info

Server String: /run/user/1000/pulse/native
Library Protocol Version: 34
Server Protocol Version: 34
Is Local: yes
Client Index: 53
Tile Size: 65472
User Name: hkc
Host Name: spaceship01u
Server Name: pulseaudio
Server Version: 14.0
Default Sample Specification: s16le 2ch 44100Hz
Default Channel Map: front-left,front-right
Default Sink: alsa_output.pci-0000_00_1b.0.analog-stereo
Default Source: alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
Cookie: 88c7:fc86

System info

OS: Arch Linux x86_64
Host: HP Mini 110-3500 058D10A000203300000300100
Kernel: 5.9.10-arch1-1
WM: i3
CPU: Intel Atom N455 (2) @ 1.666GHz
GPU: Intel Atom Processor D4xx/D5xx/N4xx/N5xx
hatkidchan commented 3 years ago

Ok, I've found workaround, problems with sound occurring only with alsa backend, with openal everything is fine. I've just added that before including PGEX:

#define USE_ALSA

And, instead of -lasound now I'm using -lopenal. But still, in /Videos/ is used older version of pgex