Open yangfangfang1204 opened 3 years ago
I have no idea how OpenAL Soft would work in a browser. Presumably it's using one of the available backends, so it depends on how that backend is behaving.
Are you sure you're setting a buffer large enough so that the device has room to store all the audio in between calls to alcCaptureSamples? If the capture buffer overruns, you will lose samples and the audio device may have stale samples when recovering (ideally it shouldn't have stale samples, but without knowing the backend being used, I can't tell whether it's a problem with the system API used or something else).
You are probably linking to the openal js implementation in Emscripten and not OpenAL Soft.
OpenAL Soft works in the browser using Qt! I just have set up it like this:
CONFIG("windows") {
INCLUDEPATH += $$PWD/libs/openal-soft-1.23.1-mingw-64-bit/include
LIBS += -L$$PWD/libs/openal-soft-1.23.1-mingw-64-bit/lib/x64
LIBS += -lOpenAL32.dll
}
It works for Desktop and WebAssembly without any changes. I just tried to build Desktop demo to WebAssembly to see what errors in will show for OpenAL Soft but it works! You can run my following my demo on itch and click on the sound button on the right button corner. I don't understand how they have made it.
When building in WASM, what is inside this section is ignored: CONFIG("windows"). Used OpenAL browser implementation using Emscripten: https://emscripten.org/docs/porting/Audio.html All code written in OpenAL, without the need for changes on the part of the programmer, is compiled into WASM. Now it is clear.
I implemented the audio capture by C, then compile it into the WASM library. finally use it in the Chrome browser。 But i need to restart the capture device (alcCatureStop then alcCaptureStart) after alcCaptureSamples. Otherwise (if not restart), it will loss the data and give me the duplicate data . Such as the recording content is (1,2,3,4,5,6,7,8,9,10,11,12),i get the PCM is (1,2,3,1,2,3,7,8,9,7,8,9)。 Do you know why ? and Whether data will be lost if the device is restarted ?(thank you very much)