Author Topic: Introducing adjust-audio-volume  (Read 2686 times)

0 Members and 1 Guest are viewing this topic.

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Introducing adjust-audio-volume
Here's a little sexp I've been working on. To quote from sexps.html:
Code: [Select]
adjust-audio-volume
Adjusts the relative volume of one sound type. Takes 1 to 3 arguments....
1: Sound Type to adjust, either Music, Voice or Effects. Will act as a reset for the given category, if no other argument present
2: Percentage of the users' settings to adjust to (optional), 0 will be silence, 100 means the maximum volume as set by the user
3: Fade time (optional), time in milliseconds to adjust the volume

Test builds for both FRED and FSO, as well as a simple sample mission and a code patch, are included in this download.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Introducing adjust-audio-volume
Thank goodness.

Also thank Axem for agitating for this so his opening cutscene wouldn't break.

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: Introducing adjust-audio-volume
I'll have to test that voice option next time some political add is on. :P
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline Shivan Hunter

  • 210
  • FRED needs lambdas!
Re: Introducing adjust-audio-volume
FRAKKING YES

I've been needing this

:D

 

Offline Aardwolf

  • 211
  • Posts: 16,384
    • Minecraft
Re: Introducing adjust-audio-volume
So now we can have FPS-style ear-ringing?

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Introducing adjust-audio-volume
You can certainly simulate it.

Also, can you guys pleeeeeeeaaaaaaaaaaaseeeeeeeee test this so I can fix it up if necessary and put it into trunk?
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Introducing adjust-audio-volume
On my phone so I can't test this. I assume it doesn't actually touch the user's settings and switches back to defaults at the start of the next mission, right?
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Introducing adjust-audio-volume
The actual user settings are unaffected, and it will reset on mission end, and on mission start.

As I said in the help text "100" means "Play this as loud as the user set it". It doesn't go beyond that.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline BlackDove

  • Star Killer
  • 211
  • Section 3 of the GTVI
    • http://www.shatteredstar.org
Re: Introducing adjust-audio-volume
That fade time, it's applied to both the start and end of a track?

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Introducing adjust-audio-volume
Err.

No, this sexp changes the effective volume of the music, voice and effect channels. It acts as a multiplier of sorts for the volume settings in the Options menu. There is no way to apply it to a specific piece of music or effect.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline BlackDove

  • Star Killer
  • 211
  • Section 3 of the GTVI
    • http://www.shatteredstar.org
Re: Introducing adjust-audio-volume
Sorry, my bad.

 

Offline Echelon9

  • 210
Re: Introducing adjust-audio-volume
Possible problem with this piece of code is that the snd_adjust_audio_volume(int type, float percent, int time) function can currently attempt to write outside the aav_data[3] array via an off-by-one. The debug Assert() check is for an index into that array of less than 4, although as an array starting at zero the three elements have indices 0, 1 and 2.

The one call within the codebase to snd_adjust_audio_volume() from sexp_adjust_audio_volume() uses the audio_volume_option_lookup() function to pick the 'type'. This has a comment "\t1:\tSound Type to adjust, either Master, Music, Voice or Effects\r\n" i.e. 4 elements even though the SEXP doesn't appear to offer the ability to adjust the Master volume, which may be the cause of the confusion.

audio_volume_option_lookup() can also return -1, which is an error code not checked for (on non-Debug), and would have likewise lead to an out of bounds write to the aav_data array.

Proposed fix (Mantis 2314):
Code: [Select]
Index: code/sound/sound.cpp
===================================================================
--- code/sound/sound.cpp    (revision 6523)
+++ code/sound/sound.cpp    (working copy)
@@ -1396,7 +1396,7 @@
 
 void snd_adjust_audio_volume(int type, float percent, int time)
 {
-    Assert( type >= 0 && type < 4 );
+    Assert( type >= 0 && type < 3 );
    
     switch (type) {
     case AAV_MUSIC:
@@ -1420,6 +1420,8 @@
         else
             aav_data[type].delta = percent - aav_effect_volume;
         break;
+    default:
+        Int3();
     }
 
     aav_data[type].delta_time = time;
« Last Edit: September 26, 2010, 10:17:39 am by Echelon9 »

 

Offline The E

  • He's Ebeneezer Goode
  • Moderator
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Introducing adjust-audio-volume
Fixed in trunk revision 6524.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns