From ba3e89b5c731ed6dc36d4650928be8081b3289f5 Mon Sep 17 00:00:00 2001 From: callum_linden Date: Fri, 18 Jan 2013 16:43:19 -0800 Subject: first push - patch from CmdCupCake plus force FMODEX on --- indra/llaudio/llwindgen.h | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'indra/llaudio/llwindgen.h') diff --git a/indra/llaudio/llwindgen.h b/indra/llaudio/llwindgen.h index b9cecb60a1..719b0ecbf2 100644 --- a/indra/llaudio/llwindgen.h +++ b/indra/llaudio/llwindgen.h @@ -27,6 +27,7 @@ #define WINDGEN_H #include "llcommon.h" +#include "llrand.h" template class LLWindGen @@ -54,7 +55,9 @@ public: } const U32 getInputSamplingRate() { return mInputSamplingRate; } - + const F32 getNextSample(); + const F32 getClampedSample(bool clamp, F32 sample); + // newbuffer = the buffer passed from the previous DSP unit. // numsamples = length in samples-per-channel at this mix time. // NOTE: generates L/R interleaved stereo @@ -89,7 +92,7 @@ public: // Start with white noise // This expression is fragile, rearrange it and it will break! - next_sample = (F32)rand() * (1.0f / (F32)(RAND_MAX / (U16_MAX / 8))) + (F32)(S16_MIN / 8); + next_sample = getNextSample(); // Apply a pinking filter // Magic numbers taken from PKE method at http://www.firstpr.com.au/dsp/pink-noise/ @@ -126,23 +129,13 @@ public: for (U8 i=mSubSamples; i && numsamples; --i, --numsamples) { mLastSample = mLastSample + delta; - S32 sample_right = (S32)(mLastSample * mCurrentPanGainR); - S32 sample_left = (S32)mLastSample - sample_right; + MIXBUFFERFORMAT_T sample_right = (MIXBUFFERFORMAT_T)getClampedSample(clip, mLastSample * mCurrentPanGainR); + MIXBUFFERFORMAT_T sample_left = (MIXBUFFERFORMAT_T)getClampedSample(clip, mLastSample - (F32)sample_right); - if (!clip) - { - *cursamplep = (MIXBUFFERFORMAT_T)sample_left; - ++cursamplep; - *cursamplep = (MIXBUFFERFORMAT_T)sample_right; - ++cursamplep; - } - else - { - *cursamplep = (MIXBUFFERFORMAT_T)llclamp(sample_left, (S32)S16_MIN, (S32)S16_MAX); - ++cursamplep; - *cursamplep = (MIXBUFFERFORMAT_T)llclamp(sample_right, (S32)S16_MIN, (S32)S16_MAX); - ++cursamplep; - } + *cursamplep = sample_left; + ++cursamplep; + *cursamplep = sample_right; + ++cursamplep; } } @@ -173,4 +166,9 @@ private: F32 mLastSample; }; +template inline const F32 LLWindGen::getNextSample() { return (F32)rand() * (1.0f / (F32)(RAND_MAX / (U16_MAX / 8))) + (F32)(S16_MIN / 8); } +template<> inline const F32 LLWindGen::getNextSample() { return ll_frand()-.5f; } +template inline const F32 LLWindGen::getClampedSample(bool clamp, F32 sample) { return clamp ? (F32)llclamp((S32)sample,(S32)S16_MIN,(S32)S16_MAX) : sample; } +template<> inline const F32 LLWindGen::getClampedSample(bool clamp, F32 sample) { return sample; } + #endif -- cgit v1.2.3 From bf6182daa8b4d7cea79310547f71d7a3155e17b0 Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Fri, 29 Mar 2013 07:50:08 -0700 Subject: Update Mac and Windows breakpad builds to latest --- indra/llaudio/llwindgen.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 indra/llaudio/llwindgen.h (limited to 'indra/llaudio/llwindgen.h') diff --git a/indra/llaudio/llwindgen.h b/indra/llaudio/llwindgen.h old mode 100644 new mode 100755 -- cgit v1.2.3 From 806d09b1143894ad66cea2c228f467e8c39a8adf Mon Sep 17 00:00:00 2001 From: Graham Madarasz Date: Tue, 30 Apr 2013 19:50:05 -0700 Subject: Merge 3.5.1 into Materials --- indra/llaudio/llwindgen.h | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'indra/llaudio/llwindgen.h') diff --git a/indra/llaudio/llwindgen.h b/indra/llaudio/llwindgen.h index b9cecb60a1..ec58f76f5f 100644 --- a/indra/llaudio/llwindgen.h +++ b/indra/llaudio/llwindgen.h @@ -27,6 +27,7 @@ #define WINDGEN_H #include "llcommon.h" +#include "llrand.h" template class LLWindGen @@ -54,6 +55,8 @@ public: } const U32 getInputSamplingRate() { return mInputSamplingRate; } + const F32 getNextSample(); + const F32 getClampedSample(bool clamp, F32 sample); // newbuffer = the buffer passed from the previous DSP unit. // numsamples = length in samples-per-channel at this mix time. @@ -89,7 +92,7 @@ public: // Start with white noise // This expression is fragile, rearrange it and it will break! - next_sample = (F32)rand() * (1.0f / (F32)(RAND_MAX / (U16_MAX / 8))) + (F32)(S16_MIN / 8); + next_sample = getNextSample(); // Apply a pinking filter // Magic numbers taken from PKE method at http://www.firstpr.com.au/dsp/pink-noise/ @@ -126,25 +129,15 @@ public: for (U8 i=mSubSamples; i && numsamples; --i, --numsamples) { mLastSample = mLastSample + delta; - S32 sample_right = (S32)(mLastSample * mCurrentPanGainR); - S32 sample_left = (S32)mLastSample - sample_right; + MIXBUFFERFORMAT_T sample_right = (MIXBUFFERFORMAT_T)getClampedSample(clip, mLastSample * mCurrentPanGainR); + MIXBUFFERFORMAT_T sample_left = (MIXBUFFERFORMAT_T)getClampedSample(clip, mLastSample - (F32)sample_right); - if (!clip) - { - *cursamplep = (MIXBUFFERFORMAT_T)sample_left; + *cursamplep = sample_left; ++cursamplep; - *cursamplep = (MIXBUFFERFORMAT_T)sample_right; - ++cursamplep; - } - else - { - *cursamplep = (MIXBUFFERFORMAT_T)llclamp(sample_left, (S32)S16_MIN, (S32)S16_MAX); - ++cursamplep; - *cursamplep = (MIXBUFFERFORMAT_T)llclamp(sample_right, (S32)S16_MIN, (S32)S16_MAX); + *cursamplep = sample_right; ++cursamplep; } } - } return newbuffer; } @@ -173,4 +166,9 @@ private: F32 mLastSample; }; +template inline const F32 LLWindGen::getNextSample() { return (F32)rand() * (1.0f / (F32)(RAND_MAX / (U16_MAX / 8))) + (F32)(S16_MIN / 8); } +template<> inline const F32 LLWindGen::getNextSample() { return ll_frand()-.5f; } +template inline const F32 LLWindGen::getClampedSample(bool clamp, F32 sample) { return clamp ? (F32)llclamp((S32)sample,(S32)S16_MIN,(S32)S16_MAX) : sample; } +template<> inline const F32 LLWindGen::getClampedSample(bool clamp, F32 sample) { return sample; } + #endif -- cgit v1.2.3