Parts of mod/xm/it files

Hiya.

I’m making a new game that’ll use SDL_mixer. I really want to do
generated music. The idea is to do something like this:

intro
transition
loop:
choose one of (a,b,c,d…)
goto loop
transition
loop:
choose one of (A, B, C, D…)
goto loop
transition
outro

where the choice of loop items is based on the current state/mood.

To keep download size to a minimum, I would like to do this with .mod
files (or the equivalent).

BUT…

I can’t do it all in one mod file because (as far as I can tell)
SDL_mixer doesn’t support the ability to move to a specific point in
a music track, nor does it seem to support the ability to get
notification at any point other than the end of the track.

But If I do this with separate .mods, then I duplicate the samples in
every mod, which is a very Bhad Thing in this case – I could end up
with literally dozens of copies of the samples.

So I’d like to do one of the following things, and wondering if
anyone else knows which would be easiest, or if any of them have
already been done:

  • Add additional notification features to SDL_mixer so that I could
    move around within a single mod with speed and accuracy.
  • Add the ability to load a mod without samples (is that a midi
    file?) that would reuse samples from a different mod.
  • Load my own sample set (in some format?) and play midi files
    instead.

My snooping around the source leads me to think the notification
stuff might not be too bad, but would it work? Modifying mikmod seems
pretty scary – I don’t have the domain knowledge to poke around in
there comfortably.

Anybody have any ideas or suggestions? Alternate solutions?

Kent-- 

Kent Quirk, CTO, CogniToy
@Kent_Quirk

Hiya.
I’m making a new game that’ll use SDL_mixer. I really want to do
generated music. The idea is to do something like this:
where the choice of loop items is based on the current state/mood.
To keep download size to a minimum, I would like to do this with .mod
files (or the equivalent).
BUT…
I can’t do it all in one mod file because (as far as I can tell)
SDL_mixer doesn’t support the ability to move to a specific point in
a music track, nor does it seem to support the ability to get
notification at any point other than the end of the track.

There are at least two options:

a) Code directly with the MikMod library, which SDL_mixer uses.
Maybe even add some hooks to SDL_mixer to support jumps.
This should not be too hard; I know MikMod can handle this.
b) If you really need a lot of control, you could implement your own
MOD player. It’s not all that difficult as long as you have the right
documentation; I’d be happy to send you my mod/s3m code and the docs
I used to write it.

  • Add additional notification features to SDL_mixer so that I could
    move around within a single mod with speed and accuracy.
  • Add the ability to load a mod without samples (is that a midi
    file?) that would reuse samples from a different mod.

Mod and MIDI are quite different; about the only similarity is that they
store music structurally rather than as a waveform. Converting mod -> MIDI
or vice versa is nontrivial.

  • Load my own sample set (in some format?) and play midi files
    instead.

Honestly, MIDI is a headache, and not a particularly good sounding headache
in most cases. Most of us don’t have sound hardware that can do a reasonable
job of reproducing it. :slight_smile:

My snooping around the source leads me to think the notification
stuff might not be too bad, but would it work? Modifying mikmod seems
pretty scary – I don’t have the domain knowledge to poke around in
there comfortably.

I’m not a MikMod expert, though I’ve implemented a mod/s3m/mtm player, and
I’d be happy to answer any particular questions you have about these formats.

-JohnOn Wed, Apr 17, 2002 at 12:37:25AM -0400, Kent Quirk wrote:


John R. Hall - KG4RUO - Stranded in the Sol System
Student, Georgia Tech; Author, Programming Linux Games

Answering my own question, a bit.

I realized after I sent that message that I had been reading March
archives but not April, and I just found this, from Sam:

http://www.libsdl.org/pipermail/sdl/2002-April/044357.html

Which says:

  • Added an API for seeking in music files (implemented for MOD and
    Ogg music)
    Mix_FadeInMusicPos(), Mix_SetMusicPosition()

Which I think is exactly what I’m looking for. But the link in that
message points to SDL_mixer 1.2.1, which is what I have, and which
doesn’t contain those functions.

The CVS page says don’t redistribute. Since I do plan to
redistribute, I can’t really use stuff that’s in CVS but not in the
mainstream release. Anybody know when this stuff will hit the streets
for real?

Kent-- 

Kent Quirk, @Kent_Quirk on 4/17/2002

On Wed, 17 Apr 2002 00:37:25 -0400, Kent Quirk scribbled:

So I’d like to do one of the following things, and wondering if
anyone else knows which would be easiest, or if any of them have
already been done:

  • Add additional notification features to SDL_mixer so that I could
    move around within a single mod with speed and accuracy.
  • Add the ability to load a mod without samples (is that a midi
    file?) that would reuse samples from a different mod.
  • Load my own sample set (in some format?) and play midi files
    instead.

    Anybody have any ideas or suggestions? Alternate solutions?

Which I think is exactly what I’m looking for. But the link in that
message points to SDL_mixer 1.2.1, which is what I have, and which
doesn’t contain those functions.

The CVS page says don’t redistribute. Since I do plan to
redistribute, I can’t really use stuff that’s in CVS but not in the
mainstream release. Anybody know when this stuff will hit the streets
for real?

It has.

http://www.libsdl.org/projects/SDL_mixer/index.html

We’re up to SDL_mixer 1.2.3, which has those functions. At least, it
should.

Technically, nothing prevents you from redistributing the CVS code,
according to the LGPL license, except it’s a courtesy to the developers so
they aren’t bombarded with bug reports. :slight_smile:

The official 1.2.3 tarball is what you want, though.

–ryan.

Thanks very much!

I appreciate it and understand. But …

If you go to:

http://www.libsdl.org/projects/SDL_mixer/index.html

You get 1.2.3. If you leave off the index.html:

http://www.libsdl.org/projects/SDL_mixer/

You get 1.2.1. Is this SUPPOSED to be this way? If so, why?–
Kent Quirk, CTO, CogniToy
@Kent_Quirk
http://www.cognitoy.com

On Wed, 17 Apr 2002 01:33:18 -0400 (EDT), Ryan C. Gordon scribbled:

Which I think is exactly what I’m looking for. But the link in that
message points to SDL_mixer 1.2.1, which is what I have, and which
doesn’t contain those functions.

The CVS page says don’t redistribute. Since I do plan to
redistribute, I can’t really use stuff that’s in CVS but not in the
mainstream release. Anybody know when this stuff will hit the
streets for real?

It has.

http://www.libsdl.org/projects/SDL_mixer/index.html

We’re up to SDL_mixer 1.2.3, which has those functions. At least, it
should.

Technically, nothing prevents you from redistributing the CVS code,
according to the LGPL license, except it’s a courtesy to the
developers so they aren’t bombarded with bug reports. :slight_smile:

The official 1.2.3 tarball is what you want, though.

–ryan.

_______________________________________________ SDL mailing list
SDL at libsdl.org http://www.libsdl.org/mailman/listinfo/sdl

Frozen bubble distributes a patched version of SDL_mixer that has position
set support, http://www.frozen-bubble.org

also, the modplug library is a higher quality mod playing library, i’d
highly recommend it…

-eviltypeguyOn Wed, Apr 17, 2002 at 01:20:54AM -0400, John R. Hall wrote:

On Wed, Apr 17, 2002 at 12:37:25AM -0400, Kent Quirk wrote:

Hiya.
I’m making a new game that’ll use SDL_mixer. I really want to do
generated music. The idea is to do something like this:
where the choice of loop items is based on the current state/mood.
To keep download size to a minimum, I would like to do this with .mod
files (or the equivalent).
BUT…
I can’t do it all in one mod file because (as far as I can tell)
SDL_mixer doesn’t support the ability to move to a specific point in
a music track, nor does it seem to support the ability to get
notification at any point other than the end of the track.

There are at least two options:

a) Code directly with the MikMod library, which SDL_mixer uses.
Maybe even add some hooks to SDL_mixer to support jumps.
This should not be too hard; I know MikMod can handle this.
b) If you really need a lot of control, you could implement your own
MOD player. It’s not all that difficult as long as you have the right
documentation; I’d be happy to send you my mod/s3m code and the docs
I used to write it.

[…interactive music…]

So I’d like to do one of the following things, and wondering if
anyone else knows which would be easiest, or if any of them have
already been done:

  • Add additional notification features to SDL_mixer so that I could
    move around within a single mod with speed and accuracy.

That would probably be the easiest way. Basically just add an optional
callback that the “song” code calls if present, instead of just picking
the next pattern. I haven’t studied the actual code of SDL_mixer, but
this would be a pretty trivial thing to do in any module player I did
read the source of.

  • Add the ability to load a mod without samples (is that a midi
    file?)

Nope, a MIDI file is basically just one or more tracks, that consist of
normal MIDI events (same format as on the cable, even!), meta events and
"delay values". Trackers generally use multitrack patterns that are fixed
size arrays with a “fixed” number of rows/notes.

that would reuse samples from a different mod.

Anyway, that would be possible, of course, but I think it would be more
work than 1). It would require hacking SDL_mixer to support modules using
samples from other modules (API for that…?), and it would also make it
more complicated to compose the modules. (A tracker with a “save module
without samples”, or a tool that strips the samples from a module, would
help a great deal.)

  • Load my own sample set (in some format?)

IIRC, SDL_mixer uses Timidity, and so should support GUS banks and
possibly SoundFonts… (Just read the docs! :slight_smile:

and play midi files
instead.

Yeah, that could work, but you still have to hack the MIDI sequencer to
get it to do what you want. Because MIDI files have nothing in the data
structure that helps you in any way, this would probably be slightly more
complicated to do than doing the corresponding hack in a module player.

That said, I’m actually working on that kind of features in the new audio
engine of Kobo Deluxe. Eventually, I’ll use the EEL scripting language
(which is currently used only for rendering waveforms and setting up
patch/instrument parameters) together with a “native” sequencer to do
this kind of stuff (the MIDI code will be converted into a loader).

For now, I’m going to use text meta events (“markers”) that can be placed
in MIDI files by any serious sequencer. These markers show up in the
tracks just like any other events, so one just has to save their
positions somewhere (depending on their text; “LOOP_START”, "LOOP_END"
and the like), and then force the player to the stored positions when
required.

My snooping around the source leads me to think the notification
stuff might not be too bad, but would it work?

Not sure. Is it based on callbacks that run directly from the player? If
so, there’s at least a chance it could work. (Timing would suck
otherwise.)

Modifying mikmod seems
pretty scary – I don’t have the domain knowledge to poke around in
there comfortably.

What’s so scary about it? (I guess I should go and have a look at what
seems to scare the h*ll out of so many hackers… :wink:

Anybody have any ideas or suggestions? Alternate solutions?

Unfortunately, there’s quite some hacking left to do on my engine before
it’s seriously usable, so that’s not of much help… (Besides, you
probably need two computers - one Linux box with the engine, and one
Windoze box with a usable sequencer app - to compose any serious music
for it. Maybe if someone bothers to make a VSTi or DXi version
eventually…)

I’d say, go for the “single module + song callback hack” solution.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Wednesday 17 April 2002 06:37, Kent Quirk wrote:

Thanks very much!

I appreciate it and understand. But …

If you go to:

http://www.libsdl.org/projects/SDL_mixer/index.html

You get 1.2.3. If you leave off the index.html:

http://www.libsdl.org/projects/SDL_mixer/

You get 1.2.1. Is this SUPPOSED to be this way? If so, why?

You’ve been bitten by the web page cacheing bug. :slight_smile:
SDL_mixer really is up to version 1.2.3, and that version is newer than
the code in frozen bubble, so don’t use that. :slight_smile:

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

[…]

  • Load my own sample set (in some format?) and play midi files
    instead.

Honestly, MIDI is a headache, and not a particularly good sounding
headache in most cases. Most of us don’t have sound hardware that can
do a reasonable job of reproducing it. :slight_smile:

Honestly, not even my JV-1080 is capable of reproducing “MIDIs” very well

  • but then, I’m thinking about GM files, of course.

Use a custom soft synth and/or custom SoundFonts, at least. (I don’t care
much for SoundFonts, though. Boring. Big. Inflexible.)

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Wednesday 17 April 2002 07:20, John R. Hall wrote:

Yes, it supports soundfonts, here’s the relevant timidity.cfg snippet:

We have soundfonts, soundfonts are good.

dir /usr/share/timidity/soundfonts

#soundfont 4gmgsmt.sf2
soundfont 8mbgmsfx.sf2
soundfont chaos12m.sf2

The following evil-sounding CRAP is found in the timidity-patches

Debian package, which contains the public domain Roland GUS patches.

To say they sound like shit is a gross understatement. We won’t even

bother using them.

[…]

Just put that at the top of the timidity.cfg file and make sure you have
the soundfonts needed. I used to be able to easily host Chaos Bank for
anyone who needed it, but I’m on a modem now and will have to see if
someone else has it on a faster link. I’ll let you track down the SBLive
soundfont yourself. It’s downloadable from at least one soundfont website
(but shouldn’t be…)

This stuff can also be used with ALSA and the sfxload package apparently,
but I have yet to figure out just how exactly I’m supposed to do that.On Wed, Apr 17, 2002 at 04:11:45PM +0200, David Olofson wrote:

  • Load my own sample set (in some format?)

IIRC, SDL_mixer uses Timidity, and so should support GUS banks and
possibly SoundFonts… (Just read the docs! :slight_smile:


Joseph Carter Available in cherry and grape

doogie: you sound highly unstable :slight_smile:
jgoerzen - he is.

  • doogie bops Knghtbrd
    see? Resorting to violence =D

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 273 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020417/34fc0e6c/attachment.pgp

[…]

I’ll let you track down
the SBLive soundfont yourself. It’s downloadable from at least one
soundfont website (but shouldn’t be…)

I’d strongly recommend creating your own SoundFonts for any serious
music, though. Some of the bigger “GM” SFs you can find are nice, but
we’re still talking about the very basic set of “bread’n’butter” sounds
specified in the GM standard, possibly with some GS variants added…

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Wednesday 17 April 2002 22:47, Joseph Carter wrote: