Notsee
Topic Author
Posts: 4
Joined: 09 Jan 2025, 12:55

WASM samples has no audio

22 Jan 2025, 13:04

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?

Last edited by Notsee on 28 Jan 2025, 03:23, edited 1 time in total.
 
User avatar
jsantos
Site Admin
Posts: 4208
Joined: 20 Jan 2012, 17:18
Contact:

Re: WASM samples has no audio

23 Jan 2025, 00:25

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.
 
Notsee
Topic Author
Posts: 4
Joined: 09 Jan 2025, 12:55

Re: WASM samples has no audio

26 Jan 2025, 16:51

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?
 
User avatar
jsantos
Site Admin
Posts: 4208
Joined: 20 Jan 2012, 17:18
Contact:

Re: WASM samples has no audio

27 Jan 2025, 19:34

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.
 
Notsee
Topic Author
Posts: 4
Joined: 09 Jan 2025, 12:55

Re: WASM samples has no audio

28 Jan 2025, 03:17

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?

 
User avatar
jsantos
Site Admin
Posts: 4208
Joined: 20 Jan 2012, 17:18
Contact:

Re: WASM samples has no audio

04 Feb 2025, 13:47

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?
 
Notsee
Topic Author
Posts: 4
Joined: 09 Jan 2025, 12:55

Re: WASM samples has no audio

05 Feb 2025, 00:11

Thanks! Created a ticket for the mini_al update:
https://www.noesisengine.com/bugs/view.php?id=3931

Who is online

Users browsing this forum: Semrush [Bot] and 2 guests