diff --git a/src/effects/Noise.cpp b/src/effects/Noise.cpp index 74e975ae2..18301ad9b 100644 --- a/src/effects/Noise.cpp +++ b/src/effects/Noise.cpp @@ -20,6 +20,8 @@ #include "../ShuttleGui.h" #include "../WaveTrack.h" +#include + #ifndef M_PI #define M_PI 3.14159265358979323846 /* pi */ #endif @@ -42,7 +44,7 @@ bool EffectNoise::PromptUser() noiseTypeList.Add(_("White")); noiseTypeList.Add(_("Pink")); - noiseTypeList.Add(_("Brown")); + noiseTypeList.Add(_("Brownian")); NoiseDialog dlog(this, mParent, _("Noise Generator")); @@ -94,8 +96,7 @@ bool EffectNoise::TransferParameters( Shuttle & shuttle ) bool EffectNoise::MakeNoise(float *buffer, sampleCount len, float fs, float amplitude) { - float white, buf0, buf1, buf2, buf3, buf4, buf5; - float a0, b1, fc, y; + float white; sampleCount i; float div = ((float)RAND_MAX) / 2.0f; @@ -107,37 +108,39 @@ bool EffectNoise::MakeNoise(float *buffer, sampleCount len, float fs, float ampl break; case 1: // pink - white=buf0=buf1=buf2=buf3=buf4=buf5=0; + // based on Paul Kellet's "instrumentation grade" algorithm. + white=0; - // 0.55f is an experimental normalization factor: thanks to Martyn - amplitude *= 0.55f; - for(i=0; i 0.01)? 9.0/sqrt(fs) : 0.01; - // 6.2f is an experimental normalization factor: thanks to Martyn - amplitude *= 6.2f; for(i=0; i 1.0) ? (leakage * y - white * scaling) : z; buffer[i] = amplitude * y; - }; + } break; } return true; @@ -193,10 +196,7 @@ void NoiseDialog::PopulateOrExchange( ShuttleGui & S ) { S.StartMultiColumn(2, wxCENTER); { - // The added colon to improve visual consistency was placed outside - // the translatable strings to avoid breaking translations close to 2.0. - // TODO: Make colon part of the translatable string after 2.0. - S.TieChoice(_("Noise type") + wxString(wxT(":")), nType, nTypeList); + S.TieChoice(_("Noise type:"), nType, nTypeList); S.TieNumericTextBox(_("Amplitude (0-1)") + wxString(wxT(":")), nAmplitude, 10); S.AddPrompt(_("Duration") + wxString(wxT(":"))); if (mNoiseDurationT == NULL) @@ -248,5 +248,3 @@ bool NoiseDialog::TransferDataFromWindow() void NoiseDialog::OnTimeCtrlUpdate(wxCommandEvent & event) { Fit(); } - - diff --git a/src/effects/Noise.h b/src/effects/Noise.h index 7749d8d33..0dfcf2f78 100644 --- a/src/effects/Noise.h +++ b/src/effects/Noise.h @@ -36,6 +36,7 @@ class EffectNoise : public BlockGenerator { SetEffectFlags(BUILTIN_EFFECT | INSERT_EFFECT); noiseType = 0; noiseAmplitude = 1.0; + y = z = buf0 = buf1 = buf2 = buf3 = buf4 = buf5 = buf6 = 0; } virtual bool Init(); @@ -71,9 +72,11 @@ class EffectNoise : public BlockGenerator { sampleCount numSamples; int noiseType; double noiseAmplitude; + float y, z, buf0, buf1, buf2, buf3, buf4, buf5, buf6; protected: virtual bool MakeNoise(float *buffer, sampleCount len, float fs, float amplitude); + //double mCurRate; // friendship ... friend class NoiseDialog; @@ -115,16 +118,3 @@ class NoiseDialog:public EffectDialog { }; #endif - - -// Indentation settings for Vim and Emacs and unique identifier for Arch, a -// version control system. Please do not modify past this point. -// -// Local Variables: -// c-basic-offset: 3 -// indent-tabs-mode: nil -// End: -// -// vim: et sts=3 sw=3 -// arch-tag: 3d52765e-51bb-4f53-8ed8-4239f7b42d16 -