Page 1 of 1

WASM samples has no audio

Posted: 22 Jan 2025, 13:04
by Notsee
Hello

So i've been checking out Noesis samples for WASM, and it seems that none of the samples has audio working.
Is audio not yet implemented for WASM?

Re: WASM samples has no audio

Posted: 23 Jan 2025, 00:25
by jsantos
Yes, audio has not been implemented in the EmscriptenDisplay. For now, we don't have concrete plans for this. This is part of the App framework, whose source code is provided.

Re: WASM samples has no audio

Posted: 26 Jan 2025, 16:51
by Notsee
So, is it possible for us to implement the audio support on our own?
If so, are there any guides/example available to help us achieve that?

Re: WASM samples has no audio

Posted: 27 Jan 2025, 19:34
by jsantos
Our Display base class offers a few virtual functions for this:
/// Plays audio file
void PlayAudio(const Noesis::Uri& uri, float volume);
    
/// Halts the currently playing audio
void PauseAudio();

/// Resumes playback
void ResumeAudio();
Please have a look at the windows implementation (Win32Display.cpp) for an example of how to do this.

Re: WASM samples has no audio

Posted: 28 Jan 2025, 03:17
by Notsee
Thanks for the pointer. I actually couldn't find the implementation in Win32Display.cpp, but I found it within Audio.mm.cpp which uses mini_al.

After discovering that mini_al supports WebAssembly, I added this define:
#ifdef NS_PLATFORM_EMSCRIPTEN
  #ifndef HAVE_AUDIO
    #define HAVE_AUDIO 1
  #endif
#endif
And now the audio is working in the WASM build.

However, I'm curious about the reasoning behind not including WASM audio support by default.
Was there any specific technical limitation or concern that led to this decision?

Re: WASM samples has no audio

Posted: 04 Feb 2025, 13:47
by jsantos
Was there any specific technical limitation or concern that led to this decision?
Probably because when WASM was implemented, audio was not supported in this library. In fact, the library has now a different name, miniaudio and we should update it. Could you please create a ticket for this?

Re: WASM samples has no audio

Posted: 05 Feb 2025, 00:11
by Notsee
Thanks! Created a ticket for the mini_al update:
https://www.noesisengine.com/bugs/view.php?id=3931