[ACS] SetMusicVolume
Moderator: GZDoom Developers
- NeuralStunner
-
- Posts: 12326
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
[ACS] SetMusicVolume
[Local]SetMusicVolume (fixed Volume[, fixed FadeTime[, int FadeType]])
Sets the relative volume of the background music. This would be a multiplier to the user's snd_musicvolume setting: 1.0 to the function is considered normal volume.
FadeTime: How many seconds to fade the music across. Use 0 (the default) to instantly change the volume.
FadeType: Linear or Logarithmic. (Not vital, choose the best option and use that.)
When used repeatedly in a script with steadily lower/higher values, this can be used to fade music out/in. (Blzut suggested building the fade feature directly into the function, particularly in Zandronum's case it would allow the server to send a single packet for fading the volume.)
The song can be gracefully faded to silence before a special event, or quieted in certain situations (E.G. character dialog).
LocalSetMusicVolume would affect only the activator.
Sets the relative volume of the background music. This would be a multiplier to the user's snd_musicvolume setting: 1.0 to the function is considered normal volume.
FadeTime: How many seconds to fade the music across. Use 0 (the default) to instantly change the volume.
FadeType: Linear or Logarithmic. (Not vital, choose the best option and use that.)
When used repeatedly in a script with steadily lower/higher values, this can be used to fade music out/in. (Blzut suggested building the fade feature directly into the function, particularly in Zandronum's case it would allow the server to send a single packet for fading the volume.)
The song can be gracefully faded to silence before a special event, or quieted in certain situations (E.G. character dialog).
LocalSetMusicVolume would affect only the activator.
Last edited by NeuralStunner on Thu Jun 06, 2013 4:31 pm, edited 1 time in total.
- Ral22
- Posts: 531
- Joined: Sun Sep 05, 2010 12:09 pm
- Preferred Pronouns: He/Him
- Location: The Fortress of Dr. Radiaki
- Contact:
Re: [ACS] SetMusicVolume
Personally, I would find this to be very helpful, and a neat feature.
I always thought the unused parameter in SetMusic would be for something like this.
I always thought the unused parameter in SetMusic would be for something like this.
Re: [ACS] SetMusicVolume
It was intended as a duration for cross-fading from the previous track, but that was never actually implemented.
Thinking about it, that would be fine, if 0 was changed to mean "use the previous volume level", since I'm pretty sure the default is 0 anyway, so if the default was full volume, it would keep compatibility with existing scripts. There's no real reason you'd want 0-volume music anyway since you can just SetMusic ("");, and if you want to keep the music running, it's be fine to set it to something really super low like (int)1 which would be close enough to inaudible that it shouldn't matter.
Thinking about it, that would be fine, if 0 was changed to mean "use the previous volume level", since I'm pretty sure the default is 0 anyway, so if the default was full volume, it would keep compatibility with existing scripts. There's no real reason you'd want 0-volume music anyway since you can just SetMusic ("");, and if you want to keep the music running, it's be fine to set it to something really super low like (int)1 which would be close enough to inaudible that it shouldn't matter.
Re: [ACS] SetMusicVolume
For what it's worth, I would prefer to see a separate function. Smaller, more specialized instructions tend to be more useful and generalized in the long run than trying to push too much into one function. Not to drop names, but [wiki]A_SpawnItemEx[/wiki].
Plus, 0 should mean 0 whenever possible. And in this case, I think it would be algorithmically detrimental for 0 to be a special case.
Also: I believe NeuralStunner meant multiplicative, not additive. And if not, he should have meant that.
Plus, 0 should mean 0 whenever possible. And in this case, I think it would be algorithmically detrimental for 0 to be a special case.
Also: I believe NeuralStunner meant multiplicative, not additive. And if not, he should have meant that.
- NeuralStunner
-
- Posts: 12326
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: [ACS] SetMusicVolume
I meant "in addition to", meaning it wouldn't affect the user setting itself. But yes, multiplicative.
- NeuralStunner
-
- Posts: 12326
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: [ACS] SetMusicVolume
Was discussing this with Blzut, and decided to make a couple additions.
-
- Posts: 36
- Joined: Thu Jan 19, 2012 11:43 am
Re: [ACS] SetMusicVolume
This would be pretty awesome. I don't know if it can be done for MIDI's, but hopefully it can be done for WAV/OGG/MP3/other standard music types.
Re: [ACS] SetMusicVolume
How about crossfading between two songs? That would be an amazing feature to have.
However, crossfading MIDIs aren't fundamentally possible... you can't crossfade between 2 MIDIs that don't share the same amount of tracks or program mapping. It's just illogical.
However, crossfading MIDIs aren't fundamentally possible... you can't crossfade between 2 MIDIs that don't share the same amount of tracks or program mapping. It's just illogical.
Re: [ACS] SetMusicVolume
You could crossfade between two MIDIs actually. The obvious way would be to have two instances of the MIDI synth.
Then there's whatever method LucasArts' iMUSE used.
Then there's whatever method LucasArts' iMUSE used.
- NeuralStunner
-
- Posts: 12326
- Joined: Tue Jul 21, 2009 12:04 pm
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia with Vulkan support
- Location: capital N, capital S, no space
- Contact:
Re: [ACS] SetMusicVolume
Well, if the engine has an internal volume for a music type, (it does for MIDI,) it would presumably work.Watermelon wrote:This would be pretty awesome. I don't know if it can be done for MIDI's, but hopefully it can be done for WAV/OGG/MP3/other standard music types.
IIRC the issue with crossfading (I.E. why we don't have it yet) is that ZDoom only supports one music stream. So that would need an overhaul.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: [ACS] SetMusicVolume
Called it: Right off of Painkiller, am I right? I so approve of this.Nash wrote:How about crossfading between two songs? That would be an amazing feature to have.