2019-12-07 11:53 EST


View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002489FSSCPsoundpublic2011-10-02 07:07
ReporterMjnMixael 
Assigned ToThe_E 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version3.6.13 
Target VersionFixed in Version3.6.13 
Summary0002489: adjust-audio-volume doesn't affect subspace
DescriptionI created an in-mission jump through subspace and the player gets a certain amount of time in subspace to finish a task. After the allotted time, it fades to black and goes to a cutscene. With the fade to black, I have 3 adjust-audio-volume sexps for Music, Effects, and Speech fading them all to 0%. It works for all sounds except the in-subspace sound effect.
Additional InformationMission file included... Press Alt-X to execute a fade out. It will fade back after a few seconds.. can repeat in the same mission multple times.
TagsNo tags attached.
Attached Files
  • ? file icon SubspaceTest.fs2 (4,726 bytes) 2011-08-25 12:07
  • ? file icon Asoundtest.fs2 (3,625 bytes) 2011-09-17 03:19
  • ? file icon Soundtest2.fs2 (3,991 bytes) 2011-09-17 19:13
  • diff file icon AdjustLoopingAudioVolume.diff (5,329 bytes) 2011-10-01 19:13 -
    Index: code/hud/hud.cpp
    ===================================================================
    --- code/hud/hud.cpp	(revision 7840)
    +++ code/hud/hud.cpp	 (working copy)
    @@ -1811,7 +1811,6 @@ void update_throttle_sound()
     
     			if ( percent_throttle < ZERO_PERCENT ) {
     				if ( Player_engine_snd_loop > -1 )	{
    -					snd_chg_loop_status(Player_engine_snd_loop, 0);
     					snd_stop(Player_engine_snd_loop); // Backslash - otherwise, long engine loops keep playing
     					Player_engine_snd_loop = -1;
     				}
    Index: code/hud/hudlock.cpp
    ===================================================================
    --- code/hud/hudlock.cpp	(revision 7840)
    +++ code/hud/hudlock.cpp	 (working copy)
    @@ -625,7 +625,7 @@ void hud_do_lock_indicator(float frametime)
     
     	if (Player_ai->current_target_is_locked) {
     		if ( Missile_track_loop > -1 )	{
    -			snd_chg_loop_status(Missile_track_loop, 0);
    +			snd_stop(Missile_track_loop);
     			Missile_track_loop = -1;
     			Missile_lock_loop = snd_play(&Snds[SND_MISSILE_LOCK]);
     		}
    @@ -863,7 +863,7 @@ void hud_calculate_lock_position(float frametime)
     	} else {
     
     		if ( Missile_track_loop > -1 )	{
    -			snd_chg_loop_status(Missile_track_loop, 0);
    +			snd_stop(Missile_track_loop);
     			Missile_track_loop = -1;
     		}
     
    Index: code/sound/sound.cpp
    ===================================================================
    --- code/sound/sound.cpp	(revision 7840)
    +++ code/sound/sound.cpp	 (working copy)
    @@ -56,6 +56,8 @@ float Master_voice_volume = 0.7f;	// range is 0 -> 1, used for all voice playbac
     
     unsigned int SND_ENV_DEFAULT = 0;
     
    +SCP_list<int> currentlyLoopingSoundHandles;
    +
     //For the adjust-audio-volume sexp
     float aav_voice_volume = 1.0f;
     float aav_music_volume = 1.0f;
    @@ -757,6 +759,8 @@ int snd_get_3d_vol_and_pan(game_snd *gs, vec3d *pos, float* vol, float *pan, flo
     	return 0;
     }
     
    +
    +
     // ---------------------------------------------------------------------------------------
     // volume 0 to 1.0.  Returns the handle of the sound. -1 if failed.
     // If startloop or stoploop are not -1, then then are used.
    @@ -817,18 +821,18 @@ int snd_play_looping( game_snd *gs, float pan, int start_loop, int stop_loop, fl
     
     	if ( (volume > MIN_SOUND_VOLUME) || force) {
     		handle = ds_play( snd->sid, gs->id_sig, ds_priority(priority), volume, pan, 1);
    +
    +		currentlyLoopingSoundHandles.push_back(handle);
     	}
     
     	return handle;
     }
     
    -// ---------------------------------------------------------------------------------------
    -// snd_stop()
    -//
    -// Stop a sound from playing.
    -//
    -// parameters:		sig => handle to sound, what is returned from snd_play()
    -//
    +/**
    + * Stop a sound from playing.
    + *
    + * @param sig handle to sound, what is returned from snd_play()
    + */
     void snd_stop( int sig )
     {
     	int channel;
    @@ -840,9 +844,35 @@ void snd_stop( int sig )
     	if ( channel == -1 )
     		return;
     	
    +	SCP_list<int>::iterator iter = currentlyLoopingSoundHandles.begin();
    +	while (iter != currentlyLoopingSoundHandles.end())
    +	{
    +		int handle = *iter;
    +		if(handle == sig) {
    +			iter = currentlyLoopingSoundHandles.erase(iter);
    +		} else {
    +			++iter;
    +		}
    +	}
    +
     	ds_stop_channel(channel);
     }
     
    +/**
    + * Stop all playing sound channels (including looping sounds)
    + *
    + * NOTE: This stops all sounds that are playing from Channels[] sound buffers.
    + * It doesn't stop every secondary sound buffer in existance.
    + */
    +void snd_stop_all()
    +{
    +	if (!ds_initialized)
    +		return;
    +
    +	currentlyLoopingSoundHandles.clear();
    +	ds_stop_channel_all();
    +}
    +
     // ---------------------------------------------------------------------------------------
     // snd_set_volume()
     //
    @@ -985,50 +1015,6 @@ int snd_is_playing( int sig )
     	return 0;
     }
     
    -
    -// ---------------------------------------------------------------------------------------
    -// snd_chg_loop_status()
    -//
    -// Change whether a currently playing song is looping or not
    -//
    -// parameters:		sig			=> handle to sound, what is returned from snd_play()
    -//						loop			=> whether to start (1) or stop (0) looping
    -//
    -void snd_chg_loop_status(int sig, int loop)
    -{
    -	int channel;
    -
    -	if (!ds_initialized)
    -		return;
    -
    -	if ( sig < 0 )
    -		return;
    -
    -	channel = ds_get_channel(sig);
    -	if ( channel == -1 ) {
    -		nprintf(( "Sound", "WARNING: Trying to change loop status of a non-playing sound!\n" ));
    -		return;
    -	}
    -
    -	ds_chg_loop_status(channel, loop);
    -}
    -
    -// ---------------------------------------------------------------------------------------
    -// snd_stop_all()
    -//
    -// Stop all playing sound channels (including looping sounds)
    -//
    -// NOTE: This stops all sounds that are playing from Channels[] sound buffers.  It doesn't
    -//			stop every secondary sound buffer in existance
    -//
    -void snd_stop_all()
    -{
    -	if (!ds_initialized)
    -		return;
    -
    -	ds_stop_channel_all();
    -}
    -
     // ---------------------------------------------------------------------------------------
     // snd_is_inited()
     //
    @@ -1368,6 +1354,13 @@ void snd_do_frame()
     	adjust_volume_on_frame(&aav_music_volume, &aav_data[AAV_MUSIC]);
     	adjust_volume_on_frame(&aav_voice_volume, &aav_data[AAV_VOICE]);
     	adjust_volume_on_frame(&aav_effect_volume, &aav_data[AAV_EFFECTS]);
    +
    +	SCP_list<int>::iterator iter;
    +	for (iter = currentlyLoopingSoundHandles.begin(); iter != currentlyLoopingSoundHandles.end(); ++iter) {
    +		int handle = *iter;
    +		snd_set_volume(handle, 1.0f);
    +	}
    +
     	ds_do_frame();
     }
     
    
    diff file icon AdjustLoopingAudioVolume.diff (5,329 bytes) 2011-10-01 19:13 +
  • diff file icon AdjustLoopingAudioVolume2.diff (8,559 bytes) 2011-10-01 21:01 -
    Index: code/hud/hud.cpp
    ===================================================================
    --- code/hud/hud.cpp	(revision 7840)
    +++ code/hud/hud.cpp	 (working copy)
    @@ -1811,14 +1811,13 @@ void update_throttle_sound()
     
     			if ( percent_throttle < ZERO_PERCENT ) {
     				if ( Player_engine_snd_loop > -1 )	{
    -					snd_chg_loop_status(Player_engine_snd_loop, 0);
     					snd_stop(Player_engine_snd_loop); // Backslash - otherwise, long engine loops keep playing
     					Player_engine_snd_loop = -1;
     				}
     			}
     			else {
     				if ( Player_engine_snd_loop == -1 ){
    -					Player_engine_snd_loop = snd_play_looping( &Snds[SND_ENGINE], 0.0f , -1, -1, percent_throttle * ENGINE_MAX_VOL );
    +					Player_engine_snd_loop = snd_play_looping( &Snds[SND_ENGINE], 0.0f , -1, -1, percent_throttle * ENGINE_MAX_VOL, FALSE);
     				} else {
     					// The sound may have been trashed at the low-level if sound channel overflow.
     					// TODO: implement system where certain sounds cannot be interrupted (priority?)
    Index: code/hud/hudlock.cpp
    ===================================================================
    --- code/hud/hudlock.cpp	(revision 7840)
    +++ code/hud/hudlock.cpp	 (working copy)
    @@ -625,7 +625,7 @@ void hud_do_lock_indicator(float frametime)
     
     	if (Player_ai->current_target_is_locked) {
     		if ( Missile_track_loop > -1 )	{
    -			snd_chg_loop_status(Missile_track_loop, 0);
    +			snd_stop(Missile_track_loop);
     			Missile_track_loop = -1;
     			Missile_lock_loop = snd_play(&Snds[SND_MISSILE_LOCK]);
     		}
    @@ -863,7 +863,7 @@ void hud_calculate_lock_position(float frametime)
     	} else {
     
     		if ( Missile_track_loop > -1 )	{
    -			snd_chg_loop_status(Missile_track_loop, 0);
    +			snd_stop(Missile_track_loop);
     			Missile_track_loop = -1;
     		}
     
    Index: code/sound/sound.cpp
    ===================================================================
    --- code/sound/sound.cpp	(revision 7840)
    +++ code/sound/sound.cpp	 (working copy)
    @@ -56,6 +56,8 @@ float Master_voice_volume = 0.7f;	// range is 0 -> 1, used for all voice playbac
     
     unsigned int SND_ENV_DEFAULT = 0;
     
    +SCP_list<int> currentlyLoopingSoundHandles;
    +
     //For the adjust-audio-volume sexp
     float aav_voice_volume = 1.0f;
     float aav_music_volume = 1.0f;
    @@ -757,28 +759,18 @@ int snd_get_3d_vol_and_pan(game_snd *gs, vec3d *pos, float* vol, float *pan, flo
     	return 0;
     }
     
    -// ---------------------------------------------------------------------------------------
    -// volume 0 to 1.0.  Returns the handle of the sound. -1 if failed.
    -// If startloop or stoploop are not -1, then then are used.
    -//
    -//	NOTE: vol_scale parameter is the multiplicative scaling applied to the default volume
    -//       (vol_scale is a default parameter with a default value of 1.0f)
    -//
    -// input:	gs				=>	game-level sound description
    -//				source_pos	=>	global pos of where the sound is
    -//				listen_pos	=>	global pos of where listener is
    -//				source_vel	=>	velocity of the source playing the sound (used for DirectSound3D only)
    -//				looping		=>	flag to indicate the sound should loop (default value 0)
    -//				vol_scale	=>	factor to scale the static volume by (applied before attenuation)
    -//				priority		=> SND_PRIORITY_MUST_PLAY			(default value)
    -//									SND_PRIORITY_SINGLE_INSTANCE
    -//									SND_PRIORITY_DOUBLE_INSTANCE
    -//									SND_PRIORITY_TRIPLE_INSTANCE
    -//
    -// returns:		-1		=>		sound could not be played
    -//					n		=>		handle for instance of sound
    -//
    -int snd_play_looping( game_snd *gs, float pan, int start_loop, int stop_loop, float vol_scale, int priority, int force )
    +/**
    + * Starts looping a game sound
    + *
    + * @param gs game-level sound description
    + * @param pan -1.0 (full left) to 1.0 (full right)
    + * @param start_loop TODO remove this parameter
    + * @param stop_loop TODO remove this parameter
    + * @param vol_scale factor to scale the static volume by (applied before attenuation)
    + * @param scriptingUpdateVolume if true the looping sound value is updated default is TRUE
    + * @return -1 on error, else the handle for this playing sound
    + */
    +int snd_play_looping( game_snd *gs, float pan, int start_loop, int stop_loop, float vol_scale, int scriptingUpdateVolume)
     {	
     	float volume;
     	int	handle = -1;
    @@ -815,20 +807,22 @@ int snd_play_looping( game_snd *gs, float pan, int start_loop, int stop_loop, fl
     	if ( volume > 1.0f )
     		volume = 1.0f;
     
    -	if ( (volume > MIN_SOUND_VOLUME) || force) {
    -		handle = ds_play( snd->sid, gs->id_sig, ds_priority(priority), volume, pan, 1);
    +	if (volume > MIN_SOUND_VOLUME) {
    +		handle = ds_play( snd->sid, gs->id_sig, DS_MUST_PLAY, volume, pan, 1);
    +
    +		if(handle != -1 && scriptingUpdateVolume) {
    +			currentlyLoopingSoundHandles.push_back(handle);
    +		}
     	}
     
     	return handle;
     }
     
    -// ---------------------------------------------------------------------------------------
    -// snd_stop()
    -//
    -// Stop a sound from playing.
    -//
    -// parameters:		sig => handle to sound, what is returned from snd_play()
    -//
    +/**
    + * Stop a sound from playing.
    + *
    + * @param sig handle to sound, what is returned from snd_play()
    + */
     void snd_stop( int sig )
     {
     	int channel;
    @@ -840,9 +834,35 @@ void snd_stop( int sig )
     	if ( channel == -1 )
     		return;
     	
    +	SCP_list<int>::iterator iter = currentlyLoopingSoundHandles.begin();
    +	while (iter != currentlyLoopingSoundHandles.end())
    +	{
    +		int handle = *iter;
    +		if(handle == sig) {
    +			iter = currentlyLoopingSoundHandles.erase(iter);
    +		} else {
    +			++iter;
    +		}
    +	}
    +
     	ds_stop_channel(channel);
     }
     
    +/**
    + * Stop all playing sound channels (including looping sounds)
    + *
    + * NOTE: This stops all sounds that are playing from Channels[] sound buffers.
    + * It doesn't stop every secondary sound buffer in existance.
    + */
    +void snd_stop_all()
    +{
    +	if (!ds_initialized)
    +		return;
    +
    +	currentlyLoopingSoundHandles.clear();
    +	ds_stop_channel_all();
    +}
    +
     // ---------------------------------------------------------------------------------------
     // snd_set_volume()
     //
    @@ -985,50 +1005,6 @@ int snd_is_playing( int sig )
     	return 0;
     }
     
    -
    -// ---------------------------------------------------------------------------------------
    -// snd_chg_loop_status()
    -//
    -// Change whether a currently playing song is looping or not
    -//
    -// parameters:		sig			=> handle to sound, what is returned from snd_play()
    -//						loop			=> whether to start (1) or stop (0) looping
    -//
    -void snd_chg_loop_status(int sig, int loop)
    -{
    -	int channel;
    -
    -	if (!ds_initialized)
    -		return;
    -
    -	if ( sig < 0 )
    -		return;
    -
    -	channel = ds_get_channel(sig);
    -	if ( channel == -1 ) {
    -		nprintf(( "Sound", "WARNING: Trying to change loop status of a non-playing sound!\n" ));
    -		return;
    -	}
    -
    -	ds_chg_loop_status(channel, loop);
    -}
    -
    -// ---------------------------------------------------------------------------------------
    -// snd_stop_all()
    -//
    -// Stop all playing sound channels (including looping sounds)
    -//
    -// NOTE: This stops all sounds that are playing from Channels[] sound buffers.  It doesn't
    -//			stop every secondary sound buffer in existance
    -//
    -void snd_stop_all()
    -{
    -	if (!ds_initialized)
    -		return;
    -
    -	ds_stop_channel_all();
    -}
    -
     // ---------------------------------------------------------------------------------------
     // snd_is_inited()
     //
    @@ -1368,6 +1344,13 @@ void snd_do_frame()
     	adjust_volume_on_frame(&aav_music_volume, &aav_data[AAV_MUSIC]);
     	adjust_volume_on_frame(&aav_voice_volume, &aav_data[AAV_VOICE]);
     	adjust_volume_on_frame(&aav_effect_volume, &aav_data[AAV_EFFECTS]);
    +
    +	SCP_list<int>::iterator iter;
    +	for (iter = currentlyLoopingSoundHandles.begin(); iter != currentlyLoopingSoundHandles.end(); ++iter) {
    +		int handle = *iter;
    +		snd_set_volume(handle, 1.0f);
    +	}
    +
     	ds_do_frame();
     }
     
    Index: code/sound/sound.h
    ===================================================================
    --- code/sound/sound.h	(revision 7840)
    +++ code/sound/sound.h	 (working copy)
    @@ -97,7 +97,7 @@ void snd_update_3d_pos(int soudnnum, game_snd *gs, vec3d *new_pos, float radius
     // Use these for looping sounds.
     // Returns the handle of the sound. -1 if failed.
     // If startloop or stoploop are not -1, then then are used.
    -int	snd_play_looping( game_snd *gs, float pan=0.0f, int start_loop=-1, int stop_loop=-1, float vol_scale=1.0f, int priority = SND_PRIORITY_MUST_PLAY, int force = 0 );
    +int	snd_play_looping( game_snd *gs, float pan=0.0f, int start_loop=-1, int stop_loop=-1, float vol_scale=1.0f, int scriptingUpdateVolume = 1);
     
     void	snd_stop( int snd_handle );
     
    @@ -172,4 +172,4 @@ int sound_env_supported();
     // adjust-audio-volume
     void snd_aav_init();
     
    -#endif
    \ No newline at end of file
    +#endif
    
    diff file icon AdjustLoopingAudioVolume2.diff (8,559 bytes) 2011-10-01 21:01 +

-Relationships
+Relationships

-Notes

~0012825

Cyborg17 (reporter)

Last edited: 2011-09-17 03:21

The ambient Lucifer sound had the same problem. I tried testing several different things, like whether different destroyers would also break the sexp. But, it appears that the sound continues to play not because it is not affected by the sexp, but because it is looping at the same volume. As soon as the sound stops playing, it will fall under the sexp. Try the mission I've attached.

Essentially, looping sounds aren't affected until they stop playing.

~0012827

MjnMixael (manager)

I think you are confused. That sound is not coming from the destroyer, but it is related to the subspace effect.

~0012828

Cyborg17 (reporter)

Last edited: 2011-09-17 16:00

No, I know that the subspace sound will continue to sound after the sexp has triggered. But the same thing has also happened with destroyer hums. They continue even after the sexp activates but stop when the sound would stop normally in game. If subspace were turned off in a mission and then turned on again, according to what has happened with me, the subspace sound will stop playing and will no longer break the sexp.

Perhaps we're experiencing slightly different bugs related to the same sexp? Are you using Iss_Mneur's sound patch? I'm on R7723 without Iss_Mneur's sound patch.

~0012829

MjnMixael (manager)

Then you need to include a test mission with, you know, destroyers in it.. that hum...

~0012830

Cyborg17 (reporter)

All right, one has been uploaded. Sound sexp activates at 1 second. On my computer the hum sound continues until it is moved to 10000, 10000, 10000. And when it reappears it remains silent.

~0012869

MjnMixael (manager)

My experience with SoundTest2.fs2 is that the destroyer hums were definitely affected by the sexp.

~0012870

Cyborg17 (reporter)

Last edited: 2011-09-30 21:33

Sounds like how we experience issue is directly related to the strength of each person's sound set up. I get both issues, and my sound card is integrated. Yours is probably a lot better than mine.

~0012872

Eli2 (developer)

Last edited: 2011-10-01 21:02

I attached a fix for review.
Edit: second version of this patch

~0012873

Eli2 (developer)

Cyborg17:
just to get you correctly, you set the volume for all effects to zero
with:
( adjust-audio-volume "Effects" 0 )

but you dont reset it to 100
how should the sound even play again ?

~0012874

The_E (administrator)

Patch 2 committed to trunk revision 7847
+Notes

-Issue History
Date Modified Username Field Change
2011-08-25 12:07 MjnMixael New Issue
2011-08-25 12:07 MjnMixael File Added: SubspaceTest.fs2
2011-09-17 03:19 Cyborg17 Note Added: 0012825
2011-09-17 03:19 Cyborg17 File Added: Asoundtest.fs2
2011-09-17 03:21 Cyborg17 Note Edited: 0012825
2011-09-17 15:47 MjnMixael Note Added: 0012827
2011-09-17 15:59 Cyborg17 Note Added: 0012828
2011-09-17 16:00 Cyborg17 Note Edited: 0012828
2011-09-17 16:01 MjnMixael Note Added: 0012829
2011-09-17 19:13 Cyborg17 File Added: Soundtest2.fs2
2011-09-17 19:14 Cyborg17 Note Added: 0012830
2011-09-30 16:30 MjnMixael Note Added: 0012869
2011-09-30 21:33 Cyborg17 Note Added: 0012870
2011-09-30 21:33 Cyborg17 Note Edited: 0012870
2011-10-01 19:13 Eli2 File Added: AdjustLoopingAudioVolume.diff
2011-10-01 19:14 Eli2 Note Added: 0012872
2011-10-01 21:01 Eli2 File Added: AdjustLoopingAudioVolume2.diff
2011-10-01 21:02 Eli2 Note Edited: 0012872
2011-10-01 21:16 Eli2 Note Added: 0012873
2011-10-02 07:07 The_E Note Added: 0012874
2011-10-02 07:07 The_E Status new => resolved
2011-10-02 07:07 The_E Fixed in Version => 3.6.13
2011-10-02 07:07 The_E Resolution open => fixed
2011-10-02 07:07 The_E Assigned To => The_E
+Issue History