Some questions about Scumm's iMUSE

General chat related to ScummVM, adventure gaming, and so on.

Moderator: ScummVM Team

Post Reply
Tarvis
Posts: 2
Joined: Tue Nov 18, 2014 9:08 am

Some questions about Scumm's iMUSE

Post by Tarvis »

Hello. I am working with others on a potential open-source Star Wars: X-Wing clone project. Right now I'm working on implementing the dynamic music. I already know about the SysEx jump commands and markers. I have the formats and rules for transitions figured out, now I'm on the playback step.

I see that ScummVM already has implementations for iMUSE dynamic playback, but I'm a little unclear on a couple things:

For context: X-Wing's inflight music is split up into dozens of GMIDI files that are 3 or 4 bars long, and are played in a somewhat random sequence. However, they are laid out so that there is 1 beat of leadin, which essentially means that each music segment overlaps the current playing segment by 1 beat. (used for things like drumroll leadins, etc.)

My questions are:
Do SCUMM games ever overlap MIDI music like that? Or are they played in sequence one at a time? I'm unclear on this because looking at ScummVM's source it seems like the midi_parser object it uses explicitly stops MIDI playback when loading a new song, which would mean they don't overlap

If so, does that mean each layered segment has its own midi_parser? Essentially, is there one parser per MIDI engine or one parser per MIDI file to play back? If it was the latter, it would make a lot more sense.

Since ScummVM has so many conditions for several different formats and commands that X-Wing doesn't need, I was planning on just rewriting my own simpler version specifically for X-Wing and TIE Fighter. But it would help if I could understand yours a little bit better. I think I'm just a bit lost sifting through all the sound effect handling code to get to the stuff I want to know about.

Thanks in advance.
User avatar
sev
ScummVM Lead
Posts: 2316
Joined: Wed Sep 21, 2005 1:06 pm
Contact:

Re: Some questions about Scumm's iMUSE

Post by sev »

Tarvis wrote: Do SCUMM games ever overlap MIDI music like that? Or are they played in sequence one at a time?
Yes, this is exactly what iMUSE is about, e.g. mixing tracks. And we have full implementation of that. See engines/scumm/imuse
Tarvis wrote: If so, does that mean each layered segment has its own midi_parser? Essentially, is there one parser per MIDI engine or one parser per MIDI file to play back? If it was the latter, it would make a lot more sense.
Yes, those are called Parts, and each gets parsed and played independently, governed by special set of commands.
Tarvis wrote: Since ScummVM has so many conditions for several different formats and commands that X-Wing doesn't need, I was planning on just rewriting my own simpler version specifically for X-Wing and TIE Fighter. But it would help if I could understand yours a little bit better. I think I'm just a bit lost sifting through all the sound effect handling code to get to the stuff I want to know about.
Maybe you're mixing it with generic sound players sitting in engine/scumm/players. Our iMUSE code is pretty simple and has pluggable game-dependent pieces of code. See sysex_samnmax.cpp for example.


Eugene
Tarvis
Posts: 2
Joined: Tue Nov 18, 2014 9:08 am

Post by Tarvis »

Ah, okay, that makes sense. The musician in me made me think Parts referred to the music played by each separate instrument, and not whole segments with multiple instruments.

My last question is: I see that music files are started and referenced by an id number. What defines which sound index maps to which music resource file? Is this defined in the ScummVM code or in the original game assets?
Post Reply