Closed konsumer closed 2 months ago
Do you have your whole code available? Would love to check it out... When loading the WAV in a desktop audio playing, it's not loading correctly. Could there be somehting wrong with how it's setting up the file?
Does pntr_sound* s = pntr_load_sound_from_memory
output something other than NULL?
Been wanting to add buffer support to playing audio, so that you wouldn't need to load it as a wav after creating it.
Yeh, I can work on buffer-support too. This method of mine to generate a wav of sfx feels like a total-hack, anyway, and it's a bit slow (there is a noticeable delay, which is maybe fine if I preload some sfx, but not great on the fly.)
The code is here.
I feel like a simplified example would help (plain pntr_app compiloed to native and web) so I will make one, as this has a few layers to troubleshoot.
Ok, so I added a few headers and some cmake-config to get sfx in example, here. Feel free to use the pntr_load_sfx
function too, if you want. I generate a "powerup" sound and it works in raylib example. Press space to activate.
I build with
emcmake cmake -B build -DPNTR_APP_BUILD_EXAMPLE_RAYLIB=false -DPNTR_APP_BUILD_EXAMPLE_WEB=true
emmake make -C build
And it seems much stricter:
/src/example/sfx_gen.c:85:20: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
85 | static float rndNP1()
| ^
| void
1 error generated.
make[2]: *** [example/CMakeFiles/pntr_app_example_web.dir/build.make:92: example/CMakeFiles/pntr_app_example_web.dir/sfx_gen.c.o] Error 1
I will come back to it later, when I have more time.
I think it must be something in my web host-stuff. I made pntr_app_sfx, and it works in example with both emscritpen & native. I am going to close this.
I have a sfx function that generates sound like this:
This works on native, but is failing on web. It creates the blob-URL but the mime-type is wrong, and wav looks wrong to my eyes (the
data
part seems off)This was working before, and still works ok on native, but I may have changed something in my host.
Here is my C code in game-wasm (the wasm that is hosted in web, that calls the other wasm):
And here is my js-host code to copy the struct out:
copyBytesFromCart
andcopyBytesToCart
seem to work, otherwise. I will keep testing and see if I can narrow down the issue. Maybe a more isolated example would help.Here is the output saved from web: test.wav.zip