View Issue Details

IDProjectCategoryView StatusLast Update
0003150FSSCPSEXPspublic2015-04-11 00:18
ReporterAxem Assigned Toniffiwan  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.7.2 RC5 
Summary0003150: Adjusting music volume doesn't work with sexps
DescriptionIn the sexp_adjust_audio_volume() function (line 10487ish) there's a lookup function to see what selected option corresponds with its integer index. Music is 0, Effects is 1, Voice is 2. The issue occurs after the look up when we get...

if (option > 0)

Which won't include music (0). *Sadfaec*

Can we get an extra equals sign up in there?
TagsNo tags attached.

Activities

MageKing17

2015-03-18 03:42

developer   ~0016566

Seems straightforward enough.

niffiwan

2015-03-18 04:09

developer   ~0016567

Seems fine to me, I just haven't tested running the sexp

MageKing17

2015-03-18 06:12

developer   ~0016569

Actually, I'm unassigning this from me because it's really Axem's fix; I just turned it into a .patch file.

niffiwan

2015-03-18 09:13

developer   ~0016570

Last edited: 2015-03-18 10:20

I've tested the change and I think there's another issue here. I set the music volume to 0% at 5 secs, then back to 100% at 20 secs with "$Event Music: 5: Deuteronomy". The music doesn't change volume at 5 secs, and it fades away completely just before 20 secs and doesn't return (ever!) unless I modify the volume in the F2 Options screen, or press escape, or take some other action.

Anyway, I'm poking around further to see if I can figure out what's going on.

Update: music from play-sound-from-file also doesn't change volume. I suspect that there's nothing (re)setting the music volume except when a track starts, e.g. when event music switches, or a loop restarts.

Update2: I think I've found the issue and have added code to trigger a volume change for all music when the music volume is changed. See attached patch mantis3150-svn.patch. I've tested this with event music and play-sound-from-file. Could you give it a test to see if it works as expected in your test case(s) as well?

niffiwan

2015-03-18 10:18

developer  

mantis3150-svn.patch (1,234 bytes)   
Index: code/parse/sexp.cpp
===================================================================
--- code/parse/sexp.cpp	(revision 11284)
+++ code/parse/sexp.cpp	(working copy)
@@ -10490,7 +10490,7 @@
 
 	if (n > 0) {
 		int option = audio_volume_option_lookup(CTEXT(n));
-		if (option > 0) {
+		if (option >= 0) {
 			n = CDR(n);
 
 			float target_volume = 1.0f;
Index: code/sound/sound.cpp
===================================================================
--- code/sound/sound.cpp	(revision 11284)
+++ code/sound/sound.cpp	(working copy)
@@ -12,6 +12,7 @@
 #include "render/3d.h"
 #include "sound/sound.h"
 #include "sound/audiostr.h"
+#include "gamesnd/eventmusic.h"
 #include "cmdline/cmdline.h"
 #include "osapi/osapi.h"
 #include "globalincs/vmallocator.h"
@@ -1518,6 +1519,12 @@
 	//apply change
 	*volume_now = data->start_volume + (data->delta * done);
 	CLAMP(*volume_now, 0.0f, 1.0f);
+
+	// if setting music volume, trigger volume change in playing tracks
+	// done here in order to avoid setting music volume in every frame regardless if it changed or not
+	if (&aav_music_volume == volume_now) {
+		audiostream_set_volume_all(Master_event_music_volume * aav_music_volume, ASF_EVENTMUSIC);
+	}
 }
 
 void snd_aav_init()
mantis3150-svn.patch (1,234 bytes)   

niffiwan

2015-03-28 04:16

developer   ~0016583

Here's a binary to test with: http://www.mediafire.com/download/icrdaaa73rrpi93/fs2_open_3_7_1_SSE2_mantis3150.7z

Axem

2015-04-08 01:39

reporter   ~0016612

The build didn't seem to have the patch applied since it didn't fix the problem.

But I took the patch and applied it to my own stuff here and the resulting build fixed all the issues.

Hooray!

niffiwan

2015-04-11 00:17

developer   ~0016638

:headdesk:
I have really got to test those Windows builds before publishing them... regardless, thanks for testing!

niffiwan

2015-04-11 00:18

developer   ~0016639

Fix committed to trunk@11299.

Related Changesets

fs2open: trunk r11299

2015-04-10 20:40

niffiwan


Ported: N/A

Details Diff
Fix mantis 3150

Use and set music volume changes requested by sexp_adjust_audio_volume()
Affected Issues
0003150
mod - /trunk/fs2_open/code/parse/sexp.cpp Diff File
mod - /trunk/fs2_open/code/sound/sound.cpp Diff File

Issue History

Date Modified Username Field Change
2015-03-18 02:42 Axem New Issue
2015-03-18 03:42 MageKing17 Note Added: 0016566
2015-03-18 03:42 MageKing17 Assigned To => MageKing17
2015-03-18 03:42 MageKing17 Status new => code review
2015-03-18 03:45 MageKing17 File Added: sexp.cpp.patch
2015-03-18 04:09 niffiwan Note Added: 0016567
2015-03-18 06:12 MageKing17 Note Added: 0016569
2015-03-18 06:12 MageKing17 Assigned To MageKing17 =>
2015-03-18 09:13 niffiwan Note Added: 0016570
2015-03-18 09:59 niffiwan Note Edited: 0016570
2015-03-18 10:18 niffiwan File Added: mantis3150-svn.patch
2015-03-18 10:20 niffiwan Note Edited: 0016570
2015-03-18 22:02 MageKing17 File Deleted: sexp.cpp.patch
2015-03-18 22:02 MageKing17 Assigned To => niffiwan
2015-03-18 22:02 MageKing17 Status code review => assigned
2015-03-18 22:03 MageKing17 Status assigned => code review
2015-03-28 04:16 niffiwan Note Added: 0016583
2015-04-08 01:39 Axem Note Added: 0016612
2015-04-11 00:17 niffiwan Note Added: 0016638
2015-04-11 00:18 niffiwan Changeset attached => fs2open trunk r11299
2015-04-11 00:18 niffiwan Note Added: 0016639
2015-04-11 00:18 niffiwan Status code review => resolved
2015-04-11 00:18 niffiwan Resolution open => fixed