The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Ogg Opus support in SDL_mixer
FaultyRAM


Joined: 20 Mar 2014
Posts: 1
Over the past couple of days I've been working on adding support for Ogg Opus audio to SDL_mixer. You can find the current sources here, under the music-opus branch. This code has not been thoroughly tested - be warned!

A few things to note:
  • Mix_LoadOpus_RW() doesn't support chaining, because each link can have a different number of channels. While libopusfile does offer a way around this (via op_read_stereo() and op_read_float_stereo()), chaining is already supported via streaming playback, and that doesn't require down-mixing your audio to 2 channels.
  • Opus audio is always 48kHz. The original sample rate is preserved in the Ogg header, but you should still play the audio at 48kHz unless the output device doesn't support it.
  • By default the code uses floating-point operations (i.e. it calls op_read_float()), but it can be configured to use fixed-point operations (i.e. op_read()) instead. If you're using the configure script, simply pass --disable-music-opus-float; if you're using Visual Studio, you'll need to remove OPUS_FLOAT from the project's preprocessor flags.
  • Speaking of Visual Studio, currently only the VS2010 project compiles with Ogg Opus support, and the repository only has 32-bit binaries. Sorry.
  • Because the Ogg container format can hold either Opus or Vorbis audio, things that referred to "Ogg" now use "Vorbis" instead, to avoid confusion (e.g. call Mix_LoadMUSType_RW(src, MUS_VORBIS, freesrc) instead of Mix_LoadMUSType_RW(src, MUS_OGG, freesrc)). This change alone shouldn't affect binary compatibility, but you will need to update your code if it uses the old names. Additionally, if both Vorbis and Opus are enabled and you pass an Ogg stream to SDL_mixer, it will initialise the Opus module and call op_test() to determine if it's dealing with an Opus stream (if not, the Vorbis module gets to have it).