diff --git a/src/effects/Compressor2.cpp b/src/effects/Compressor2.cpp index 98a2a65ae..e0da5115f 100644 --- a/src/effects/Compressor2.cpp +++ b/src/effects/Compressor2.cpp @@ -91,6 +91,29 @@ Param( LookaheadTime, double, wxT("LookaheadTime"), 0.0, 0.0, 10. Param( LookbehindTime, double, wxT("LookbehindTime"), 0.1, 0.0, 10.0, 200.0 ); Param( OutputGain, double, wxT("OutputGain"), 0.0, 0.0, 50.0, 10.0 ); +struct FactoryPreset +{ + const TranslatableString name; + int algorithm; + int compressBy; + bool stereoInd; + double thresholdDB; + double ratio; + double kneeWidthDB; + double attackTime; + double releaseTime; + double lookaheadTime; + double lookbehindTime; + double outputGainDB; +}; + +static const FactoryPreset FactoryPresets[] = +{ + { XO("Dynamic Reduction"), kEnvPT1, kAmplitude, false, -40, 2.5, 6, 0.3, 0.3, 0.5, 0.5, 23 }, + { XO("Peak Reduction"), kEnvPT1, kAmplitude, false, -10, 10, 0, 0.001, 0.05, 0, 0, 0 }, + { XO("Analog Limiter"), kEnvPT1, kAmplitude, false, -6, 100, 6, 0.0001, 0.0001, 0, 0, 0 } +}; + inline int ScaleToPrecision(double scale) { return ceil(log10(scale)); @@ -736,6 +759,40 @@ bool EffectCompressor2::SetAutomationParameters(CommandParameters & parms) return true; } +RegistryPaths EffectCompressor2::GetFactoryPresets() +{ + RegistryPaths names; + + for (size_t i = 0; i < WXSIZEOF(FactoryPresets); i++) + names.push_back( FactoryPresets[i].name.Translation() ); + + return names; +} + +bool EffectCompressor2::LoadFactoryPreset(int id) +{ + if (id < 0 || id >= int(WXSIZEOF(FactoryPresets))) + return false; + + const FactoryPreset* preset = &FactoryPresets[id]; + + mAlgorithm = preset->algorithm; + mCompressBy = preset->compressBy; + mStereoInd = preset->stereoInd; + + mThresholdDB = preset->thresholdDB; + mRatio = preset->ratio; + mKneeWidthDB = preset->kneeWidthDB; + mAttackTime = preset->attackTime; + mReleaseTime = preset->releaseTime; + mLookaheadTime = preset->lookaheadTime; + mLookbehindTime = preset->lookbehindTime; + mOutputGainDB = preset->outputGainDB; + + TransferDataToWindow(); + return true; +} + // Effect implementation bool EffectCompressor2::CheckWhetherSkipEffect() diff --git a/src/effects/Compressor2.h b/src/effects/Compressor2.h index f1be14686..c4c1159c9 100644 --- a/src/effects/Compressor2.h +++ b/src/effects/Compressor2.h @@ -197,6 +197,8 @@ public: bool DefineParams( ShuttleParams & S ) override; bool GetAutomationParameters(CommandParameters & parms) override; bool SetAutomationParameters(CommandParameters & parms) override; + RegistryPaths GetFactoryPresets() override; + bool LoadFactoryPreset(int id) override; // Effect implementation