Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
LegacyCompressorBase Class Reference

An Effect derived from EffectTwoPassSimpleMono. More...

#include <LegacyCompressorBase.h>

Inheritance diagram for LegacyCompressorBase:
[legend]
Collaboration diagram for LegacyCompressorBase:
[legend]

Public Member Functions

 LegacyCompressorBase ()
 
virtual ~LegacyCompressorBase ()
 
ComponentInterfaceSymbol GetSymbol () const override
 
TranslatableString GetDescription () const override
 
ManualPageID ManualPage () const override
 Name of a page in the Audacity alpha manual, default is empty. More...
 
EffectType GetType () const override
 Type determines how it behaves. More...
 
- Public Member Functions inherited from EffectTwoPassSimpleMono
 ~EffectTwoPassSimpleMono () override
 
bool Process (EffectInstance &instance, EffectSettings &settings) override
 
- Public Member Functions inherited from StatefulEffect
 ~StatefulEffect () override
 
std::shared_ptr< EffectInstanceMakeInstance () const override
 Make an object maintaining short-term state of an Effect. More...
 
- Public Member Functions inherited from StatefulEffectBase
virtual bool Init ()
 
virtual bool Process (EffectInstance &instance, EffectSettings &settings)=0
 
virtual bool RealtimeInitialize (EffectSettings &settings, double sampleRate)
 
virtual bool RealtimeAddProcessor (EffectSettings &settings, EffectOutputs *pOutputs, unsigned numChannels, float sampleRate)
 
virtual bool RealtimeSuspend ()
 
virtual bool RealtimeResume ()
 
virtual bool RealtimeProcessStart (MessagePackage &package)
 settings are possibly changed, since last call, by an asynchronous dialog More...
 
virtual size_t RealtimeProcess (size_t group, EffectSettings &settings, const float *const *inBuf, float *const *outBuf, size_t numSamples)
 
virtual bool RealtimeProcessEnd (EffectSettings &settings) noexcept
 settings can be updated to let a dialog change appearance at idle More...
 
virtual bool RealtimeFinalize (EffectSettings &settings) noexcept
 
virtual size_t SetBlockSize (size_t maxBlockSize)
 
virtual size_t GetBlockSize () const
 
virtual unsigned GetAudioInCount () const
 How many input buffers to allocate at once. More...
 
virtual unsigned GetAudioOutCount () const
 How many output buffers to allocate at once. More...
 
virtual sampleCount GetLatency () const
 
virtual bool NeedsDither () const
 
virtual bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap=nullptr)
 
virtual bool ProcessFinalize () noexcept
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () const override
 
bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings) override
 
bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const override
 
ComponentInterfaceSymbol GetSymbol () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
TranslatableString GetDescription () const override
 
EffectFamilySymbol GetFamily () const override
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () const override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () const override
 Whether the effect sorts "above the line" in the menus. More...
 
RealtimeSince RealtimeSupport () const override
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsAutomation () const override
 Whether the effect has any automatable controls. More...
 
bool SaveSettings (const EffectSettings &settings, CommandParameters &parms) const override
 Store settings as keys and values. More...
 
bool LoadSettings (const CommandParameters &parms, EffectSettings &settings) const override
 Restore settings from keys and values. More...
 
OptionalMessage LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 
bool SaveUserPreset (const RegistryPath &name, const EffectSettings &settings) const override
 Save settings in the configuration file as a user-named preset. More...
 
RegistryPaths GetFactoryPresets () const override
 Report names of factory presets. More...
 
OptionalMessage LoadFactoryPreset (int id, EffectSettings &settings) const override
 
OptionalMessage LoadFactoryDefaults (EffectSettings &settings) const override
 
virtual const EffectParameterMethodsParameters () const
 
bool CanExportPresets () const override
 Whether the effect supports export of presets to files, and importing too. More...
 
bool HasOptions () const override
 
const EffectSettingsManagerGetDefinition () const override
 
virtual NumericFormatID GetSelectionFormat ()
 
bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const override
 
OptionalMessage LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const override
 
bool IsBatchProcessing () const override
 
void SetBatchProcessing () override
 
void UnsetBatchProcessing () override
 
unsigned TestUIFlags (unsigned mask)
 
bool Delegate (Effect &delegate, EffectSettings &settings, InstanceFinder finder={})
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
bool IsLinearEffect () const
 
bool PreviewsFullSelection () const
 
void SetTracks (TrackList *pTracks)
 
double GetDefaultDuration ()
 
virtual std::any BeginPreview (const EffectSettings &settings)
 Called when Preview() starts, to allow temporary effect state changes. More...
 
bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess) override
 
virtual double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const =0
 
void CountWaveTracks ()
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual bool HasOptions () const =0
 
virtual bool CanExportPresets () const =0
 Whether the effect supports export of presets to files, and importing too. More...
 
virtual const EffectSettingsManagerGetDefinition () const =0
 
virtual bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0
 
virtual OptionalMessage LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const =0
 
virtual bool IsBatchProcessing () const =0
 
virtual void SetBatchProcessing ()=0
 
virtual void UnsetBatchProcessing ()=0
 
virtual bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess=nullptr)=0
 
- Public Member Functions inherited from EffectInstanceFactory
virtual ~EffectInstanceFactory ()
 
virtual std::shared_ptr< EffectInstanceMakeInstance () const =0
 Make an object maintaining short-term state of an Effect. More...
 
- Public Member Functions inherited from EffectSettingsManager
virtual ~EffectSettingsManager ()
 
virtual bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings)
 
virtual bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const
 
virtual EffectSettings MakeSettings () const
 
virtual bool CopySettingsContents (const EffectSettings &src, EffectSettings &dst) const
 Update one settings object from another. More...
 
virtual std::unique_ptr< EffectOutputsMakeOutputs () const
 Produce an object to hold values to send to effect output meters. More...
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetType () const =0
 Type determines how it behaves. More...
 
virtual EffectType GetClassification () const
 Determines which menu it appears in; default same as GetType(). More...
 
virtual EffectFamilySymbol GetFamily () const =0
 Report identifier and user-visible name of the effect protocol. More...
 
virtual bool IsInteractive () const =0
 Whether the effect needs a dialog for entry of settings. More...
 
virtual bool IsDefault () const =0
 Whether the effect sorts "above the line" in the menus. More...
 
virtual RealtimeSince RealtimeSupport () const =0
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsRealtime () const
 
virtual bool SupportsAutomation () const =0
 Whether the effect has any automatable controls. More...
 
virtual bool EnablesDebug () const
 Whether the effect dialog should have a Debug button; default, always false. More...
 
virtual ManualPageID ManualPage () const
 Name of a page in the Audacity alpha manual, default is empty. More...
 
virtual FilePath HelpPage () const
 Fully qualified local help file name, default is empty. More...
 
virtual bool IsHiddenFromMenus () const
 Default is false. More...
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
virtual PluginPath GetPath () const =0
 
virtual ComponentInterfaceSymbol GetSymbol () const =0
 
virtual VendorSymbol GetVendor () const =0
 
virtual wxString GetVersion () const =0
 
virtual TranslatableString GetDescription () const =0
 
TranslatableString GetName () const
 

Static Public Member Functions

static LegacyCompressorBaseFetchParameters (LegacyCompressorBase &e, EffectSettings &)
 
- Static Public Member Functions inherited from Effect
static EffectFetchParameters (Effect &e, EffectSettings &)
 
- Static Public Member Functions inherited from EffectBase
static std::optional< InstancePointerFindInstance (EffectPlugin &plugin)
 
static InstanceFinder DefaultInstanceFinder (EffectPlugin &plugin)
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 

Static Public Attributes

static const ComponentInterfaceSymbol Symbol
 
- Static Public Attributes inherited from EffectPlugin
static const wxString kUserPresetIdent = wxT("User Preset:")
 
static const wxString kFactoryPresetIdent = wxT("Factory Preset:")
 
static const wxString kCurrentSettingsIdent = wxT("<Current Settings>")
 
static const wxString kFactoryDefaultsIdent = wxT("<Factory Defaults>")
 

Protected Member Functions

bool InitPass1 () override
 
bool InitPass2 () override
 
bool NewTrackPass1 () override
 
bool ProcessPass2 (float *buffer, size_t len) override
 
bool TwoBufferProcessPass1 (float *buffer1, size_t len1, float *buffer2, size_t len2) override
 
const EffectParameterMethodsParameters () const override
 
- Protected Member Functions inherited from EffectTwoPassSimpleMono
virtual bool InitPass1 ()
 
virtual bool InitPass2 ()
 
virtual bool NewTrackPass1 ()
 
virtual bool NewTrackPass2 ()
 
virtual bool ProcessPass1 (float *WXUNUSED(buffer), size_t WXUNUSED(len))
 Override this method to actually process audio. More...
 
virtual bool ProcessPass2 (float *WXUNUSED(buffer), size_t WXUNUSED(len))
 
virtual bool TwoBufferProcessPass1 (float *buffer1, size_t len1, float *buffer2, size_t len2)
 
virtual bool TwoBufferProcessPass2 (float *buffer1, size_t len1, float *buffer2, size_t len2)
 
void DisableSecondPass ()
 Call this if you know in advance that no second pass will be needed. More...
 
- Protected Member Functions inherited from Effect
bool CheckWhetherSkipEffect (const EffectSettings &settings) const override
 Default implementation returns false. More...
 
double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const override
 Default implementation returns previewLength More...
 
bool TotalProgress (double frac, const TranslatableString &={}) const
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={}) const
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={}) const
 
int GetNumWaveTracks () const
 
int GetNumWaveGroups () const
 
void GetBounds (const WaveTrack &track, sampleCount *start, sampleCount *len)
 
- Protected Member Functions inherited from EffectBase
virtual bool CheckWhetherSkipEffect (const EffectSettings &settings) const =0
 After Init(), tell whether Process() should be skipped. More...
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing () const
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 

Protected Attributes

double mRMSSum
 
size_t mCircleSize
 
size_t mCirclePos
 
Doubles mCircle
 
double mAttackTime
 
double mThresholdDB
 
double mNoiseFloorDB
 
double mRatio
 
bool mNormalize
 
bool mUsePeak
 
double mDecayTime
 
double mAttackFactor
 
double mAttackInverseFactor
 
double mDecayFactor
 
double mThreshold
 
double mCompression
 
double mNoiseFloor
 
int mNoiseCounter
 
double mGain
 
double mLastLevel
 
Floats mFollow1
 
Floats mFollow2
 
size_t mFollowLen
 
double mMax
 
- Protected Attributes inherited from EffectTwoPassSimpleMono
int mCurTrackNum
 
double mCurRate
 
double mCurT0
 
double mCurT1
 
int mPass
 
bool mSecondPassDisabled
 
std::shared_ptr< TrackListmWorkTracks
 
TrackListmTrackLists [2]
 
- Protected Attributes inherited from EffectBase
double mF0 {}
 
double mF1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 

Static Protected Attributes

static constexpr EffectParameter Threshold
 
static constexpr EffectParameter NoiseFloor
 
static constexpr EffectParameter Ratio
 
static constexpr EffectParameter AttackTime
 
static constexpr EffectParameter ReleaseTime
 
static constexpr EffectParameter Normalize
 
static constexpr EffectParameter UsePeak
 

Private Member Functions

void FreshenCircle ()
 
float AvgCircle (float x)
 
void Follow (float *buffer, float *env, size_t len, float *previous, size_t previous_len)
 
float DoCompression (float x, double env)
 

Additional Inherited Members

- Public Types inherited from StatefulEffectBase
using MessagePackage = EffectInstance::MessagePackage
 
- Public Types inherited from EffectPlugin
using EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess >
 
using InstancePointer = std::shared_ptr< EffectInstanceEx >
 
using InstanceFinder = std::function< std::optional< InstancePointer >(EffectSettings &settings) >
 
- Public Types inherited from EffectDefinitionInterface
enum class  RealtimeSince : unsigned { Never , After_3_1 , Always }
 In which versions of Audacity was an effect realtime capable? More...
 
- Public Attributes inherited from EffectBase
std::shared_ptr< TrackListmTracks {}
 
int mNumTracks {}
 
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
double mT0 {}
 
double mT1 {}
 
bool mIsPreview { false }
 

Detailed Description

An Effect derived from EffectTwoPassSimpleMono.

Definition at line 19 of file LegacyCompressorBase.h.

Constructor & Destructor Documentation

◆ LegacyCompressorBase()

LegacyCompressorBase::LegacyCompressorBase ( )

Definition at line 45 of file LegacyCompressorBase.cpp.

46{
47 Parameters().Reset(*this);
48
49 mThreshold = 0.25;
50 mNoiseFloor = 0.01;
51 mCompression = 0.5;
52 mFollowLen = 0;
53
55}
void SetLinearEffectFlag(bool linearEffectFlag)
Definition: EffectBase.cpp:210
virtual void Reset(Effect &effect) const =0
const EffectParameterMethods & Parameters() const override

References mCompression, mFollowLen, mNoiseFloor, mThreshold, Parameters(), EffectParameterMethods::Reset(), and EffectBase::SetLinearEffectFlag().

Referenced by Parameters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~LegacyCompressorBase()

LegacyCompressorBase::~LegacyCompressorBase ( )
virtual

Definition at line 57 of file LegacyCompressorBase.cpp.

58{
59}

Member Function Documentation

◆ AvgCircle()

float LegacyCompressorBase::AvgCircle ( float  x)
private

Definition at line 212 of file LegacyCompressorBase.cpp.

213{
214 float level;
215
216 // Calculate current level from root-mean-squared of
217 // circular buffer ("RMS")
219 mCircle[mCirclePos] = value * value;
221 level = sqrt(mRMSSum / mCircleSize);
223
224 return level;
225}
__finl float_x4 __vecc sqrt(const float_x4 &a)

References mCircle, mCirclePos, mCircleSize, mRMSSum, and staffpad::audio::simd::sqrt().

Referenced by Follow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoCompression()

float LegacyCompressorBase::DoCompression ( float  x,
double  env 
)
private

Definition at line 354 of file LegacyCompressorBase.cpp.

355{
356 float out;
357 if (mUsePeak)
358 {
359 // Peak values map 1.0 to 1.0 - 'upward' compression
360 out = value * pow(1.0 / env, mCompression);
361 }
362 else
363 {
364 // With RMS-based compression don't change values below mThreshold -
365 // 'downward' compression
366 out = value * pow(mThreshold / env, mCompression);
367 }
368
369 // Retain the maximum value for use in the normalization pass
370 if (mMax < fabs(out))
371 mMax = fabs(out);
372
373 return out;
374}

References mCompression, mMax, mThreshold, and mUsePeak.

Referenced by TwoBufferProcessPass1().

Here is the caller graph for this function:

◆ FetchParameters()

static LegacyCompressorBase * LegacyCompressorBase::FetchParameters ( LegacyCompressorBase e,
EffectSettings  
)
inlinestatic

Definition at line 23 of file LegacyCompressorBase.h.

24 {
25 return &e;
26 }

◆ Follow()

void LegacyCompressorBase::Follow ( float *  buffer,
float *  env,
size_t  len,
float *  previous,
size_t  previous_len 
)
private

Definition at line 227 of file LegacyCompressorBase.cpp.

229{
230 /*
231
232 "Follow"ing algorithm by Roger B. Dannenberg, taken from
233 Nyquist. His description follows. -DMM
234
235 Description: this is a sophisticated envelope follower.
236 The input is an envelope, e.g. something produced with
237 the AVG function. The purpose of this function is to
238 generate a smooth envelope that is generally not less
239 than the input signal. In other words, we want to "ride"
240 the peaks of the signal with a smooth function. The
241 algorithm is as follows: keep a current output value
242 (called the "value"). The value is allowed to increase
243 by at most rise_factor and decrease by at most fall_factor.
244 Therefore, the next value should be between
245 value * rise_factor and value * fall_factor. If the input
246 is in this range, then the next value is simply the input.
247 If the input is less than value * fall_factor, then the
248 next value is just value * fall_factor, which will be greater
249 than the input signal. If the input is greater than value *
250 rise_factor, then we compute a rising envelope that meets
251 the input value by working bacwards in time, changing the
252 previous values to input / rise_factor, input / rise_factor^2,
253 input / rise_factor^3, etc. until this NEW envelope intersects
254 the previously computed values. There is only a limited buffer
255 in which we can work backwards, so if the NEW envelope does not
256 intersect the old one, then make yet another pass, this time
257 from the oldest buffered value forward, increasing on each
258 sample by rise_factor to produce a maximal envelope. This will
259 still be less than the input.
260
261 The value has a lower limit of floor to make sure value has a
262 reasonable positive value from which to begin an attack.
263 */
264 double level, last;
265
266 if (!mUsePeak)
267 {
268 // Update RMS sum directly from the circle buffer
269 // to avoid accumulation of rounding errors
271 }
272 // First apply a peak detect with the requested decay rate
273 last = mLastLevel;
274 for (size_t i = 0; i < len; i++)
275 {
276 if (mUsePeak)
277 level = fabs(buffer[i]);
278 else // use RMS
279 level = AvgCircle(buffer[i]);
280 // Don't increase gain when signal is continuously below the noise floor
281 if (level < mNoiseFloor)
282 {
284 }
285 else
286 {
287 mNoiseCounter = 0;
288 }
289 if (mNoiseCounter < 100)
290 {
291 last *= mDecayFactor;
292 if (last < mThreshold)
293 last = mThreshold;
294 if (level > last)
295 last = level;
296 }
297 env[i] = last;
298 }
299 mLastLevel = last;
300
301 // Next do the same process in reverse direction to get the requested attack
302 // rate
303 last = mLastLevel;
304 for (size_t i = len; i--;)
305 {
306 last *= mAttackInverseFactor;
307 if (last < mThreshold)
308 last = mThreshold;
309 if (env[i] < last)
310 env[i] = last;
311 else
312 last = env[i];
313 }
314
315 if ((previous != NULL) && (previous_len > 0))
316 {
317 // If the previous envelope was passed, propagate the rise back until we
318 // intersect
319 for (size_t i = previous_len; i--;)
320 {
321 last *= mAttackInverseFactor;
322 if (last < mThreshold)
323 last = mThreshold;
324 if (previous[i] < last)
325 previous[i] = last;
326 else // Intersected the previous envelope buffer, so we are finished
327 return;
328 }
329 // If we can't back up far enough, project the starting level forward
330 // until we intersect the desired envelope
331 last = previous[0];
332 for (size_t i = 1; i < previous_len; i++)
333 {
334 last *= mAttackFactor;
335 if (previous[i] > last)
336 previous[i] = last;
337 else // Intersected the desired envelope, so we are finished
338 return;
339 }
340 // If we still didn't intersect, then continue ramp up into current buffer
341 for (size_t i = 0; i < len; i++)
342 {
343 last *= mAttackFactor;
344 if (buffer[i] > last)
345 buffer[i] = last;
346 else // Finally got an intersect
347 return;
348 }
349 // If we still didn't intersect, then reset mLastLevel
350 mLastLevel = last;
351 }
352}

References AvgCircle(), FreshenCircle(), mAttackFactor, mAttackInverseFactor, mDecayFactor, mLastLevel, mNoiseCounter, mNoiseFloor, mThreshold, and mUsePeak.

Referenced by TwoBufferProcessPass1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FreshenCircle()

void LegacyCompressorBase::FreshenCircle ( )
private

Definition at line 203 of file LegacyCompressorBase.cpp.

204{
205 // Recompute the RMS sum periodically to prevent accumulation of rounding
206 // errors during long waveforms
207 mRMSSum = 0;
208 for (size_t i = 0; i < mCircleSize; i++)
209 mRMSSum += mCircle[i];
210}

References mCircle, mCircleSize, and mRMSSum.

Referenced by Follow().

Here is the caller graph for this function:

◆ GetDescription()

TranslatableString LegacyCompressorBase::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 68 of file LegacyCompressorBase.cpp.

69{
70 return XO("Compresses the dynamic range of audio");
71}
XO("Cut/Copy/Paste")

References XO().

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol LegacyCompressorBase::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 63 of file LegacyCompressorBase.cpp.

64{
65 return Symbol;
66}
static const ComponentInterfaceSymbol Symbol

References Symbol.

◆ GetType()

EffectType LegacyCompressorBase::GetType ( ) const
overridevirtual

Type determines how it behaves.

Implements EffectDefinitionInterface.

Definition at line 80 of file LegacyCompressorBase.cpp.

81{
82 return EffectTypeProcess;
83}
@ EffectTypeProcess

References EffectTypeProcess.

◆ InitPass1()

bool LegacyCompressorBase::InitPass1 ( )
overrideprotectedvirtual

Override these methods if you need to initialize something before each pass. Return false if processing should stop.

Reimplemented from EffectTwoPassSimpleMono.

Definition at line 112 of file LegacyCompressorBase.cpp.

113{
114 mMax = 0.0;
115 if (!mNormalize)
117
118 // Find the maximum block length required for any track
119 size_t maxlen = inputTracks()->Selected<const WaveTrack>().max(
121 mFollow1.reset();
122 mFollow2.reset();
123 // Allocate buffers for the envelope
124 if (maxlen > 0)
125 {
126 mFollow1.reinit(maxlen);
127 mFollow2.reinit(maxlen);
128 }
129 mFollowLen = maxlen;
130
131 return true;
132}
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:59
const TrackList * inputTracks() const
Definition: EffectBase.h:102
void DisableSecondPass()
Call this if you know in advance that no second pass will be needed.
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:967
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
size_t GetMaxBlockSize() const
Definition: WaveTrack.cpp:2279

References EffectTwoPassSimpleMono::DisableSecondPass(), WaveTrack::GetMaxBlockSize(), EffectBase::inputTracks(), mFollow1, mFollow2, mFollowLen, mMax, mNormalize, ArrayOf< X >::reinit(), and TrackList::Selected().

Here is the call graph for this function:

◆ InitPass2()

bool LegacyCompressorBase::InitPass2 ( )
overrideprotectedvirtual

Reimplemented from EffectTwoPassSimpleMono.

Definition at line 134 of file LegacyCompressorBase.cpp.

135{
136 // Actually, this should not even be called, because we call
137 // DisableSecondPass() before, if mNormalize is false.
138 return mNormalize;
139}

References mNormalize.

◆ ManualPage()

ManualPageID LegacyCompressorBase::ManualPage ( ) const
overridevirtual

Name of a page in the Audacity alpha manual, default is empty.

Reimplemented from EffectDefinitionInterface.

Definition at line 73 of file LegacyCompressorBase.cpp.

74{
75 return L"Compressor";
76}

◆ NewTrackPass1()

bool LegacyCompressorBase::NewTrackPass1 ( )
overrideprotectedvirtual

Override these methods if you need to do things before every track (including the first one)

Reimplemented from EffectTwoPassSimpleMono.

Definition at line 87 of file LegacyCompressorBase.cpp.

88{
91 mNoiseCounter = 100;
92
95 mDecayFactor = exp(log(mThreshold) / (mCurRate * mDecayTime + 0.5));
96
97 if (mRatio > 1)
98 mCompression = 1.0 - 1.0 / mRatio;
99 else
100 mCompression = 0.0;
101
103
104 mCircleSize = 100;
106 mCirclePos = 0;
107 mRMSSum = 0.0;
108
109 return true;
110}
#define DB_TO_LINEAR(x)
Definition: MemoryX.h:338

References DB_TO_LINEAR, mAttackFactor, mAttackInverseFactor, mAttackTime, mCircle, mCirclePos, mCircleSize, mCompression, EffectTwoPassSimpleMono::mCurRate, mDecayFactor, mDecayTime, mLastLevel, mNoiseCounter, mNoiseFloor, mNoiseFloorDB, mRatio, mRMSSum, mThreshold, mThresholdDB, and ArrayOf< X >::reinit().

Here is the call graph for this function:

◆ Parameters()

const EffectParameterMethods & LegacyCompressorBase::Parameters ( ) const
overrideprotectedvirtual

Reimplemented from Effect.

Definition at line 26 of file LegacyCompressorBase.cpp.

27{
28 static CapturedParameters<
30 Ratio, // positive number > 1.0
31 AttackTime, // seconds
32 ReleaseTime, // seconds
34 parameters;
35 return parameters;
36}
Generates EffectParameterMethods overrides from variadic template arguments.
static constexpr EffectParameter ReleaseTime
static constexpr EffectParameter Ratio
static constexpr EffectParameter Normalize
static constexpr EffectParameter AttackTime
static constexpr EffectParameter NoiseFloor
static constexpr EffectParameter UsePeak
static constexpr EffectParameter Threshold

References AttackTime, LegacyCompressorBase(), NoiseFloor, Normalize, Ratio, ReleaseTime, Threshold, and UsePeak.

Referenced by LegacyCompressorBase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessPass2()

bool LegacyCompressorBase::ProcessPass2 ( float *  buffer,
size_t  len 
)
overrideprotected

Definition at line 192 of file LegacyCompressorBase.cpp.

193{
194 if (mMax != 0)
195 {
196 for (size_t i = 0; i < len; i++)
197 buffer[i] /= mMax;
198 }
199
200 return true;
201}

References mMax.

◆ TwoBufferProcessPass1()

bool LegacyCompressorBase::TwoBufferProcessPass1 ( float *  buffer1,
size_t  len1,
float *  buffer2,
size_t  len2 
)
overrideprotectedvirtual

Override this method to actually process audio with access to 2 sequential buffers at a time

Either buffer1 or buffer2 may be modified as needed This allows implementation of processing with delays The default just calls the one-buffer-at-a-time method

Reimplemented from EffectTwoPassSimpleMono.

Definition at line 144 of file LegacyCompressorBase.cpp.

146{
147 // If buffers are bigger than allocated, then abort
148 // (this should never happen, but if it does, we don't want to crash)
149 if ((len1 > mFollowLen) || (len2 > mFollowLen))
150 return false;
151
152 // This makes sure that the initial value is well-chosen
153 // buffer1 == NULL on the first and only the first call
154 if (buffer1 == NULL)
155 {
156 // Initialize the mLastLevel to the peak level in the first buffer
157 // This avoids problems with large spike events near the beginning of the
158 // track
160 for (size_t i = 0; i < len2; i++)
161 {
162 if (mLastLevel < fabs(buffer2[i]))
163 mLastLevel = fabs(buffer2[i]);
164 }
165 }
166
167 // buffer2 is NULL on the last and only the last call
168 if (buffer2 != NULL)
169 {
170 Follow(buffer2, mFollow2.get(), len2, mFollow1.get(), len1);
171 }
172
173 if (buffer1 != NULL)
174 {
175 for (size_t i = 0; i < len1; i++)
176 {
177 buffer1[i] = DoCompression(buffer1[i], mFollow1[i]);
178 }
179 }
180
181#if 0
182 // Copy the envelope over the track data (for debug purposes)
183 memcpy(buffer1, mFollow1, len1*sizeof(float));
184#endif
185
186 // Rotate the buffer pointers
187 mFollow1.swap(mFollow2);
188
189 return true;
190}
void Follow(float *buffer, float *env, size_t len, float *previous, size_t previous_len)
float DoCompression(float x, double env)

References DoCompression(), Follow(), mFollow1, mFollow2, mFollowLen, mLastLevel, and mThreshold.

Here is the call graph for this function:

Member Data Documentation

◆ AttackTime

constexpr EffectParameter LegacyCompressorBase::AttackTime
staticconstexprprotected
Initial value:
{
&LegacyCompressorBase::mAttackTime, L"AttackTime", 0.2, 0.1, 5.0, 100
}

Definition at line 107 of file LegacyCompressorBase.h.

Referenced by Parameters(), EffectLegacyCompressor::PopulateOrExchange(), and EffectLegacyCompressor::TransferDataToWindow().

◆ mAttackFactor

double LegacyCompressorBase::mAttackFactor
protected

Definition at line 77 of file LegacyCompressorBase.h.

Referenced by Follow(), and NewTrackPass1().

◆ mAttackInverseFactor

double LegacyCompressorBase::mAttackInverseFactor
protected

Definition at line 78 of file LegacyCompressorBase.h.

Referenced by Follow(), and NewTrackPass1().

◆ mAttackTime

double LegacyCompressorBase::mAttackTime
protected

◆ mCircle

Doubles LegacyCompressorBase::mCircle
protected

Definition at line 67 of file LegacyCompressorBase.h.

Referenced by AvgCircle(), FreshenCircle(), and NewTrackPass1().

◆ mCirclePos

size_t LegacyCompressorBase::mCirclePos
protected

Definition at line 66 of file LegacyCompressorBase.h.

Referenced by AvgCircle(), and NewTrackPass1().

◆ mCircleSize

size_t LegacyCompressorBase::mCircleSize
protected

Definition at line 65 of file LegacyCompressorBase.h.

Referenced by AvgCircle(), FreshenCircle(), and NewTrackPass1().

◆ mCompression

double LegacyCompressorBase::mCompression
protected

Definition at line 81 of file LegacyCompressorBase.h.

Referenced by DoCompression(), LegacyCompressorBase(), and NewTrackPass1().

◆ mDecayFactor

double LegacyCompressorBase::mDecayFactor
protected

Definition at line 79 of file LegacyCompressorBase.h.

Referenced by Follow(), and NewTrackPass1().

◆ mDecayTime

double LegacyCompressorBase::mDecayTime
protected

◆ mFollow1

Floats LegacyCompressorBase::mFollow1
protected

Definition at line 86 of file LegacyCompressorBase.h.

Referenced by InitPass1(), and TwoBufferProcessPass1().

◆ mFollow2

Floats LegacyCompressorBase::mFollow2
protected

Definition at line 86 of file LegacyCompressorBase.h.

Referenced by InitPass1(), and TwoBufferProcessPass1().

◆ mFollowLen

size_t LegacyCompressorBase::mFollowLen
protected

Definition at line 87 of file LegacyCompressorBase.h.

Referenced by InitPass1(), LegacyCompressorBase(), and TwoBufferProcessPass1().

◆ mGain

double LegacyCompressorBase::mGain
protected

Definition at line 84 of file LegacyCompressorBase.h.

◆ mLastLevel

double LegacyCompressorBase::mLastLevel
protected

Definition at line 85 of file LegacyCompressorBase.h.

Referenced by Follow(), NewTrackPass1(), and TwoBufferProcessPass1().

◆ mMax

double LegacyCompressorBase::mMax
protected

Definition at line 89 of file LegacyCompressorBase.h.

Referenced by DoCompression(), InitPass1(), and ProcessPass2().

◆ mNoiseCounter

int LegacyCompressorBase::mNoiseCounter
protected

Definition at line 83 of file LegacyCompressorBase.h.

Referenced by Follow(), and NewTrackPass1().

◆ mNoiseFloor

double LegacyCompressorBase::mNoiseFloor
protected

Definition at line 82 of file LegacyCompressorBase.h.

Referenced by Follow(), LegacyCompressorBase(), and NewTrackPass1().

◆ mNoiseFloorDB

double LegacyCompressorBase::mNoiseFloorDB
protected

◆ mNormalize

bool LegacyCompressorBase::mNormalize
protected

◆ mRatio

double LegacyCompressorBase::mRatio
protected

◆ mRMSSum

double LegacyCompressorBase::mRMSSum
protected

Definition at line 64 of file LegacyCompressorBase.h.

Referenced by AvgCircle(), FreshenCircle(), and NewTrackPass1().

◆ mThreshold

double LegacyCompressorBase::mThreshold
protected

◆ mThresholdDB

double LegacyCompressorBase::mThresholdDB
protected

◆ mUsePeak

bool LegacyCompressorBase::mUsePeak
protected

◆ NoiseFloor

constexpr EffectParameter LegacyCompressorBase::NoiseFloor
staticconstexprprotected

◆ Normalize

constexpr EffectParameter LegacyCompressorBase::Normalize
staticconstexprprotected
Initial value:
{
&LegacyCompressorBase::mNormalize, L"Normalize", true, false, true, 1
}

Definition at line 113 of file LegacyCompressorBase.h.

Referenced by Parameters(), and EffectLegacyCompressor::PopulateOrExchange().

◆ Ratio

constexpr EffectParameter LegacyCompressorBase::Ratio
staticconstexprprotected

◆ ReleaseTime

constexpr EffectParameter LegacyCompressorBase::ReleaseTime
staticconstexprprotected

◆ Symbol

const ComponentInterfaceSymbol LegacyCompressorBase::Symbol
static
Initial value:
{ XO(
"Legacy Compressor") }

Definition at line 28 of file LegacyCompressorBase.h.

Referenced by GetSymbol().

◆ Threshold

constexpr EffectParameter LegacyCompressorBase::Threshold
staticconstexprprotected
Initial value:
{
&LegacyCompressorBase::mThresholdDB, L"Threshold", -12.0, -60.0, -1.0, 1
}

Definition at line 93 of file LegacyCompressorBase.h.

Referenced by Parameters(), and EffectLegacyCompressor::PopulateOrExchange().

◆ UsePeak

constexpr EffectParameter LegacyCompressorBase::UsePeak
staticconstexprprotected
Initial value:
{
&LegacyCompressorBase::mUsePeak, L"UsePeak", false, false, true, 1
}

Definition at line 116 of file LegacyCompressorBase.h.

Referenced by Parameters(), and EffectLegacyCompressor::PopulateOrExchange().


The documentation for this class was generated from the following files: