Integrate soft synth with SDL_Mixer, emscipten?

Hi,

I have written a little soft synth, that works with embedded hw. You know ARM Cortex etc. Output so far has been in I2S hardware.

Now, my friend makes a platform (meshpage.org) that uses SDL extensively. He supports both native, and web via emsripten. He told me that his audio is based on SDL_Mixer. We’d want to keep the SDL_Mixer so we can play music from my synth and also sound effects same time.

The question is how to integrate so that we get that all multiplatform and web glory?

The soft synth is a typical soft synth - it needs a callback to render next slice of audio in raw format, when buffer is becoming empty.
I took a quick look in SDL_Mixer, and I can see no trivial way to do this.

I appreciate any pointers!

Could you use SDL2 Core Audio (SDL_OpenAudioDevice etc.) instead of SDL2_mixer? That can work exactly as you describe, calling your callback function to refill the buffer.

But then you gotta do the mixing yourself…

Mix_HookMusic() sounds like what you want?

Depending on what ‘mixing’ you need to do, another Core Audio function SDL_MixAudioFormat() may be suitable. I don’t use SDL2_mixer, too many dependencies for my liking.