Skip to content

A minimal library which renders music using HTML5 <audio>. For use with Emscripten.

License

Notifications You must be signed in to change notification settings

devappd/html5_mixer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

html5_mixer

This is a minimal drop-in replacement for the music functions of SDL2_mixer to be used with the Emscripten compiler. It uses HTML5 <audio> to render music.

Overview

emscripten-ports/SDL2_mixer is a WebAssembly port that performs all sound decoding in WASM. It pushes samples via emscripten-ports/SDL2 to a Web Audio context for playback.

While this approach ensures the highest parity with native builds, the program is susceptible to dropped samples and playback stutters because music decoding and audio rendering both occur in the main thread.

To reduce processing load, we implement the SDL2_mixer interface to use the browser's native playback features via <audio>.

How to Use

Download this package to a location of your choice. Specify ./include in your "Include" directories and specify the files within ./src in your sources.

In your compiler and linker flags, specify -s USE_SDL=2. You may use this library concurrently with SDL Mixer (-s USE_SDL_MIXER=2), but this is not required.

You may shim SDL Mixer's Mix_*() music functions by specifying -DHTML5_MIXER_SHIM_MUSIC in your macro defines.

Support exists to link this library without SDL2, but this is untested. If you wish to try, specify -DHTML5_MIXER_NO_SDL.

Notes

We do not perform any decoding; we merely pass the URL or data buffer to an Audio() instance.

Your audio files must be supported by the user's web browser. For a format compatibility table, see Wikipedia.

Currently, we support a minimal subset of the SDL2_mixer API. See issue #1 for progress.

Potential Next Steps

See Also

License

The html5_mixer code is released under MIT License.

This project incorporates code from SDL_mixer_html5 which is released under 3-clause BSD License.

About

A minimal library which renders music using HTML5 <audio>. For use with Emscripten.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages