[SDL_Mixer]: Preliminary music integration

I just submitted issue #1194 to Bugzilla, containing a patch for SDL_Mixer. This
patch updates the API to require music to play on a channel, just like sound,
instead of living in a separate “world”. Among other things, this means that
SDL_Mixer effects can now be attached to music.

This has been tested and will work properly with one or more songs, at least
with libmodplug; haven’t tested the other decoders yet, and I know that playing
multiple songs from a WAV source will definitely not work. Playing multiple
songs on top of each other sounds kind of weird, but being able to play two
songs at once on two different channels makes some practical effects available,
such as cross-fading.

This is kind of a work in progress, but the basic concept works.

Mason

I just submitted issue #1194 to Bugzilla, containing a patch for SDL_Mixer. This
patch updates the API to require music to play on a channel, just like sound,
instead of living in a separate “world”. ?Among other things, this means that
SDL_Mixer effects can now be attached to music.

This has been tested and will work properly with one or more songs, at least
with libmodplug; haven’t tested the other decoders yet, and I know that playing
multiple songs from a WAV source will definitely not work. ?Playing multiple
songs on top of each other sounds kind of ?weird, but being able to play two
songs at once on two different channels makes some practical effects available,
such as cross-fading.

This is kind of a work in progress, but the basic concept works.

Thank you Mason, Thank you very much!

Bob PendletonOn Fri, Apr 29, 2011 at 9:49 PM, Mason Wheeler wrote:

Mason


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


±----------------------------------------------------------

I just submitted issue #1194 to Bugzilla, containing a patch for SDL_Mixer.
This
patch updates the API to require music to play on a channel, just like
sound,
instead of living in a separate “world”. Among other things, this means
that
SDL_Mixer effects can now be attached to music.

Very nice :slight_smile:

This has been tested and will work properly with one or more songs, at
least
with libmodplug; haven’t tested the other decoders yet, and I know that
playing
multiple songs from a WAV source will definitely not work.

Do you mean a single wave source? If so, are you loading the file by name or
are you opening the RWops yourself? The wave music loader stores the open
RWops and reads directly from the filesystem as needed (see bug 1168). If
you load the music by filename or if you create two SDL_RWops from the same
file it will create two separate handles and should work in theory…On Fri, Apr 29, 2011 at 7:49 PM, Mason Wheeler wrote:


Matthew Orlando
http://cogwheel.info

I’m talking about all the places in music.c where the massive switchboards say
"case MUS_WAV:" and then execute a WAVStream_* command that does not take
music_playing->data.wave as a parameter. That means that the WAVStream API is
stateful and is storing a single stream internally.

I just looked at wavstream.c, and it’s right there, about 90 lines in:

/* Currently we only support a single stream at a time */
static WAVStream *music = NULL;

That will have to change, if anyone cares enough to change it. Right now I’m
busy with other things.________________________________
From: maorlando@gmail.com (Matthew Orlando)
Subject: Re: [SDL] [SDL_Mixer]: Preliminary music integration

This has been tested and will work properly with one or more songs, at least

with libmodplug; haven’t tested the other decoders yet, and I know that playing

multiple songs from a WAV source will definitely not work.

Do you mean a single wave source? If so, are you loading the file by name or are
you opening the RWops yourself? The wave music loader stores the open RWops and
reads directly from the filesystem as needed (see bug 1168). If you load the
music by filename or if you create two SDL_RWops from the same file it will
create two separate handles and should work in theory…

Matthew Orlando
http://cogwheel.info

This is extremely useful and the only way to play multiple MP3s through
libmad. But the patch doesn’t apply against current Hg.

Are you still working on this?On 04/30/2011 05:49 AM, Mason Wheeler wrote:

I just submitted issue #1194 to Bugzilla, containing a patch for SDL_Mixer. This
patch updates the API to require music to play on a channel, just like sound,
instead of living in a separate “world”. Among other things, this means that
SDL_Mixer effects can now be attached to music.
[…]

It wasn’t meant to apply against the current Hg, it was meant to apply against what was current
when I released it.? I’ve got a few more changes to make, but for the moment I’ve been more
focused on the program I made the changes to support, not on SDL_Mixer itself.

So my patch never got merged, then?? Anyone know why not?________________________________
From: realnc@arcor.de (Nikos Chantziaras)
To: sdl at libsdl.org
Sent: Tuesday, July 19, 2011 3:45 AM
Subject: Re: [SDL] [SDL_Mixer]: Preliminary music integration

On 04/30/2011 05:49 AM, Mason Wheeler wrote:

I just submitted issue #1194 to Bugzilla, containing a patch for SDL_Mixer. This
patch updates the API to require music to play on a channel, just like sound,
instead of living in a separate “world”.? Among other things, this means that
SDL_Mixer effects can now be attached to music.
[…]

This is extremely useful and the only way to play multiple MP3s through
libmad.? But the patch doesn’t apply against current Hg.

Are you still working on this?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

So my patch never got merged, then? Anyone know why not?

Inertia; I’m (very slowly) working through the backlog. I haven’t even
looked at it yet.

SDL_mixer hasn’t changed much recently, so merging won’t be hard. I’ll
take a look at it when I get some time.

–ryan.

Would be nice to have this. SDL_mixer’s utility is currently very
limited due to its inability to play multiple streams. Which is kinda
weird, since it’s supposed to be a “mixer”. :slight_smile:

Currently, I’m using the sample API to be able to play more than one
sound, and RAM usage suffers greatly, so do loading times (for example,
two MP3 files need to be decompressed intro RAM with SDL_sound,
consuming about 100MB each, and then loaded with Mix_QuickLoad_RAW()).
This stuff should really be streamed from disk instead.

Currently, SDL_mixer looks more like two different libraries (sample and
music APIs) in one source code package. In a perfect world, we would
only have the sample API, and no support for anything else than raw
audio. Then one would use SDL_sound for decoding, and SDL_mixer for mixing.On 07/20/2011 01:28 AM, Ryan C. Gordon wrote:

So my patch never got merged, then? Anyone know why not?

Inertia; I’m (very slowly) working through the backlog. I haven’t even
looked at it yet.

SDL_mixer hasn’t changed much recently, so merging won’t be hard. I’ll
take a look at it when I get some time.

Mason,

I ported your patch to current Hg. It applies to both the default as
well as the stable-1.2 branch.

I need a bit of help though in figuring out why there’s a weird sound
artifact when doing fade-in and fade-out during the fade.

I am attaching the updated patch. I hope someone can help in fixing
this problem.

(The patch is bzipped because the list blocked it due to its size.)On 19/07/11 15:54, Mason Wheeler wrote:

It wasn’t meant to apply against the current Hg, it was meant to apply
against what was current
when I released it. I’ve got a few more changes to make, but for the
moment I’ve been more
focused on the program I made the changes to support, not on SDL_Mixer
itself.

So my patch never got merged, then? Anyone know why not?

From: Nikos Chantziaras
To: sdl at libsdl.org
Sent: Tuesday, July 19, 2011 3:45 AM
Subject: Re: [SDL] [SDL_Mixer]: Preliminary music integration

On 04/30/2011 05:49 AM, Mason Wheeler wrote:

I just submitted issue #1194 to Bugzilla, containing a patch for
SDL_Mixer. This
patch updates the API to require music to play on a channel, just
like sound,
instead of living in a separate “world”. Among other things, this
means that
SDL_Mixer effects can now be attached to music.
[…]

This is extremely useful and the only way to play multiple MP3s through
libmad. But the patch doesn’t apply against current Hg.

Are you still working on this?

-------------- next part --------------
A non-text attachment was scrubbed…
Name: music_channels.diff.bz2
Type: application/x-bzip
Size: 9111 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20120424/37bb433e/attachment.bin

OK, this is not because of the fade itself, but because of the volume
change. If you change the volume to anything else that max volume, the
sound is glitchy. Happens with MP3 (MAD) and Ogg Vorbis. ModPlug does
not seem to be affected.

Another problem is that MIDI doesn’t produce any sound (both Timidity as
well as FluidSynth.)

I’m also working on a patch that restores binary compatibility with the
current SDL_mixer 1.2. This will be helpful for testing it by using
existing applications.On 24/04/12 09:37, Nikos Chantziaras wrote:

I need a bit of help though in figuring out why there’s a weird sound
artifact when doing fade-in and fade-out during the fade.

I was able to fix both problems. I’ve set up a mercurial repo here:

https://bitbucket.org/realnc/sdl_mixer

It still needs work, like the WAVE decoder and Timidity not supporting
multiple streams. (FluidSynth works.) Note that mixing works
regardless: playing WAVE music and MP3 music at the same time works.
Playing two WAVEs at the same time doesn’t.On 24/04/12 10:49, Nikos Chantziaras wrote:

On 24/04/12 09:37, Nikos Chantziaras wrote:

I need a bit of help though in figuring out why there’s a weird sound
artifact when doing fade-in and fade-out during the fade.

OK, this is not because of the fade itself, but because of the volume
change. If you change the volume to anything else that max volume, the
sound is glitchy. Happens with MP3 (MAD) and Ogg Vorbis. ModPlug does
not seem to be affected.

Another problem is that MIDI doesn’t produce any sound (both Timidity as
well as FluidSynth.)

I’ve now fixed WAVE to support multiple music streams. SMPEG too. So
all of these work with multiple channels now:

MUS_WAV, MUS_OGG, MUS_FLAC, MUS_MP3, MUS_MP3_MAD, MUS_MID (with
FluidSynth), MUS_MODPLUG.

The only ones that don’t support this now are MikMod and Timidity; they
can only play one stream at a time. Of course native MIDI and MUS_CMD
cannot be supported since they work externally.On 25/04/12 08:04, Nikos Chantziaras wrote:

https://bitbucket.org/realnc/sdl_mixer

It still needs work, like the WAVE decoder and Timidity not supporting
multiple streams. (FluidSynth works.) Note that mixing works regardless:
playing WAVE music and MP3 music at the same time works. Playing two
WAVEs at the same time doesn’t.

It’s been three months. No interest in this at all? Pity.On 25/04/12 13:16, Nikos Chantziaras wrote:

On 25/04/12 08:04, Nikos Chantziaras wrote:

https://bitbucket.org/realnc/sdl_mixer

It still needs work, like the WAVE decoder and Timidity not supporting
multiple streams. (FluidSynth works.) Note that mixing works regardless:
playing WAVE music and MP3 music at the same time works. Playing two
WAVEs at the same time doesn’t.

I’ve now fixed WAVE to support multiple music streams. SMPEG too. So
all of these work with multiple channels now:

MUS_WAV, MUS_OGG, MUS_FLAC, MUS_MP3, MUS_MP3_MAD, MUS_MID (with
FluidSynth), MUS_MODPLUG.

The only ones that don’t support this now are MikMod and Timidity; they
can only play one stream at a time. Of course native MIDI and MUS_CMD
cannot be supported since they work externally.

There may be more interest if you submitted a patch rather than a
repo-clone link. Either that, or make a pull request (does mercurial do
that?), and put some information into SDL’s bugzilla system.

-AlexOn Mon, Jul 23, 2012 at 10:31 AM, Nikos Chantziaras wrote:

On 25/04/12 13:16, Nikos Chantziaras wrote:

On 25/04/12 08:04, Nikos Chantziaras wrote:

https://bitbucket.org/realnc/**sdl_mixerhttps://bitbucket.org/realnc/sdl_mixer

It still needs work, like the WAVE decoder and Timidity not supporting
multiple streams. (FluidSynth works.) Note that mixing works regardless:
playing WAVE music and MP3 music at the same time works. Playing two
WAVEs at the same time doesn’t.

I’ve now fixed WAVE to support multiple music streams. SMPEG too. So
all of these work with multiple channels now:

MUS_WAV, MUS_OGG, MUS_FLAC, MUS_MP3, MUS_MP3_MAD, MUS_MID (with
FluidSynth), MUS_MODPLUG.

The only ones that don’t support this now are MikMod and Timidity; they
can only play one stream at a time. Of course native MIDI and MUS_CMD
cannot be supported since they work externally.

It’s been three months. No interest in this at all? Pity.

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I had opened a bug for this back then.

It’s just that there’s no reply at all :-/ Total silence.On 23/07/12 17:55, Alex Barry wrote:

There may be more interest if you submitted a patch rather than a
repo-clone link. Either that, or make a pull request (does mercurial do
that?), and put some information into SDL’s bugzilla system.

-Alex

On Mon, Jul 23, 2012 at 10:31 AM, Nikos Chantziaras <@Nikos_Chantziaras mailto:Nikos_Chantziaras> wrote:

On 25/04/12 13:16, Nikos Chantziaras wrote:

    On 25/04/12 08:04, Nikos Chantziaras wrote:

        https://bitbucket.org/realnc/__sdl_mixer
        <https://bitbucket.org/realnc/sdl_mixer>

        It still needs work, like the WAVE decoder and Timidity not
        supporting
        multiple streams. (FluidSynth works.) Note that mixing works
        regardless:
        playing WAVE music and MP3 music at the same time works.
        Playing two
        WAVEs at the same time doesn't.


    I've now fixed WAVE to support multiple music streams.  SMPEG
    too.  So
    all of these work with multiple channels now:

        MUS_WAV, MUS_OGG, MUS_FLAC, MUS_MP3, MUS_MP3_MAD, MUS_MID (with
    FluidSynth), MUS_MODPLUG.

    The only ones that don't support this now are MikMod and
    Timidity; they
    can only play one stream at a time.  Of course native MIDI and
    MUS_CMD
    cannot be supported since they work externally.


It's been three months.  No interest in this at all?  Pity.

Great, I’d like to consider this for the SDL2_mixer release.

Can you submit a patch based on the latest SDL updates at
hg.libsdl.org/SDL_mixer? I just fixed a bunch of things in music.c, so you
may need to do some merging.

Thanks!On Wed, Apr 25, 2012 at 3:16 AM, Nikos Chantziaras wrote:

On 25/04/12 08:04, Nikos Chantziaras wrote:

https://bitbucket.org/realnc/**sdl_mixerhttps://bitbucket.org/realnc/sdl_mixer

It still needs work, like the WAVE decoder and Timidity not supporting
multiple streams. (FluidSynth works.) Note that mixing works regardless:
playing WAVE music and MP3 music at the same time works. Playing two
WAVEs at the same time doesn’t.

I’ve now fixed WAVE to support multiple music streams. SMPEG too. So all
of these work with multiple channels now:

MUS_WAV, MUS_OGG, MUS_FLAC, MUS_MP3, MUS_MP3_MAD, MUS_MID (with
FluidSynth), MUS_MODPLUG.

The only ones that don’t support this now are MikMod and Timidity; they
can only play one stream at a time. Of course native MIDI and MUS_CMD
cannot be supported since they work externally.

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I’ll try and find some time at some point for this. It should be noted
however that the API additions and the design in general was geared
towards version 1.2 and therefore was not optimal; there’s some hacks
and kludges in there (and general ugliness) in order to keep full API
and ABI compatibility. Since version 2.0 is free to break source
compatibility, this patch set really isn’t that optimal. This should be
kept in mind before considering adding this into SDL2_mixer.On 02/06/13 06:36, Sam Lantinga wrote:

Great, I’d like to consider this for the SDL2_mixer release.

Can you submit a patch based on the latest SDL updates at
hg.libsdl.org/SDL_mixer http://hg.libsdl.org/SDL_mixer? I just fixed a
bunch of things in music.c, so you may need to do some merging.

Thanks!

On Wed, Apr 25, 2012 at 3:16 AM, Nikos Chantziaras <@Nikos_Chantziaras mailto:Nikos_Chantziaras> wrote:

On 25/04/12 08:04, Nikos Chantziaras wrote:

    https://bitbucket.org/realnc/__sdl_mixer
    <https://bitbucket.org/realnc/sdl_mixer>

    It still needs work, like the WAVE decoder and Timidity not
    supporting
    multiple streams. (FluidSynth works.) Note that mixing works
    regardless:
    playing WAVE music and MP3 music at the same time works. Playing two
    WAVEs at the same time doesn't.


I've now fixed WAVE to support multiple music streams.  SMPEG too.
  So all of these work with multiple channels now:

   MUS_WAV, MUS_OGG, MUS_FLAC, MUS_MP3, MUS_MP3_MAD, MUS_MID (with
FluidSynth), MUS_MODPLUG.

The only ones that don't support this now are MikMod and Timidity;
they can only play one stream at a time.  Of course native MIDI and
MUS_CMD cannot be supported since they work externally.

Okay, feel free to create a patch for your optimal API and we’ll consider
it for 2.1.

Cheers!On Tue, Jun 4, 2013 at 11:48 AM, Nikos Chantziaras wrote:

I’ll try and find some time at some point for this. It should be noted
however that the API additions and the design in general was geared towards
version 1.2 and therefore was not optimal; there’s some hacks and kludges
in there (and general ugliness) in order to keep full API and ABI
compatibility. Since version 2.0 is free to break source compatibility,
this patch set really isn’t that optimal. This should be kept in mind
before considering adding this into SDL2_mixer.

On 02/06/13 06:36, Sam Lantinga wrote:

Great, I’d like to consider this for the SDL2_mixer release.

Can you submit a patch based on the latest SDL updates at
hg.libsdl.org/SDL_mixer <http://hg.libsdl.org/SDL_**mixerhttp://hg.libsdl.org/SDL_mixer>?
I just fixed a

bunch of things in music.c, so you may need to do some merging.

Thanks!

On Wed, Apr 25, 2012 at 3:16 AM, Nikos Chantziaras <realnc at gmail.com <mailto:realnc at gmail.com>> wrote:

On 25/04/12 08:04, Nikos Chantziaras wrote:

    https://bitbucket.org/realnc/_**_sdl_mixer<https://bitbucket.org/realnc/__sdl_mixer>

    <https://bitbucket.org/realnc/**sdl_mixer<https://bitbucket.org/realnc/sdl_mixer>
    It still needs work, like the WAVE decoder and Timidity not
    supporting
    multiple streams. (FluidSynth works.) Note that mixing works
    regardless:
    playing WAVE music and MP3 music at the same time works. Playing

two
WAVEs at the same time doesn’t.

I've now fixed WAVE to support multiple music streams.  SMPEG too.
  So all of these work with multiple channels now:

   MUS_WAV, MUS_OGG, MUS_FLAC, MUS_MP3, MUS_MP3_MAD, MUS_MID (with
FluidSynth), MUS_MODPLUG.

The only ones that don't support this now are MikMod and Timidity;
they can only play one stream at a time.  Of course native MIDI and
MUS_CMD cannot be supported since they work externally.

_____________**
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/**listinfo.cgi/sdl-libsdl.orghttp://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org