#define SND_MIN_SPEED 8000
-#define SND_MAX_SPEED 48000
+#define SND_MAX_SPEED 96000
#define SND_MIN_WIDTH 1
#define SND_MAX_WIDTH 2
#define SND_MIN_CHANNELS 1
{ 22050, 2, 2 },
{ 44100, 2, 2 },
{ 48000, 2, 6 },
+ { 96000, 2, 6 },
{ SND_MAX_SPEED, SND_MAX_WIDTH, SND_MAX_CHANNELS },
};
const unsigned int nb_thresholds = sizeof(thresholds) / sizeof(thresholds[0]);
void S_Restart_f(void)
{
+ // NOTE: we can't free all sounds if we are running a map (this frees sfx_t that are still referenced by precaches)
+ // So, refuse to do this if we are connected.
+ if(cls.state == ca_connected)
+ {
+ Con_Printf("snd_restart would wreak havoc if you do that while connected!\n");
+ return;
+ }
+
S_Shutdown();
S_Startup();
}
{
int i;
+ // NOTE: we can't free all sounds if we are running a map (this frees sfx_t that are still referenced by precaches)
+ // So, refuse to do this if we are connected.
+ if(cls.state == ca_connected)
+ {
+ Con_Printf("snd_unloadallsounds would wreak havoc if you do that while connected!\n");
+ return;
+ }
+
// stop any active sounds
S_StopAllSounds();
// Free it
if (sfx->fetcher != NULL && sfx->fetcher->free != NULL)
- sfx->fetcher->free (sfx);
+ sfx->fetcher->free (sfx->fetcher_data);
Mem_Free (sfx);
}
// Initialize the channel
memset (target_chan, 0, sizeof (*target_chan));
VectorCopy (origin, target_chan->origin);
- target_chan->master_vol = (int)(fvol * 255);
target_chan->sfx = sfx;
target_chan->flags = flags;
target_chan->pos = 0; // start of the sound
// Lock the SFX during play
S_LockSfx (sfx);
+
+ // and finally, apply the volume
+ S_SetChannelVolume(target_chan - channels, fvol);
}
{
snd_fetcher_endsb_t fetcher_endsb = sfx->fetcher->endsb;
if (fetcher_endsb != NULL)
- fetcher_endsb (&ch->fetcher_data);
+ fetcher_endsb (ch->fetcher_data);
}
// Remove the lock it holds
S_UnlockSfx (sfx);
+ ch->fetcher_data = NULL;
ch->sfx = NULL;
}
}
void S_SetChannelVolume (unsigned int ch_ind, float fvol)
{
+ sfx_t *sfx = channels[ch_ind].sfx;
+ if(sfx->volume_peak > 0)
+ {
+ // Replaygain support
+ // Con_DPrintf("Setting volume on ReplayGain-enabled track... %f -> ", fvol);
+ fvol *= sfx->volume_mult;
+ if(fvol * sfx->volume_peak > 1)
+ fvol = 1 / sfx->volume_peak;
+ // Con_DPrintf("%f\n", fvol);
+ }
channels[ch_ind].master_vol = (int)(fvol * 255.0f);
}