X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=snd_mix.c;h=2274f353ea5cdf6dc40915721de98d4a05d3b245;hb=26678e90426687f151e496d496a8cc4957e0fcba;hp=50c07bcc8b1fe9e8ea704d0c368e7e3124a17dec;hpb=2b6658ae80858652e17ad3489e4bf5df6a7b8106;p=xonotic%2Fdarkplaces.git diff --git a/snd_mix.c b/snd_mix.c index 50c07bcc..2274f353 100644 --- a/snd_mix.c +++ b/snd_mix.c @@ -28,7 +28,6 @@ static portable_sampleframe_t paintbuffer_unswapped[PAINTBUFFER_SIZE]; extern speakerlayout_t snd_speakerlayout; // for querying the listeners -extern void SCR_CaptureVideo_SoundFrame(const portable_sampleframe_t *paintbuffer, size_t length); static void S_CaptureAVISound(const portable_sampleframe_t *paintbuffer, size_t length) { size_t i; @@ -56,6 +55,8 @@ static void S_SoftClipPaintBuffer(portable_sampleframe_t *painted_ptr, int nbfra if((snd_softclip.integer == 1 && width <= 2) || snd_softclip.integer > 1) { + portable_sampleframe_t *p = painted_ptr; + #if 0 /* Soft clipping, the sound of a dream, thanks to Jon Wattes post to Musicdsp.org */ @@ -65,9 +66,8 @@ static void S_SoftClipPaintBuffer(portable_sampleframe_t *painted_ptr, int nbfra // let's do a simple limiter instead, seems to sound better static float maxvol = 0; maxvol = max(1.0f, maxvol * (1.0f - nbframes / (0.4f * snd_renderbuffer->format.speed))); -#define SOFTCLIP(x) if((x)>maxvol) maxvol=(x); (x) /= maxvol; +#define SOFTCLIP(x) if(fabs(x)>maxvol) maxvol=fabs(x); (x) /= maxvol; - portable_sampleframe_t *p = painted_ptr; if (channels == 8) // 7.1 surround { for (i = 0;i < nbframes;i++, p++) @@ -301,7 +301,7 @@ void S_MixToBuffer(void *stream, unsigned int bufferframes) // paint in the channels. // channels with zero volumes still advance in time but don't paint. - ch = channels; + ch = channels; // cppcheck complains here but it is wrong, channels is a channel_t[MAX_CHANNELS] and not an int for (channelindex = 0;channelindex < (int)total_channels;channelindex++, ch++) { sfx = ch->sfx; @@ -360,7 +360,6 @@ void S_MixToBuffer(void *stream, unsigned int bufferframes) // do the actual paint now (may skip work if silent) paint = paintbuffer; - wantframes = totalmixframes; istartframe = 0; for (wantframes = totalmixframes;wantframes > 0;posd += count * speedd, wantframes -= count) {