Author Topic: Let's talk about the sound code... again.  (Read 27774 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
Re: Let's talk about the sound code... again.
Here are builds with the change mentioned above: http://blueplanet.fsmods.net/E/stuff/soundtest.7z
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 Spoon

  • 212
  • ヾ(´︶`♡)ノ
Re: Let's talk about the sound code... again.
That seems to be a step backwards. There's more noticable clipping on that latest build compared to the one Iss Mneur's posted (though the clipping itself is less ear shredding) and at times its not playing sounds from turrets close (and in the viewing cone) to you at all.
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them

 
Re: Let's talk about the sound code... again.
http://www.youtube.com/watch?v=zqtOhEgE2oA

.....Hopefully, if not I'll encode the two together tomorrow anyway
"Neutrality means that you don't really care, cuz the struggle goes on even when you're not there: Blind and unaware."

"We still believe in all the things that we stood by before,
and after everything we've seen here maybe even more.
I know we're not the only ones, and we were not the first,
and unapologetically we'll stand behind each word."

 

Offline Iss Mneur

  • 210
  • TODO:
Re: Let's talk about the sound code... again.
Okay, another build to try.

This is a rollup of a few different changes so that that we can come up with some appropriate values and/or defaults.  The changes included are:
  • My fix from previously disabled by default.  Enable with cmdline flag -alwaysenforce.
  • Allows dynamic adjustment of the change that Taylor posted.  By default it is also off.  Control this feature with -listenergain <value>-1 disables.  Useful range is 0.0 (effectively turns off sound) to 1.0 (presumably the same as -1).  Taylor's patch sets this to 0.65.
  • Allows control of the percentage of new lightning flashes that get turned into bangs (aka thunder sound plays).  Controlled with -percent_flashtobang <value>.  Default is 100.  I find 25 is too boring, 75 is still too much sound.

Thoughts?  Please post the settings of the above three flags and whether you are using the OpenALSoft.dll so that we can use the numbers to come up with good defaults for retail to use.


Code: (More sound code fun.patch) [Select]
Index: code/cmdline/cmdline.cpp
===================================================================
--- code/cmdline/cmdline.cpp (revision 7567)
+++ code/cmdline/cmdline.cpp (working copy)
@@ -437,8 +437,16 @@
 cmdline_parm output_sexp_arg("-output_sexps", NULL); //WMC - outputs all SEXPs to sexps.html
 cmdline_parm output_scripting_arg("-output_scripting", NULL); //WMC
 
+float Cmdline_percentflashtobang = 100.0f;
+float Cmdline_listenergain = -1;
+int Cmdline_enforce_concurrent_sound_count = 0;
 
+cmdline_parm percent_flashtobang_arg("-percent_flashtobang", NULL);
+cmdline_parm listenergain_arg("-listenergain", NULL);
+cmdline_parm always_enforce_concurrent_sound("-alwaysenforce", NULL);
 
+
+
 #ifndef NDEBUG
 // NOTE: this assumes that os_init() has already been called but isn't a fatal error if it hasn't
 void cmdline_debug_print_cmdline()
@@ -1450,6 +1458,21 @@
  Cmdline_bloom_intensity = bloom_intensity_arg.get_int();
  }
 
+ if ( listenergain_arg.found() )
+ {
+ Cmdline_listenergain = listenergain_arg.get_float();
+ }
+
+ if ( percent_flashtobang_arg.found() )
+ {
+ Cmdline_percentflashtobang = percent_flashtobang_arg.get_float();
+ }
+
+ if ( always_enforce_concurrent_sound.found() )
+ {
+ Cmdline_enforce_concurrent_sound_count = 1;
+ }
+
  return true;
 }
 
Index: code/cmdline/cmdline.h
===================================================================
--- code/cmdline/cmdline.h (revision 7567)
+++ code/cmdline/cmdline.h (working copy)
@@ -145,7 +145,10 @@
 extern int Cmdline_no_grab;
 #endif
 
+// Temp, only for evaluating new defaults
+extern float Cmdline_listenergain;
+extern float Cmdline_percentflashtobang;
+extern int Cmdline_enforce_concurrent_sound_count;
 
-
 //extern char FreeSpace_Directory[]; // allievating a cfilesystem problem caused by fred -- Kazan
 #endif
Index: code/nebula/neblightning.cpp
===================================================================
--- code/nebula/neblightning.cpp (revision 7567)
+++ code/nebula/neblightning.cpp (working copy)
@@ -21,10 +21,8 @@
 #include "weapon/emp.h"
 #include "network/multi.h"
 #include "network/multimsgs.h"
+#include "cmdline/cmdline.h"
 
-
-extern int Cmdline_nohtl;
-
 // ------------------------------------------------------------------------------------------------------
 // NEBULA LIGHTNING DEFINES/VARS
 //
@@ -439,24 +437,27 @@
 
  // do some special stuff on the very first strike of the bolt
  if(b->strikes_left == bi->num_strikes){
- // play a sound
- float bang;
- if(Nebl_bang < 40.0f){
- bang = 1.0f;
- } else if(Nebl_bang > 400.0f){
- bang = 0.0f;
- } else {
- bang = 1.0f - (Nebl_bang / 400.0f);
- }
- if(frand_range(0.0f, 1.0f) < 0.5f){
- snd_play(&Snds[SND_LIGHTNING_2], 0.0f, bang, SND_PRIORITY_DOUBLE_INSTANCE);
- } else {
- snd_play(&Snds[SND_LIGHTNING_1], 0.0f, bang, SND_PRIORITY_DOUBLE_INSTANCE);
- }
+ // play a sound
+ if (frand_range(0.0f, 100.0f) < Cmdline_percentflashtobang)
+ {
+ float bang;
+ if(Nebl_bang < 40.0f){
+ bang = 1.0f;
+ } else if(Nebl_bang > 400.0f){
+ bang = 0.0f;
+ } else {
+ bang = 1.0f - (Nebl_bang / 400.0f);
+ }
+ if(frand_range(0.0f, 1.0f) < 0.5f){
+ snd_play(&Snds[SND_LIGHTNING_2], 0.0f, bang, SND_PRIORITY_DOUBLE_INSTANCE);
+ } else {
+ snd_play(&Snds[SND_LIGHTNING_1], 0.0f, bang, SND_PRIORITY_DOUBLE_INSTANCE);
+ }
 
- // apply em pulse
- if(bi->emp_intensity > 0.0f){
- emp_apply(&b->midpoint, 0.0f, vm_vec_dist(&b->start, &b->strike), bi->emp_intensity, bi->emp_time);
+ // apply em pulse
+ if(bi->emp_intensity > 0.0f){
+ emp_apply(&b->midpoint, 0.0f, vm_vec_dist(&b->start, &b->strike), bi->emp_intensity, bi->emp_time);
+ }
  }
  }
  }
Index: code/sound/ds.cpp
===================================================================
--- code/sound/ds.cpp (revision 7567)
+++ code/sound/ds.cpp (working copy)
@@ -18,8 +18,8 @@
 #include "sound/acm.h"
 #include "osapi/osapi.h"
 #include "sound/dscap.h"
+#include "cmdline/cmdline.h"
 
-
 typedef struct sound_buffer
 {
  ALuint buf_id; // OpenAL buffer id
@@ -1129,6 +1129,10 @@
  // this is needed for 2D pan
  OpenAL_ErrorPrint( alListener3f(AL_POSITION, 0.0, 0.0, 0.0) );
  OpenAL_ErrorPrint( alListenerfv(AL_ORIENTATION, list_orien) );
+ if (Cmdline_listenergain > 0)
+ {
+ OpenAL_ErrorPrint( alListenerf(AL_GAIN, Cmdline_listenergain) );
+ }
 
  // disable doppler (FIXME)
  OpenAL_ErrorPrint( alDopplerFactor(0.0f) );
@@ -1407,24 +1411,33 @@
  }
  }
 
+ // Make sure that we are not going to play more copies of this sound than we should be
+ if ( Cmdline_enforce_concurrent_sound_count && (instance_count >= limit) && (lowest_instance_vol_index >= 0) ) {
+ // If there is a lower volume duplicate, stop it.... otherwise, don't play the sound
+ if (lowest_instance_vol <= new_volume) {
+ ds_close_channel_fast(lowest_instance_vol_index);
+ first_free_channel = lowest_instance_vol_index;
+ }
+ }
+
  if (first_free_channel < 0) {
- // If we've exceeded the limit, then maybe stop the duplicate if it is lower volume
+ // Make sure that we are not going to play more copies of this sound than we should be
  if ( (instance_count >= limit) && (lowest_instance_vol_index >= 0) ) {
  // If there is a lower volume duplicate, stop it.... otherwise, don't play the sound
  if (lowest_instance_vol <= new_volume) {
  ds_close_channel_fast(lowest_instance_vol_index);
  first_free_channel = lowest_instance_vol_index;
  }
- } else {
- // there is no limit barrier to play the sound, so see if we've ran out of channels
- // stop the lowest volume instance to play our sound if priority demands it
- if ( (lowest_vol_index != -1) && (priority == DS_MUST_PLAY) ) {
- // Check if the lowest volume playing is less than the volume of the requested sound.
- // If so, then we are going to trash the lowest volume sound.
- if ( Channels[lowest_vol_index].vol <= new_volume ) {
- ds_close_channel_fast(lowest_vol_index);
- first_free_channel = lowest_vol_index;
- }
+ }
+ // still don't have a channel and
+ // there is no limit barrier to play the sound, so see if we've ran out of channels
+ // stop the lowest volume instance to play our sound if priority demands it
+ if ( (lowest_vol_index != -1) && (priority == DS_MUST_PLAY) ) {
+ // Check if the lowest volume playing is less than the volume of the requested sound.
+ // If so, then we are going to trash the lowest volume sound.
+ if ( Channels[lowest_vol_index].vol <= new_volume ) {
+ ds_close_channel_fast(lowest_vol_index);
+ first_free_channel = lowest_vol_index;
  }
  }
  }

"I love deadlines. I like the whooshing sound they make as they fly by." -Douglas Adams
wxLauncher 0.9.4 public beta (now with no config file editing for FRED) | wxLauncher 2.0 Request for Comments

 

Offline Spoon

  • 212
  • ヾ(´︶`♡)ノ
Re: Let's talk about the sound code... again.
-alwaysenforce enabled while not perfect does give the best result, fixing sound from turrets&warpins 85% of the time. -listenergain between 0.8 - 0.9 slightly reduces the amount of clipping when it does happen, without making it sound like I need to turn up the volume of my speakers because the general sound volume sounds so soft. Imo if -alwaysenforce would work at every distance properly there would be no need for -listenergain at all.
-percent_flashtobang at 60 seems to give a pretty good nebula result.
not using openalsoft
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them

 

Offline torc

  • 210
  • Diaspora SFX engineer
Re: Let's talk about the sound code... again.
excuse me guys,but do you hear the capship warping effect?
and the capship explosion? the sound should be the Atomic.wav but what i only  hear is the clusterboom sound.
i noticed that working on Diaspora... i think is not only our issue,but i think is a bug in the code.
Plus, the Capship engine not work...if you pass near a ship like the Colossus,you hear nothing IIRC.
thanks in advance for your help
indossare una divisa può avere un prezzo alto...ma a volte...è troppo alto!!! Bill Adama

 

Offline torc

  • 210
  • Diaspora SFX engineer
Re: Let's talk about the sound code... again.
excuse me guys,but do you hear the capship warping effect?
and the capship explosion? the sound should be the Atomic.wav but what i only  hear is the clusterboom sound.
i noticed that working on Diaspora... i think is not only our issue,but i think is a bug in the code.
Plus, the Capship engine not work...if you pass near a ship like the Colossus,you hear nothing IIRC.
thanks in advance for your help
BUMP
ehm...i quoted myself...
thanks again :)
indossare una divisa può avere un prezzo alto...ma a volte...è troppo alto!!! Bill Adama

 

Offline Spoon

  • 212
  • ヾ(´︶`♡)ノ
Re: Let's talk about the sound code... again.
Guys, Seriously.
Stop the irrelevant talk about speaker set ups and audiocards and do something with this:

Okay, another build to try.

This is a rollup of a few different changes so that that we can come up with some appropriate values and/or defaults.  The changes included are:
  • My fix from previously disabled by default.  Enable with cmdline flag -alwaysenforce.
  • Allows dynamic adjustment of the change that Taylor posted.  By default it is also off.  Control this feature with -listenergain <value>-1 disables.  Useful range is 0.0 (effectively turns off sound) to 1.0 (presumably the same as -1).  Taylor's patch sets this to 0.65.
  • Allows control of the percentage of new lightning flashes that get turned into bangs (aka thunder sound plays).  Controlled with -percent_flashtobang <value>.  Default is 100.  I find 25 is too boring, 75 is still too much sound.

Thoughts?  Please post the settings of the above three flags and whether you are using the OpenALSoft.dll so that we can use the numbers to come up with good defaults for retail to use.


Code: (More sound code fun.patch) [Select]
Index: code/cmdline/cmdline.cpp
===================================================================
--- code/cmdline/cmdline.cpp (revision 7567)
+++ code/cmdline/cmdline.cpp (working copy)
@@ -437,8 +437,16 @@
 cmdline_parm output_sexp_arg("-output_sexps", NULL); //WMC - outputs all SEXPs to sexps.html
 cmdline_parm output_scripting_arg("-output_scripting", NULL); //WMC
 
+float Cmdline_percentflashtobang = 100.0f;
+float Cmdline_listenergain = -1;
+int Cmdline_enforce_concurrent_sound_count = 0;
 
+cmdline_parm percent_flashtobang_arg("-percent_flashtobang", NULL);
+cmdline_parm listenergain_arg("-listenergain", NULL);
+cmdline_parm always_enforce_concurrent_sound("-alwaysenforce", NULL);
 
+
+
 #ifndef NDEBUG
 // NOTE: this assumes that os_init() has already been called but isn't a fatal error if it hasn't
 void cmdline_debug_print_cmdline()
@@ -1450,6 +1458,21 @@
  Cmdline_bloom_intensity = bloom_intensity_arg.get_int();
  }
 
+ if ( listenergain_arg.found() )
+ {
+ Cmdline_listenergain = listenergain_arg.get_float();
+ }
+
+ if ( percent_flashtobang_arg.found() )
+ {
+ Cmdline_percentflashtobang = percent_flashtobang_arg.get_float();
+ }
+
+ if ( always_enforce_concurrent_sound.found() )
+ {
+ Cmdline_enforce_concurrent_sound_count = 1;
+ }
+
  return true;
 }
 
Index: code/cmdline/cmdline.h
===================================================================
--- code/cmdline/cmdline.h (revision 7567)
+++ code/cmdline/cmdline.h (working copy)
@@ -145,7 +145,10 @@
 extern int Cmdline_no_grab;
 #endif
 
+// Temp, only for evaluating new defaults
+extern float Cmdline_listenergain;
+extern float Cmdline_percentflashtobang;
+extern int Cmdline_enforce_concurrent_sound_count;
 
-
 //extern char FreeSpace_Directory[]; // allievating a cfilesystem problem caused by fred -- Kazan
 #endif
Index: code/nebula/neblightning.cpp
===================================================================
--- code/nebula/neblightning.cpp (revision 7567)
+++ code/nebula/neblightning.cpp (working copy)
@@ -21,10 +21,8 @@
 #include "weapon/emp.h"
 #include "network/multi.h"
 #include "network/multimsgs.h"
+#include "cmdline/cmdline.h"
 
-
-extern int Cmdline_nohtl;
-
 // ------------------------------------------------------------------------------------------------------
 // NEBULA LIGHTNING DEFINES/VARS
 //
@@ -439,24 +437,27 @@
 
  // do some special stuff on the very first strike of the bolt
  if(b->strikes_left == bi->num_strikes){
- // play a sound
- float bang;
- if(Nebl_bang < 40.0f){
- bang = 1.0f;
- } else if(Nebl_bang > 400.0f){
- bang = 0.0f;
- } else {
- bang = 1.0f - (Nebl_bang / 400.0f);
- }
- if(frand_range(0.0f, 1.0f) < 0.5f){
- snd_play(&Snds[SND_LIGHTNING_2], 0.0f, bang, SND_PRIORITY_DOUBLE_INSTANCE);
- } else {
- snd_play(&Snds[SND_LIGHTNING_1], 0.0f, bang, SND_PRIORITY_DOUBLE_INSTANCE);
- }
+ // play a sound
+ if (frand_range(0.0f, 100.0f) < Cmdline_percentflashtobang)
+ {
+ float bang;
+ if(Nebl_bang < 40.0f){
+ bang = 1.0f;
+ } else if(Nebl_bang > 400.0f){
+ bang = 0.0f;
+ } else {
+ bang = 1.0f - (Nebl_bang / 400.0f);
+ }
+ if(frand_range(0.0f, 1.0f) < 0.5f){
+ snd_play(&Snds[SND_LIGHTNING_2], 0.0f, bang, SND_PRIORITY_DOUBLE_INSTANCE);
+ } else {
+ snd_play(&Snds[SND_LIGHTNING_1], 0.0f, bang, SND_PRIORITY_DOUBLE_INSTANCE);
+ }
 
- // apply em pulse
- if(bi->emp_intensity > 0.0f){
- emp_apply(&b->midpoint, 0.0f, vm_vec_dist(&b->start, &b->strike), bi->emp_intensity, bi->emp_time);
+ // apply em pulse
+ if(bi->emp_intensity > 0.0f){
+ emp_apply(&b->midpoint, 0.0f, vm_vec_dist(&b->start, &b->strike), bi->emp_intensity, bi->emp_time);
+ }
  }
  }
  }
Index: code/sound/ds.cpp
===================================================================
--- code/sound/ds.cpp (revision 7567)
+++ code/sound/ds.cpp (working copy)
@@ -18,8 +18,8 @@
 #include "sound/acm.h"
 #include "osapi/osapi.h"
 #include "sound/dscap.h"
+#include "cmdline/cmdline.h"
 
-
 typedef struct sound_buffer
 {
  ALuint buf_id; // OpenAL buffer id
@@ -1129,6 +1129,10 @@
  // this is needed for 2D pan
  OpenAL_ErrorPrint( alListener3f(AL_POSITION, 0.0, 0.0, 0.0) );
  OpenAL_ErrorPrint( alListenerfv(AL_ORIENTATION, list_orien) );
+ if (Cmdline_listenergain > 0)
+ {
+ OpenAL_ErrorPrint( alListenerf(AL_GAIN, Cmdline_listenergain) );
+ }
 
  // disable doppler (FIXME)
  OpenAL_ErrorPrint( alDopplerFactor(0.0f) );
@@ -1407,24 +1411,33 @@
  }
  }
 
+ // Make sure that we are not going to play more copies of this sound than we should be
+ if ( Cmdline_enforce_concurrent_sound_count && (instance_count >= limit) && (lowest_instance_vol_index >= 0) ) {
+ // If there is a lower volume duplicate, stop it.... otherwise, don't play the sound
+ if (lowest_instance_vol <= new_volume) {
+ ds_close_channel_fast(lowest_instance_vol_index);
+ first_free_channel = lowest_instance_vol_index;
+ }
+ }
+
  if (first_free_channel < 0) {
- // If we've exceeded the limit, then maybe stop the duplicate if it is lower volume
+ // Make sure that we are not going to play more copies of this sound than we should be
  if ( (instance_count >= limit) && (lowest_instance_vol_index >= 0) ) {
  // If there is a lower volume duplicate, stop it.... otherwise, don't play the sound
  if (lowest_instance_vol <= new_volume) {
  ds_close_channel_fast(lowest_instance_vol_index);
  first_free_channel = lowest_instance_vol_index;
  }
- } else {
- // there is no limit barrier to play the sound, so see if we've ran out of channels
- // stop the lowest volume instance to play our sound if priority demands it
- if ( (lowest_vol_index != -1) && (priority == DS_MUST_PLAY) ) {
- // Check if the lowest volume playing is less than the volume of the requested sound.
- // If so, then we are going to trash the lowest volume sound.
- if ( Channels[lowest_vol_index].vol <= new_volume ) {
- ds_close_channel_fast(lowest_vol_index);
- first_free_channel = lowest_vol_index;
- }
+ }
+ // still don't have a channel and
+ // there is no limit barrier to play the sound, so see if we've ran out of channels
+ // stop the lowest volume instance to play our sound if priority demands it
+ if ( (lowest_vol_index != -1) && (priority == DS_MUST_PLAY) ) {
+ // Check if the lowest volume playing is less than the volume of the requested sound.
+ // If so, then we are going to trash the lowest volume sound.
+ if ( Channels[lowest_vol_index].vol <= new_volume ) {
+ ds_close_channel_fast(lowest_vol_index);
+ first_free_channel = lowest_vol_index;
  }
  }
  }

Trying to fix the sound code here, useful feedback has been requested.
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them

  

Offline Iss Mneur

  • 210
  • TODO:
Re: Let's talk about the sound code... again.
excuse me guys,but do you hear the capship warping effect?
and the capship explosion? the sound should be the Atomic.wav but what i only  hear is the clusterboom sound.
i noticed that working on Diaspora... i think is not only our issue,but i think is a bug in the code.
Plus, the Capship engine not work...if you pass near a ship like the Colossus,you hear nothing IIRC.
thanks in advance for your help
BUMP
ehm...i quoted myself...
thanks again :)
Your post that you quoted wasn't even up for 8 hours before you bumped it, 24-48 hours is a more realistic timeline.  If you want instant answers, use FS modding or #hard-light (assuming they have the answer for you), if you want researched answers, give the coders some time to research it.

Since you posted in this thread, I assume that is because the build that I posted breaks these sounds for you?  I have not changed anything that should affect the playback of these sounds, so if this build is breaking it, go to the the nightly build forum and try the builds there to locate where we broke the sounds in question.

For the record,  I tested this last night, the correct warp, explosion, and engine sounds play just fine for me with retail assets in the trunk build and the build that I posted here.  More than likely the problem is a mod data issue and the ship that is not playing the explosion or warp sound is missing the "capital" ship flag.  I didn't get a chance to check on the specific requirements for engine sounds.

Trying to fix the sound code here, useful feedback has been requested.

Yes please.

With respect to the speakers and audio cards, find the settings (with retail assets) that you like the best with whatever you play the game with.  I am going to make whatever the consensus is the defaults for the engine.  The cmdline flags are not staying.
"I love deadlines. I like the whooshing sound they make as they fly by." -Douglas Adams
wxLauncher 0.9.4 public beta (now with no config file editing for FRED) | wxLauncher 2.0 Request for Comments

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: Let's talk about the sound code... again.
The listener gain thing is pointless as a fix.  I thought that it would help out, and if you don't look at it all too carefully then it does, but after going through the code (FSO and OpenAL) it is just a stupid thing.

I have found several bugs though, most specifically for warps and beams, where they are supposed be played as 3D sounds but get converted to being partially 2D and just kind of breaking how it's supposed to work/sound.  I've fixed that, but it still needs testing.

I also tested putting a timestamp on the nebula lightning so that it won't play a sound except in 750 ms intervals.  Doing this appears to best mimic the most of what retail tended to play.  But the main thing is that it got rid of the clipping 100% in my tests.  500ms clips a bit, 1000ms is too long of a time between sounds.  As a fix it appears to be the only thing that has worked perfectly for me, but it could probably use further tweaking to be even better.

Additionally I am working on some code to step down the gain of multiple of the same sound.  There are a few ways to go about this though and I haven't quite figured out how best to do it yet.  But the idea is that it should (hopefully) squash the clipping issue while still allowing for the full and rich sound environment provided by the new sound code.


Anyway, just an update on what I've found.

 

Offline Flipside

  • əp!sd!l£
  • 212
Re: Let's talk about the sound code... again.
Guys, Seriously.
Stop the irrelevant talk about speaker set ups and audiocards and do something with this:

Okay, another build to try.

This is a rollup of a few different changes so that that we can come up with some appropriate values and/or defaults.  The changes included are:
  • My fix from previously disabled by default.  Enable with cmdline flag -alwaysenforce.
  • Allows dynamic adjustment of the change that Taylor posted.  By default it is also off.  Control this feature with -listenergain <value>-1 disables.  Useful range is 0.0 (effectively turns off sound) to 1.0 (presumably the same as -1).  Taylor's patch sets this to 0.65.
  • Allows control of the percentage of new lightning flashes that get turned into bangs (aka thunder sound plays).  Controlled with -percent_flashtobang <value>.  Default is 100.  I find 25 is too boring, 75 is still too much sound.

Thoughts?  Please post the settings of the above three flags and whether you are using the OpenALSoft.dll so that we can use the numbers to come up with good defaults for retail to use.


Code: (More sound code fun.patch) [Select]
Index: code/cmdline/cmdline.cpp
===================================================================
--- code/cmdline/cmdline.cpp (revision 7567)
+++ code/cmdline/cmdline.cpp (working copy)
@@ -437,8 +437,16 @@
 cmdline_parm output_sexp_arg("-output_sexps", NULL); //WMC - outputs all SEXPs to sexps.html
 cmdline_parm output_scripting_arg("-output_scripting", NULL); //WMC
 
+float Cmdline_percentflashtobang = 100.0f;
+float Cmdline_listenergain = -1;
+int Cmdline_enforce_concurrent_sound_count = 0;
 
+cmdline_parm percent_flashtobang_arg("-percent_flashtobang", NULL);
+cmdline_parm listenergain_arg("-listenergain", NULL);
+cmdline_parm always_enforce_concurrent_sound("-alwaysenforce", NULL);
 
+
+
 #ifndef NDEBUG
 // NOTE: this assumes that os_init() has already been called but isn't a fatal error if it hasn't
 void cmdline_debug_print_cmdline()
@@ -1450,6 +1458,21 @@
  Cmdline_bloom_intensity = bloom_intensity_arg.get_int();
  }
 
+ if ( listenergain_arg.found() )
+ {
+ Cmdline_listenergain = listenergain_arg.get_float();
+ }
+
+ if ( percent_flashtobang_arg.found() )
+ {
+ Cmdline_percentflashtobang = percent_flashtobang_arg.get_float();
+ }
+
+ if ( always_enforce_concurrent_sound.found() )
+ {
+ Cmdline_enforce_concurrent_sound_count = 1;
+ }
+
  return true;
 }
 
Index: code/cmdline/cmdline.h
===================================================================
--- code/cmdline/cmdline.h (revision 7567)
+++ code/cmdline/cmdline.h (working copy)
@@ -145,7 +145,10 @@
 extern int Cmdline_no_grab;
 #endif
 
+// Temp, only for evaluating new defaults
+extern float Cmdline_listenergain;
+extern float Cmdline_percentflashtobang;
+extern int Cmdline_enforce_concurrent_sound_count;
 
-
 //extern char FreeSpace_Directory[]; // allievating a cfilesystem problem caused by fred -- Kazan
 #endif
Index: code/nebula/neblightning.cpp
===================================================================
--- code/nebula/neblightning.cpp (revision 7567)
+++ code/nebula/neblightning.cpp (working copy)
@@ -21,10 +21,8 @@
 #include "weapon/emp.h"
 #include "network/multi.h"
 #include "network/multimsgs.h"
+#include "cmdline/cmdline.h"
 
-
-extern int Cmdline_nohtl;
-
 // ------------------------------------------------------------------------------------------------------
 // NEBULA LIGHTNING DEFINES/VARS
 //
@@ -439,24 +437,27 @@
 
  // do some special stuff on the very first strike of the bolt
  if(b->strikes_left == bi->num_strikes){
- // play a sound
- float bang;
- if(Nebl_bang < 40.0f){
- bang = 1.0f;
- } else if(Nebl_bang > 400.0f){
- bang = 0.0f;
- } else {
- bang = 1.0f - (Nebl_bang / 400.0f);
- }
- if(frand_range(0.0f, 1.0f) < 0.5f){
- snd_play(&Snds[SND_LIGHTNING_2], 0.0f, bang, SND_PRIORITY_DOUBLE_INSTANCE);
- } else {
- snd_play(&Snds[SND_LIGHTNING_1], 0.0f, bang, SND_PRIORITY_DOUBLE_INSTANCE);
- }
+ // play a sound
+ if (frand_range(0.0f, 100.0f) < Cmdline_percentflashtobang)
+ {
+ float bang;
+ if(Nebl_bang < 40.0f){
+ bang = 1.0f;
+ } else if(Nebl_bang > 400.0f){
+ bang = 0.0f;
+ } else {
+ bang = 1.0f - (Nebl_bang / 400.0f);
+ }
+ if(frand_range(0.0f, 1.0f) < 0.5f){
+ snd_play(&Snds[SND_LIGHTNING_2], 0.0f, bang, SND_PRIORITY_DOUBLE_INSTANCE);
+ } else {
+ snd_play(&Snds[SND_LIGHTNING_1], 0.0f, bang, SND_PRIORITY_DOUBLE_INSTANCE);
+ }
 
- // apply em pulse
- if(bi->emp_intensity > 0.0f){
- emp_apply(&b->midpoint, 0.0f, vm_vec_dist(&b->start, &b->strike), bi->emp_intensity, bi->emp_time);
+ // apply em pulse
+ if(bi->emp_intensity > 0.0f){
+ emp_apply(&b->midpoint, 0.0f, vm_vec_dist(&b->start, &b->strike), bi->emp_intensity, bi->emp_time);
+ }
  }
  }
  }
Index: code/sound/ds.cpp
===================================================================
--- code/sound/ds.cpp (revision 7567)
+++ code/sound/ds.cpp (working copy)
@@ -18,8 +18,8 @@
 #include "sound/acm.h"
 #include "osapi/osapi.h"
 #include "sound/dscap.h"
+#include "cmdline/cmdline.h"
 
-
 typedef struct sound_buffer
 {
  ALuint buf_id; // OpenAL buffer id
@@ -1129,6 +1129,10 @@
  // this is needed for 2D pan
  OpenAL_ErrorPrint( alListener3f(AL_POSITION, 0.0, 0.0, 0.0) );
  OpenAL_ErrorPrint( alListenerfv(AL_ORIENTATION, list_orien) );
+ if (Cmdline_listenergain > 0)
+ {
+ OpenAL_ErrorPrint( alListenerf(AL_GAIN, Cmdline_listenergain) );
+ }
 
  // disable doppler (FIXME)
  OpenAL_ErrorPrint( alDopplerFactor(0.0f) );
@@ -1407,24 +1411,33 @@
  }
  }
 
+ // Make sure that we are not going to play more copies of this sound than we should be
+ if ( Cmdline_enforce_concurrent_sound_count && (instance_count >= limit) && (lowest_instance_vol_index >= 0) ) {
+ // If there is a lower volume duplicate, stop it.... otherwise, don't play the sound
+ if (lowest_instance_vol <= new_volume) {
+ ds_close_channel_fast(lowest_instance_vol_index);
+ first_free_channel = lowest_instance_vol_index;
+ }
+ }
+
  if (first_free_channel < 0) {
- // If we've exceeded the limit, then maybe stop the duplicate if it is lower volume
+ // Make sure that we are not going to play more copies of this sound than we should be
  if ( (instance_count >= limit) && (lowest_instance_vol_index >= 0) ) {
  // If there is a lower volume duplicate, stop it.... otherwise, don't play the sound
  if (lowest_instance_vol <= new_volume) {
  ds_close_channel_fast(lowest_instance_vol_index);
  first_free_channel = lowest_instance_vol_index;
  }
- } else {
- // there is no limit barrier to play the sound, so see if we've ran out of channels
- // stop the lowest volume instance to play our sound if priority demands it
- if ( (lowest_vol_index != -1) && (priority == DS_MUST_PLAY) ) {
- // Check if the lowest volume playing is less than the volume of the requested sound.
- // If so, then we are going to trash the lowest volume sound.
- if ( Channels[lowest_vol_index].vol <= new_volume ) {
- ds_close_channel_fast(lowest_vol_index);
- first_free_channel = lowest_vol_index;
- }
+ }
+ // still don't have a channel and
+ // there is no limit barrier to play the sound, so see if we've ran out of channels
+ // stop the lowest volume instance to play our sound if priority demands it
+ if ( (lowest_vol_index != -1) && (priority == DS_MUST_PLAY) ) {
+ // Check if the lowest volume playing is less than the volume of the requested sound.
+ // If so, then we are going to trash the lowest volume sound.
+ if ( Channels[lowest_vol_index].vol <= new_volume ) {
+ ds_close_channel_fast(lowest_vol_index);
+ first_free_channel = lowest_vol_index;
  }
  }
  }

Trying to fix the sound code here, useful feedback has been requested.

Considering that part of what is being discussed is what soundcards people use and how effective the OpenAL support is on them, I would consider that useful, even if it isn't useful to you personally, don't assume that such information is irrelevant. I've fixed sound issues on a friend computer because they'd turned on some internal effects on their own card or it had a built in EQ that had been enabled.

As such, the discussion of soundcards used by members is not irrelevant.

Secondly, as Taylor stated, he is looking for a way to reduce gain on multiple occurences of the same sound, this, once again, relates to the fact that the problem might not be the actual sound itself, but the way the computer mixes it, which is also what I was talking about earlier.

 

Offline Zacam

  • Magnificent Bastard
  • Administrator
  • 211
  • I go Sledge-O-Matic on Spammers
    • Minecraft
    • Steam
    • Twitter
    • ModDB Feature
Re: Let's talk about the sound code... again.

Flipside: Reporting on ones sound configuration and setup while also providing feedback is more the point, not just some random divergence into talking about setups.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!
Talk with the community on Discord
"If you can keep a level head in all this confusion, you just don't understand the situation"

¤[D+¬>

[08/01 16:53:11] <sigtau> EveningTea: I have decided that I am a 32-bit registerkin.  Pronouns are eax, ebx, ecx, edx.
[08/01 16:53:31] <EveningTea> dhauidahh
[08/01 16:53:32] <EveningTea> sak
[08/01 16:53:40] * EveningTea froths at the mouth
[08/01 16:53:40] <sigtau> i broke him, boys

 

Offline Flipside

  • əp!sd!l£
  • 212
Re: Let's talk about the sound code... again.
Agreed, more detail and a more formalised system would probably be needed, but the fact is that if someone is having problems with the sound code, it wouldn't hurt to know what card they are using. That's why I can't really contribute to the thread beyond suggestions, because I know that OpenAL support on my card sucks at the best of times, so I could be having problems that are purely related to that low level of support.

It's not the level of detail I have a problem with, it's the casual shrugging off of information because 'we're trying to fix the sound code here', there are polite ways and rude ways of doing things and a simple smattering of good manners, particularly outside of GD, is not such a big thing to ask.

I've stated on a few sound code threads that I felt it was more to do with the mixing of the sounds when the audio is particularly 'busy', though apparently Taylor found some other problems as well, and I stand by that belief, but if people want to consider my input irrelevant then fine.
« Last Edit: September 01, 2011, 10:19:45 pm by Flipside »

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: Let's talk about the sound code... again.
Sound system setup can change everything about what works and what doesn't, so it never hurts to verify what someone has.  Simply playing the game with headphones instead of a 7.1 sound system can give very different results.  The 7.1 system can play sounds in a different place or moving in a weird direction, and headphones wouldn't show any of that.  Hardware makes a bit of difference, particularly if the sound drivers have an effects mixer which can give strange results if any of that is enabled.  OpenAL versions and how it's installed can make a difference as can what backend is in use.  Also the platform in use can be a big factor, as OpenAL works quite a bit differently on Windows than it does for Linux and OS X.  Far too much depends on the system and setup in question to assume that anything is just a problem with the code.

But I am definitely seeing a couple of code bugs.  Things that weren't really an issue with the DS/DS3D code because of how the two operate (as far as I know, not an expert), but are an issue with OpenAL since it's a unified system.  Cleaning up those issues will help deal with some 2D vs. 3D problems and make it easier to address the other issues.

I haven't quite figured out the true cause of the clipping issue, but it does seem to be related to a mixing problem with sounds that are in close proximity to each other.  Tweaking the gain a bit manually on those individual sounds did a lot to reduce the clipping problems so it's now a matter of implementing a system which can handle that in an automatic manner, and hoping that it really works to fix the problem.

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Let's talk about the sound code... again.
Taylor:   :yes: :yes: :yes:

That's right, I grew a third thumb for that maneuver.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 
Re: Let's talk about the sound code... again.
It is indeed quite relevant because, despite having tried for a while when I have been at my pc (hense, sorry, why I haven't popped up another video with the latest build when I have been on it), I haven't been able to repro the clipping described on Spoons machine on any of the builds, I assume, because of how much the Zonar can handle.
"Neutrality means that you don't really care, cuz the struggle goes on even when you're not there: Blind and unaware."

"We still believe in all the things that we stood by before,
and after everything we've seen here maybe even more.
I know we're not the only ones, and we were not the first,
and unapologetically we'll stand behind each word."

 

Offline torc

  • 210
  • Diaspora SFX engineer
Re: Let's talk about the sound code... again.
excuse me guys,but do you hear the capship warping effect?
and the capship explosion? the sound should be the Atomic.wav but what i only  hear is the clusterboom sound.
i noticed that working on Diaspora... i think is not only our issue,but i think is a bug in the code.
Plus, the Capship engine not work...if you pass near a ship like the Colossus,you hear nothing IIRC.
thanks in advance for your help
BUMP
ehm...i quoted myself...
thanks again :)
Your post that you quoted wasn't even up for 8 hours before you bumped it, 24-48 hours is a more realistic timeline.  If you want instant answers, use FS modding or #hard-light (assuming they have the answer for you), if you want researched answers, give the coders some time to research it.

Since you posted in this thread, I assume that is because the build that I posted breaks these sounds for you?  I have not changed anything that should affect the playback of these sounds, so if this build is breaking it, go to the the nightly build forum and try the builds there to locate where we broke the sounds in question.

For the record,  I tested this last night, the correct warp, explosion, and engine sounds play just fine for me with retail assets in the trunk build and the build that I posted here.  More than likely the problem is a mod data issue and the ship that is not playing the explosion or warp sound is missing the "capital" ship flag.  I didn't get a chance to check on the specific requirements for engine sounds.


i've just Bump my post not for ask you an immediate  answer for my issue,but because seems the discussion went out topic...that's all.

second: i'll try with the new build and see if there are some differences.
Anyway,i can't hear the atom.wav sound when a capship blows and the other issues in the retail build too,and is not due to the soundcard because all the Diaspora members noticed that.

Thanks for the help

« Last Edit: September 02, 2011, 12:43:28 pm by torc »
indossare una divisa può avere un prezzo alto...ma a volte...è troppo alto!!! Bill Adama

 
Re: Let's talk about the sound code... again.
Enough.

Can any non-to-the-subject posts be cleared out and no more be posted, please? Use your self-restraint guys thanks.


I think I nailed the flash-to-bang number needed, although obviously it's to personal taste so... video forthcoming.

Edit for video;

http://www.youtube.com/watch?v=4mry7YcdhaI

As it says in the description I'll fold it into the current long compilation video shortly and will end up;
http://www.youtube.com/watch?v=yBBONSZWTCA
« Last Edit: September 02, 2011, 05:04:54 pm by QuantumDelta »
"Neutrality means that you don't really care, cuz the struggle goes on even when you're not there: Blind and unaware."

"We still believe in all the things that we stood by before,
and after everything we've seen here maybe even more.
I know we're not the only ones, and we were not the first,
and unapologetically we'll stand behind each word."

 

Offline Cyborg17

  • 29
  • Life? Don't talk to me about life....
Re: Let's talk about the sound code... again.
Flash-to-bang is pretty solid in the video, but will it work in a mission with less lightning?

 

Offline Spoon

  • 212
  • ヾ(´︶`♡)ノ
Re: Let's talk about the sound code... again.
Still eagerly awaiting for updates from Taylor on this.
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them