Distance Volume ramp is ignored in audio script

Ask questions, discuss ideas, get answers
Post Reply
User avatar
metan
Posts: 4
Joined: Sun Oct 28, 2018 7:53 pm

Distance Volume ramp is ignored in audio script

Post by metan »

Hi!
I've been modding BF sound scripts for a long time and it seems I've finally encountered a nasty problem with volume-distance ramps I can't solve on my own and have to ask for help :oops:
I'm familiar with Senshi/Kerfuffle SSC scripting deep-dives, but their posts don't go deep enough into distance ramps. Initially, I though I messed up my game/eax settings or RFAs, but after experimenting with vanilla game for two days I think I've pinpointed the particular issue.

For the context, I usually set minDistance to the sound termination distance specified in one of the volume ramps (-1), because I don't want rolloff interfering with my volume fade fine-tuning. Even though this usually works, with certain ramp combinations the game seems to ignore my fading ramp. It's best explained with the following code sample, which modifies the last barmlp.wav patch in vanilla Objects/HandWeapons/Bar1918/Sounds/High.ssc:

Code: Select all

load @ROOT/Sound/@RTD/barmlp.wav
minDistance 100 <--- my only change in "header" section, other commands are just for context
loop
stop FinishSample
dopplerOff
priority 8
randomStartPitch 0.02 / 0.01

*** changes begin here ***
beginEffect
  controlDestination Volume
  controlSource Distance
  envelope Ramp
  param 10
  param 10
  param 0
  param 1 <--- changing this to 0.1 lowers the initial volume; distance fade works OK
endEffect

beginEffect
  controlDestination Volume
  controlSource Distance
  envelope Ramp
  param 10
  param 100
  param 1 <---  seems to act as a multiplier for the volume value at distance specified by 1st parameter, 
		i.e. setting 0.5 to both this param and the 4th param in previous ramp results in 
		initial volume of 0.5 * 0.5 = 0.25 at 10 meters. 
		Though, bear in mind that Ramp fading is probably not linear, so 
		"multiplying" initial volume 1.0 by 0.1 will result in much more aggressive fading curve 
		than 0.1 "multiplied" by 1
  param -1
endEffect
If you try setting a fixed camera view on a flat map and go away while shooting the gun, you will hear the gunshot becomes audible at 10 meters and then gradually decreases to zero at 100 meters (means everything is OK).
However, if you replace the second ramp with the following two ramps, the behaviour will be incorrect:

Code: Select all

beginEffect
  controlDestination Volume
  controlSource Distance
  envelope Ramp
  param 10
  param 100
  param 1
  param 0.1 <--- this value (and distance fade as a consequence) 
		is completely ignored by the game, as if 
		the next volume ramp overrides/overwrites this one 
		with whatever initial volume is specified there
endEffect

beginEffect
  controlDestination Volume
  controlSource Distance
  envelope Ramp
  param 100
  param 100
  param 1 <--- virtually any value here seems to override distance fade 
		from the previous ramp, so with value 1 the volume stays at 1 
		across the whole 10-100 range until termination
  param -1
endEffect
In short, I can't find a way to fade the volume to a specific non-zero value and immediately terminate it, as the game simply ignores/overwrites my fade ramp. Which is kinda strange since at the same time BF accepts gradual fade-in followed by a fade-out:

Code: Select all

beginEffect
  controlDestination Volume
  controlSource Distance
  envelope Ramp
  param 1
  param 50
  param 0
  param 1 <--- setting to other values seems to work as expected
endEffect

beginEffect
  controlDestination Volume
  controlSource Distance
  envelope Ramp
  param 50
  param 100
  param 1
  param -1
endEffect
So, are there any ssc experts still active :?:
If someone wants to reproduce it, I can provide a tweak for soldier fixed/external camera view and my sandbox map I used for testing this
Diamondback
Posts: 617
Joined: Mon Oct 01, 2012 3:13 pm
Location: Canada
Contact:

Re: Distance Volume ramp is ignored in audio script

Post by Diamondback »

Hi, I would advise asking your question in the Discord, here: https://discord.gg/AHeygmdm.
See my Strasbourg map project here.
User avatar
metan
Posts: 4
Joined: Sun Oct 28, 2018 7:53 pm

Re: Distance Volume ramp is ignored in audio script

Post by metan »

Diamondback wrote: Tue Apr 29, 2025 12:33 am Hi, I would advise asking your question in the Discord, here: https://discord.gg/AHeygmdm.
Thanks, I'll try!
Post Reply