Playing music at offset

Moderator: GZDoom Developers

Post Reply
User avatar
Xeotroid
Posts: 448
Joined: Sat Jun 23, 2012 7:44 am
Graphics Processor: nVidia with Vulkan support
Location: Czech Rep.

Playing music at offset

Post by Xeotroid »

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.
User avatar
edward850
Posts: 5890
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Playing music at offset

Post by edward850 »

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?
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Playing music at offset

Post by Gez »

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.
Not just NSF. Multi-track files also include MIDI type-2, XMI, GBS, HES, KSS, and AY at least.

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.
User avatar
edward850
Posts: 5890
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Playing music at offset

Post by edward850 »

Prehaps also giving unique loop tags to subsongs? That seems worthwhile. It would give LOOP_END a tangible purpose, at least.
User avatar
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

Post by Xeotroid »

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.
User avatar
edward850
Posts: 5890
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Playing music at offset

Post by edward850 »

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...
Seeing as music doesn't use actor channels and already has loop tag support, I have no idea what you are saying here.
User avatar
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

Post by Xeotroid »

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.
User avatar
edward850
Posts: 5890
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Playing music at offset

Post by edward850 »

Sounds aren't music. ;)
All level music, by implementation, loops. Tags or no tags.
User avatar
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

Post by Xeotroid »

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?
User avatar
edward850
Posts: 5890
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Playing music at offset

Post by edward850 »

Using those very loop tags you claim don't work. :P
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?
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”