No SDL2_mixer port? What do people use for sound+music?

617 views
Skip to first unread message

Goran Milovanovic

unread,
Aug 29, 2017, 10:55:46 AM8/29/17
to emscripten-discuss
I would like to compile a project that's built on top of SDL2 libraries. One of those libraries is SDL2_mixer, which seems to have no emscripten port ... I find that strange, because there's a port for everything else (even SDL2_net), and audio seems like one of the more fundamental requirements for a large number of applications.

So, I'm just wondering why there's no port for SDL2_mixer, and what people typically do for sound+music support (I hope it's something other than "use SDL1").

Thanks.

Александр Гурьянов

unread,
Aug 29, 2017, 2:11:35 PM8/29/17
to emscripte...@googlegroups.com
I prefer to use SDL_mixer_1.2 it works fast. Also it supports ogg, mp3
panning and dinstance.
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to emscripten-disc...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Alon Zakai

unread,
Aug 29, 2017, 6:11:24 PM8/29/17
to emscripten-discuss
Another option is OpenAL.


> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Floh

unread,
Aug 31, 2017, 12:42:43 AM8/31/17
to emscripten-discuss
If you're looking for a portable audio solution, SoLoud might be a better option than OpenAL btw. I found OpenAL's multiplatform support quite lacking (e.g. on Windows and Android).

SoLoud is very lean, the various platform-backends are extremely simple, and it has a nice medium-level API:


For HTML5 I'm using SoLoud's SDL1 backend (implemented here: https://github.com/jarikomppa/soloud/blob/master/src/backend/sdl_static/soloud_sdl_static.cpp). I was considering adding an emscripten-specific backend to SoLoud but found the client-size overhead of the SDL1 wrapper to be small enough that a separate backend wasn't worth it IMHO.

Cheers,
-Floh

Goran Milovanovic

unread,
Aug 31, 2017, 9:37:41 AM8/31/17
to emscripten-discuss
I assume you're also using SDL1 in general, as it seems that SDL_mixer_1.2 requires that.

If I could somehow use SDL2, but then just have emscripten use SDL_mixer_1.2 for audio, that would work really well for me.

Goran Milovanovic

unread,
Aug 31, 2017, 9:45:33 AM8/31/17
to emscripten-discuss
As Floh mentioned, it seems to have substandard multiplatform support, so it's not really a good solution for me.

What I really find hard to understand, is why there's no SDL2_mixer port, because, as I noted before, there's a port for everything else, and obviously SDL_mixer_1.2 is supported internally, so it seems like it should be possible to make SDL2_mixer work with emscripten.

Goran Milovanovic

unread,
Aug 31, 2017, 9:54:06 AM8/31/17
to emscripten-discuss
Hey, thanks for the recommendation. That seems like something that could work for my needs, as it also seems to support SDL2: https://github.com/jarikomppa/soloud/blob/master/src/backend/sdl2_static/soloud_sdl2_static.cpp

Hopefully, that should work fine with the SDL2 port.

Alon Zakai

unread,
Aug 31, 2017, 1:34:49 PM8/31/17
to emscripten-discuss
On Thu, Aug 31, 2017 at 6:45 AM, Goran Milovanovic <goranm...@gmail.com> wrote:
As Floh mentioned, it seems to have substandard multiplatform support, so it's not really a good solution for me.

What I really find hard to understand, is why there's no SDL2_mixer port, because, as I noted before, there's a port for everything else, and obviously SDL_mixer_1.2 is supported internally, so it seems like it should be possible to make SDL2_mixer work with emscripten.

It should be possible, yeah. I think it's just that the other solutions are good enough for most people, so no one was motivated to port SDL2_mixer yet. But it would be great if someone did.

Btw, it should be possible to mix SDL1 audio with everything else from SDL2, the implementations should not collide (but I didn't verify this).
 

On Tuesday, August 29, 2017 at 6:11:24 PM UTC-4, Alon Zakai wrote:
Another option is OpenAL.

On Tue, Aug 29, 2017 at 11:11 AM, Александр Гурьянов <caii...@gmail.com> wrote:
I prefer to use SDL_mixer_1.2 it works fast. Also it supports ogg, mp3
panning and dinstance.

2017-08-29 21:55 GMT+07:00 Goran Milovanovic <goranm...@gmail.com>:
> I would like to compile a project that's built on top of SDL2 libraries. One
> of those libraries is SDL2_mixer, which seems to have no emscripten port ...
> I find that strange, because there's a port for everything else (even
> SDL2_net), and audio seems like one of the more fundamental requirements for
> a large number of applications.
>
> So, I'm just wondering why there's no port for SDL2_mixer, and what people
> typically do for sound+music support (I hope it's something other than "use
> SDL1").
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an

> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Goran Milovanovic

unread,
Sep 1, 2017, 11:06:46 AM9/1/17
to emscripten-discuss
I think it would be worthwhile: A lot of SDL projects usually leverage the extra SDL libraries for common requirements like image loading, font rendering, and audio mixing. With SDL1, where all those libraries are supported, developers don't have to rewrite their code, but for SDL2, where there's no mixer support, developers have to go hunting for a new audio system. It wouldn't be as annoying if there were no other SDL2 library ports, but since there are basically ports for everything else, it becomes a missing piece that's forcing the developer to do significantly more work, just to have basic audio capability.

If it's possible to use SDL1 audio with SDL2, that would be fine, but I don't know how to set that up. I tried simply compiling:

> em++ $SRC_DIR/*.cpp -I $INC_DIR -s WASM=1 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -o out.bc

But that results in an error:

> fatal error: 'SDL_mixer.h' file not found
> #include "SDL_mixer.h"


Another option is OpenAL.

> email to emscripten-discuss+unsub...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alon Zakai

unread,
Sep 1, 2017, 1:42:35 PM9/1/17
to emscripten-discuss
Hmm, yeah, I guess it's not that easy. The actual implementations are completely separate though, so it could work, but I guess something would need to be figured out with those includes.

I agree that the best thing would be if someone volunteered to port SDL2_mixer.

Another option is OpenAL.


> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Aidan Hobson Sayers

unread,
Sep 18, 2017, 2:14:17 PM9/18/17
to emscripte...@googlegroups.com
I have it hanging around for another project and intend to contribute back at some point, but for now:
```
rm -rf SDL2_mixer
mv SDL2_mixer-2.0.0 SDL2_mixer
cd SDL2_mixer
emconfigure ./configure --prefix=$(pwd)/dist --enable-music-ogg --disable-music-ogg-shared CFLAGS="-s USE_VORBIS=1"
emmake make install
cd ..
```

It works great. In fact, the audio was one of the easiest parts of this particular project to get working :)

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Alon Zakai

unread,
Nov 27, 2017, 7:26:13 PM11/27/17
to emscripten-discuss
Aidan, any chance you have time for this? Our current SDL2-using-SDL1 hacks are pretty fragile, I just noticed a regression there now. Would be good to have a proper SDL2_mixer port.

(The regression I noticed is from https://github.com/kripken/emscripten/commit/7a5744d75 but that's a correct fix for other issues, that is, it just uncovered an existing brokenness of trying to mix SDL1 and 2...)

To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages