Playing music at offset
Moderator: GZDoom Developers
- Xeotroid
- Posts: 448
- Joined: Sat Jun 23, 2012 7:44 am
- Graphics Processor: nVidia with Vulkan support
- Location: Czech Rep.
Playing music at offset
I was playing with W3 trigger editor recently and I found pretty interesting action - playing music at offset while fading in.
Now I know that fading was suggested like a million times (and it was never implemented, even though Graf said that it's easy to implement, if it isn't a crossfade between another music), but I think skipping a part of music can be pretty helpful, because the music can have some good part you want to use in some special event, but it's in the middle of the file, for instance.
And then you have only one option. To open the music file in an audio editor, cut out the music and add it to .wad/.pk3 as a new music. But that wastes space, it's not really a big deal today, but /idgames doesn't like much when the file is too big, and generally, I think it's better to have one music file than many shattered little others.
The perfect example is once again from Warcraft 3. There's a music that starts with a flute solo and then it begins to morph to a heroic/adventurous theme and then it changes to an epic chamber string that morphs back to a short flute solo. If you don't know the music, here it is on YT. Imagine you want to use differenet parts of it in events, cutscenes etc.
Now the only option is to shatter the music in Audacity and make many music files, which sounds unpractical for me.
What do you guys (and girls) think? Thanks in advance for responses.
Now I know that fading was suggested like a million times (and it was never implemented, even though Graf said that it's easy to implement, if it isn't a crossfade between another music), but I think skipping a part of music can be pretty helpful, because the music can have some good part you want to use in some special event, but it's in the middle of the file, for instance.
And then you have only one option. To open the music file in an audio editor, cut out the music and add it to .wad/.pk3 as a new music. But that wastes space, it's not really a big deal today, but /idgames doesn't like much when the file is too big, and generally, I think it's better to have one music file than many shattered little others.
The perfect example is once again from Warcraft 3. There's a music that starts with a flute solo and then it begins to morph to a heroic/adventurous theme and then it changes to an epic chamber string that morphs back to a short flute solo. If you don't know the music, here it is on YT. Imagine you want to use differenet parts of it in events, cutscenes etc.
Now the only option is to shatter the music in Audacity and make many music files, which sounds unpractical for me.
What do you guys (and girls) think? Thanks in advance for responses.
Re: Playing music at offset
Well technically this already partly exists. You can specify an order to start at with modules, or the track to start at with NSFs. Extending this same parameter to specify sample postions for streamed formats played in FMOD shouldn't be too complicated. The only question is what yo do with saving/HUBs. Music positions aren't serialized, so should the set sample postion be stored or should the music track always reset from the beginning?
Re: Playing music at offset
Not just NSF. Multi-track files also include MIDI type-2, XMI, GBS, HES, KSS, and AY at least.edward850 wrote:Well technically this already partly exists. You can specify an order to start at with modules, or the track to start at with NSFs.
I think that, just like [wiki]audio loop[/wiki], this could be done with tags. Define a subsong tag with a startpoint and an endpoint. Subsong 0 is the whole song normally, subsong 1 is the first defined subsong tag, etc. Then if you play song:3, it'll play the 3rd defined subsong.
Re: Playing music at offset
Prehaps also giving unique loop tags to subsongs? That seems worthwhile. It would give LOOP_END a tangible purpose, at least.
- Xeotroid
- Posts: 448
- Joined: Sat Jun 23, 2012 7:44 am
- Graphics Processor: nVidia with Vulkan support
- Location: Czech Rep.
Re: Playing music at offset
Yes, that's a good idea, too, but I think the system would have to change a bit, because sound loops have to be played in the loop channel (256), so you need to use PlaySound ACS function currently to be able to select the channel...
Also, if you could use the offset function, it would be faster than using loop tags, because instead of just looking up the start point (and maybe the end poind), you need to write those in a tag and save the file.
Also, if you could use the offset function, it would be faster than using loop tags, because instead of just looking up the start point (and maybe the end poind), you need to write those in a tag and save the file.
Re: Playing music at offset
Seeing as music doesn't use actor channels and already has loop tag support, I have no idea what you are saying here.Xeotroid wrote:Yes, that's a good idea, too, but I think the system would have to change a bit, because sound loops have to be played in the loop channel (256), so you need to use PlaySound ACS function currently to be able to select the channel...
- Xeotroid
- Posts: 448
- Joined: Sat Jun 23, 2012 7:44 am
- Graphics Processor: nVidia with Vulkan support
- Location: Czech Rep.
Re: Playing music at offset
Well, you can't use sound loops in SetMusic, so you have to use something that allows it, and only ACS function I know is PlaySound, because you can assign the music to the loop channel, because you have to, see here:
ZDoom Wiki wrote:Sounds that define a loop do not play looped by default. They must be started with CHAN_LOOP so that the higher level sound code knows they loop and can handle them accordingly.
Re: Playing music at offset
Sounds aren't music. 
All level music, by implementation, loops. Tags or no tags.

All level music, by implementation, loops. Tags or no tags.
- Xeotroid
- Posts: 448
- Joined: Sat Jun 23, 2012 7:44 am
- Graphics Processor: nVidia with Vulkan support
- Location: Czech Rep.
Re: Playing music at offset
OK, but how do you want to make the music play only the loop region, and not the whole thing? Adding the sound to the loop channel makes it use the loop tags, but you can't do this for music, so... how can you do it?
Re: Playing music at offset
Using those very loop tags you claim don't work. 
Music with loop tags already exists. That's why myself and Gez were talking about an extension on it. What else would we be talking about?

Music with loop tags already exists. That's why myself and Gez were talking about an extension on it. What else would we be talking about?