[ACS] SetMusicVolume

Moderator: GZDoom Developers

Post Reply
User avatar
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

Post by NeuralStunner »

[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.
Last edited by NeuralStunner on Thu Jun 06, 2013 4:31 pm, edited 1 time in total.
User avatar
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

Post by Ral22 »

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.
User avatar
Kate
... in rememberance ...
Posts: 2975
Joined: Tue Jul 15, 2003 8:06 pm

Re: [ACS] SetMusicVolume

Post by Kate »

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.
User avatar
DavidPH
Posts: 382
Joined: Fri Aug 28, 2009 1:46 pm

Re: [ACS] SetMusicVolume

Post by DavidPH »

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. :P
User avatar
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

Post by NeuralStunner »

I meant "in addition to", meaning it wouldn't affect the user setting itself. But yes, multiplicative. :P
User avatar
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

Post by NeuralStunner »

Was discussing this with Blzut, and decided to make a couple additions.
Watermelon
Posts: 36
Joined: Thu Jan 19, 2012 11:43 am

Re: [ACS] SetMusicVolume

Post by Watermelon »

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.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [ACS] SetMusicVolume

Post by Nash »

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

Re: [ACS] SetMusicVolume

Post by Gez »

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.
User avatar
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

Post by NeuralStunner »

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.
Well, if the engine has an internal volume for a music type, (it does for MIDI,) it would presumably work.

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.
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: [ACS] SetMusicVolume

Post by Major Cooke »

Nash wrote:How about crossfading between two songs? That would be an amazing feature to have.
Called it: Right off of Painkiller, am I right? I so approve of this. :D
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”