Make an ambient sound get quieter?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Make an ambient sound get quieter?

Post by Enjay »

Maybe scripting, maybe mapping, maybe something else entirely.

What is the best way to have an ambient sound get quieter - i.e.fade out?

I want this for a closing map (like a TITLEMAP at the end of the game). The map itself is just a simple box. An ACS script shows a series of images that fade from one to the other. The player start spot is surrounded on 4 sides by looping ambient sound objects (ednum 14065 things with ambient sounds defined in SNDINFO). I have placed them like this because it means that the different sounds come from different angles. The sounds themselves are quite long.

As the graphics change, I want the sounds to get quieter and quieter and eventually fade out entirely. Is there a way to fade them programmatically (using ACS) or would I be best just to make duplicates of the sounds (the sounds are also used in a proper map) and fade the sound files out?
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Make an ambient sound get quieter?

Post by Blue Shadow »

The answer is to use [wiki]SoundVolume[/wiki] in a loop.

Code: Select all

for (int vol = 0.95; vol > 0; vol -= 0.05)
{
    SoundVolume(<tid>, CHAN_BODY, vol); // Ambient sounds actors play their sounds on the 'body' channel.
    Delay(35);
}
User avatar
Enjay
 
 
Posts: 26534
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Make an ambient sound get quieter?

Post by Enjay »

Aha! That certainly looks like it should work. "SoundVolume" eh? I didn't even realise that was a thing.

I'm away for a few days as of tomorrow but I'll try it when I get back.

Thank you kindly.
Post Reply

Return to “Scripting”