openal-soft icon indicating copy to clipboard operation
openal-soft copied to clipboard

Sound cuts out when multiple are playing

Open Kai-Indiemade opened this issue 2 years ago • 1 comments

I am playing a sound every 10th of a second(100 milliseconds), and it quickly starts to cut out the more it plays.

Here's a recording of the audio:

https://github.com/kcat/openal-soft/assets/29464461/25ff477e-72a1-40c7-809c-c477bc750344

I am using openal-soft version 1.22.2. (I'm using the vcpkg version, it's slightly out of date)

I use the alplay.c tutorial code for the sound loading, but I made my own "Sound" class(in cpp) so that I can play multiple at once. I am passing in the same buffer to each Sound object, but of course making a new source for each one.

When the sound is finished playing I delete it, which in the destructor also deletes the source (with alDeleteSources(1, &source);)

Here's how I check if it's finished, similar to how it's done in the example.

alGetSourcei(source, AL_SOURCE_STATE, &state);

alGetSourcef(source, AL_SEC_OFFSET, &offset);

if (alGetError() != AL_NO_ERROR || state != AL_PLAYING) {

    finished = true;
}

As discussed elsewhere you'll need to see a trace log to get an idea of what's going on, would that be the debug output?

The only debug output I get in visual studio after I start playing the sound is this: [ALSOFT] (II) Increasing allocated voice properties to 32

Here's the output prior to that, when AL Soft is setting up:

[ALSOFT] (II) Initializing library v1.23.1-unknown UNKNOWN
[ALSOFT] (II) Supported backends: wasapi, dsound, winmm, null, wave
[ALSOFT] (II) Loading config C:\Users\me\AppData\Roaming\alsoft.ini...
[ALSOFT] (II) Got binary: D:\VisualStudioProjects\testproj\out\build\x64-debug, testproj.exe
[ALSOFT] (II) Loading config D:\VisualStudioProjects\testproj\out\build\x64-debug\alsoft.ini...
[ALSOFT] (II) Key disable-cpu-exts not found
[ALSOFT] (II) Vendor ID: ""
[ALSOFT] (II) Name: "Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz"
[ALSOFT] (II) Extensions: +SSE +SSE2 +SSE3 +SSE4.1
[ALSOFT] (II) Key rt-prio not found
[ALSOFT] (II) Key rt-time-limit not found
[ALSOFT] (II) Key game_compat/enable-sub-data-ext not found
[ALSOFT] (II) Key game_compat/reverse-x not found
[ALSOFT] (II) Key game_compat/reverse-y not found
[ALSOFT] (II) Key game_compat/reverse-z not found
[ALSOFT] (II) Key game_compat/nfc-scale not found
[ALSOFT] (II) Key resampler not found
[ALSOFT] (II) Key uhj/decode-filter not found
[ALSOFT] (II) Key uhj/encode-filter not found
[ALSOFT] (II) Key trap-al-error not found
[ALSOFT] (II) Key trap-alc-error not found
[ALSOFT] (II) Key reverb/boost not found
[ALSOFT] (II) Key drivers not found
[ALSOFT] (II) Starting message thread
[ALSOFT] (II) Initialized backend "wasapi"
[ALSOFT] (II) Added "wasapi" for playback
[ALSOFT] (II) Added "wasapi" for capture
[ALSOFT] (II) Key excludefx not found
[ALSOFT] (II) Key default-reverb not found
[ALSOFT] (II) Key eax/enable not found
[ALSOFT] (II) Opening default playback device
[ALSOFT] (II) Got device "Digital Audio (HDMI) (2- High Definition Audio Device)", "{25A967A2-9E3D-442D-B921-4B46EC5926BA}", "{0.0.0.00000000}.{25a967a2-9e3d-442d-b921-4b46ec5926ba}"
[ALSOFT] (II) Got device "Headset Earphone (Razer Kraken 7.1 V2)", "{5274C0C6-3BA0-4988-BDB5-D10BEAA7E846}", "{0.0.0.00000000}.{5274c0c6-3ba0-4988-bdb5-d10beaa7e846}"
[ALSOFT] (II) Got device "Digital Audio (HDMI) (2- High Definition Audio Device) #2", "{69354831-9185-4DF7-A2CB-AB1E0CE4F1CE}", "{0.0.0.00000000}.{69354831-9185-4df7-a2cb-ab1e0ce4f1ce}"
[ALSOFT] (II) Got device "Headset Microphone (Razer Kraken 7.1 V2)", "{593883CB-636E-4AA5-8361-7E4D573604F7}", "{0.0.1.00000000}.{593883cb-636e-4aa5-8361-7e4d573604f7}"
[ALSOFT] (II) Starting message loop
[ALSOFT] (II) Got message "Open Device" (0x0000, this=000001C39F999B90, param=0000000000000000)
[ALSOFT] (II) Created device 000001C394E6EC40, "OpenAL Soft on Headset Earphone (Razer Kraken 7.1 V2)"
[ALSOFT] (II) Key frequency not found
[ALSOFT] (II) Key period_size not found
[ALSOFT] (II) Key periods not found
[ALSOFT] (II) Key sample-type not found
[ALSOFT] (II) Key channels not found
[ALSOFT] (II) Key ambi-format not found
[ALSOFT] (II) Key hrtf not found
[ALSOFT] (II) Key stereo-encoding not found
[ALSOFT] (II) Pre-reset: Stereo, Float32, 48000hz, 960 / 2880 buffer
[ALSOFT] (II) Got message "Reset Device" (0x0001, this=000001C39F999B90, param=0000000000000000)
[ALSOFT] (II) Device mix format:
    FormatTag      = 0xfffe
    Channels       = 2
    SamplesPerSec  = 48000
    AvgBytesPerSec = 384000
    BlockAlign     = 8
    BitsPerSample  = 32
    Size           = 22
    Samples        = 32
    ChannelMask    = 0x3
    SubFormat      = {00000003-0000-0010-8000-00aa00389b71}
[ALSOFT] (II) Requesting playback format:
    FormatTag      = 0xfffe
    Channels       = 2
    SamplesPerSec  = 48000
    AvgBytesPerSec = 384000
    BlockAlign     = 8
    BitsPerSample  = 32
    Size           = 22
    Samples        = 32
    ChannelMask    = 0x3
    SubFormat      = {00000003-0000-0010-8000-00aa00389b71}
[ALSOFT] (II) Post-reset: Stereo, Float32, 48000hz, 960 / 2880 buffer
[ALSOFT] (II) Key stereo-mode not found
[ALSOFT] (II) Key hrtf-paths not found
[ALSOFT] (II) Searching D:\VisualStudioProjects\testproj\out\build\x64-debug\*.mhr
[ALSOFT] (II) Searching C:\Users\me\AppData\Roaming\openal\hrtf\*.mhr
[ALSOFT] (II) Searching C:\ProgramData\openal\hrtf\*.mhr
[ALSOFT] (II) Adding built-in entry "!1_Built-In HRTF"
[ALSOFT] (II) Key default-hrtf not found
[ALSOFT] (II) Loading !1_Built-In HRTF...
[ALSOFT] (II) Detected data set format v3
[ALSOFT] (II) Loaded HRTF Built-In HRTF for sample rate 48000hz, 64-sample filter
[ALSOFT] (II) Key hrtf-size not found
[ALSOFT] (II) Key hrtf-mode not found
[ALSOFT] (II) 1st order + Full HRTF rendering enabled, using "Built-In HRTF"
[ALSOFT] (II) Channel config, Main: 4, Real: 2
[ALSOFT] (II) Allocating 6 channels, 24576 bytes
[ALSOFT] (II) Min delay: 7.75, max delay: 32.50, FIR length: 64
[ALSOFT] (II) New max delay: 24.75, FIR length: 89
[ALSOFT] (II) Key decoder/nfc not found
[ALSOFT] (II) Key sources not found
[ALSOFT] (II) Key sends not found
[ALSOFT] (II) Max sources: 256 (255 + 1), effect slots: 64, sends: 4
[ALSOFT] (II) Key dither not found
[ALSOFT] (II) Key dither-depth not found
[ALSOFT] (II) Dithering disabled
[ALSOFT] (II) Key output-limiter not found
[ALSOFT] (II) Output limiter disabled
[ALSOFT] (II) Fixed device latency: 0ns
[ALSOFT] (II) Got message "Start Device" (0x0002, this=000001C39F999B90, param=0000000000000000)
[ALSOFT] (II) Post-start: Stereo, Float32, 48000hz, 960 / 2880 buffer
[ALSOFT] (II) Increasing allocated voices to 256
[ALSOFT] (II) Key volume-adjust not found
[ALSOFT] (II) Created context 000001C394E6DB50

Kai-Indiemade avatar Jun 22 '23 19:06 Kai-Indiemade

I'm having the exact same issue that. I spent a couple hours to figure out whats wrong but couldnt. I can share the code if needed.

Kitiara avatar Oct 14 '24 12:10 Kitiara