[No] Change music at end of loop point

Moderator: GZDoom Developers

Change music at end of loop point

Postby Samuel Seblingchark » Wed Jul 31, 2019 6:12 am

From my understanding, ZDoom will utilize loop points in background music to seamlessly loop music without repeating unwanted parts of the intro. Would it be possible to have a function that changes music after the end of the current loop point is reached?

Having that feature would drastically improve the ability to implement a dynamic soundtrack akin to Doom 2016 or simply combat/non-combat states.
Samuel Seblingchark
 

Re: Change music at end of loop point

Postby Tolbert Lightson » Sat Oct 17, 2020 4:06 pm

Have you managed to find the solution? I'm currently working on the randomized music mod and having this feature is essential.
Tolbert Lightson
 

Re: Change music at end of loop point

Postby Exl » Sun Oct 18, 2020 2:45 am

I've actually thought a lot about a feature like this, but have not yet made an attempt at adding it.

It would have to be possible to specify multiple loop start and end points per music track, because there might be a brief delay when starting a completely new music track. For OGG and FLAC that might be accomplished using sets of tags with specific names. You could treat each set of loop points as a track, and then queue a track change to occur after the current one reaches it's loop end point. A QueueMusic ACS command using the same parameters as SetMusic might be used for that, where the order parameter specifies the track to queue up next. Or perhaps a QueueTrack command that would only queue a new track within the current music track.
User avatar
Exl
 
Joined: 01 Jul 2009

Re: Change music at end of loop point

Postby Chicken McNuggets » Sun Oct 18, 2020 5:22 am

Damn, great idea! Was searching for the solution for weeks. Though, it's rather strange that ZDoom doesn't send a message of some kind by itself, as it seems that it loops untagged and unmapped tracks automatically.
User avatar
Chicken McNuggets
 
Joined: 25 Jan 2020

Re: Change music at end of loop point

Postby Chris » Sun Oct 18, 2020 8:56 am

By the time a track ends or hits the loop point, it's either already stopped or has already buffered some looped samples. Any kind of notification for a loop or end event would have to be sent ahead of time, so that the decoder/reader can do something at the appropriate time ahead of actual playback (which could have dozens or hundreds of milliseconds of audio still waiting to play). Though even then you'll have limitations if you want smooth transitions. For Ogg and FLAC and the like, the format of a new track will have to be the same as the old one; for instance, you can't queue up mono 44.1khz samples after stereo 48khz samples without a break in playback since the sample timing and channel positioning isn't the same. Switching to/from MIDI will also be a problem if using an external MIDI synth.

And that's assuming tracks are correctly authored to seamlessly switch at specific points. It would need careful management by the sound engineer, with limits on how things are put together. It's possible various formats are amenable to this (e.g. Ogg Vorbis files containing multiple audio streams), which can help ensure coherency between tracks/streams, although I'm not familiar with utilizing them.
User avatar
Chris
 
Joined: 17 Jul 2003

Re: Change music at end of loop point

Postby Graf Zahl » Sun Oct 18, 2020 9:39 am

I noticed that OpenAL has sufficient lag here when trying to implement streaming audio for some of the video formats in Raze. I had to fudge quite a bit to make them match up.
From that experience I have to conclude that such a notification feature is not going to work without some major changes to the music system.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Change music at end of loop point

Postby Chris » Sun Oct 18, 2020 12:46 pm

Graf Zahl wrote:I noticed that OpenAL has sufficient lag here when trying to implement streaming audio for some of the video formats in Raze. I had to fudge quite a bit to make them match up.

Worse, different systems will have a different amount of lag. OpenAL Soft has extensions to measure the active latency of a sound source (or more generally, the device), though proper A/V sync for video playback can get somewhat involved.

For a form of this feature, however, OpenAL and streaming lag doesn't really factor into it. It's in the decoder's domain; when the decoder would read sample 'X' from the file (the end loop point or some other predefined point), jump to time point 'Y' (or bitstream 'Z') to read samples instead. From OpenAL's perspective, it's just playing a continuous stream of samples, it doesn't really care about what the decoder or zmusic is doing to get them. The trick, as it were, is largely in defining how scripts can control the flow of a music stream. What would be needed is a way for songs to define break points and seek points (as defined by the music creator; where it can stop reading the current samples and start reading other samples, without causing an obvious click or pop when played), and a way for scripts to set a seek point the decoder should start reading from the next time it reaches a break point.
User avatar
Chris
 
Joined: 17 Jul 2003

Re: Change music at end of loop point

Postby Chicken McNuggets » Mon Oct 19, 2020 6:59 am

Chris wrote:By the time a track ends or hits the loop point, it's either already stopped or has already buffered some looped samples. Any kind of notification for a loop or end event would have to be sent ahead of time, so that the decoder/reader can do something at the appropriate time ahead of actual playback (which could have dozens or hundreds of milliseconds of audio still waiting to play). Though even then you'll have limitations if you want smooth transitions. For Ogg and FLAC and the like, the format of a new track will have to be the same as the old one; for instance, you can't queue up mono 44.1khz samples after stereo 48khz samples without a break in playback since the sample timing and channel positioning isn't the same. Switching to/from MIDI will also be a problem if using an external MIDI synth.

And that's assuming tracks are correctly authored to seamlessly switch at specific points. It would need careful management by the sound engineer, with limits on how things are put together. It's possible various formats are amenable to this (e.g. Ogg Vorbis files containing multiple audio streams), which can help ensure coherency between tracks/streams, although I'm not familiar with utilizing them.


I've almost offended the ZDoom and got a detailed explanation of where and why I was wrong. Man, I love this community.
User avatar
Chicken McNuggets
 
Joined: 25 Jan 2020

Re: Change music at end of loop point

Postby Logan MTM » Wed Oct 21, 2020 12:30 pm

Samuel Seblingchark wrote:Having that feature would drastically improve the ability to implement a dynamic soundtrack akin to Doom 2016 or simply combat/non-combat states.

I did suggested ChangeMusicVolume in the past and I just got. "No". Hopefully, this function exist now.
Doom 2016 use a short piece of music to play when combat is done. Normally it is some guitar riff to represent the transitions between combat and no combat. You can do the same method.
User avatar
Logan MTM
I can see you...
 
Joined: 17 Jan 2006
Location: Rio de Janeiro - Brazil


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests