Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
EffectFindClipping Class Referencefinal

Locates clipping and inserts labels when found. More...

#include <FindClipping.h>

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

Public Member Functions

 EffectFindClipping ()
 
virtual ~EffectFindClipping ()
 
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...
 
bool Process (EffectInstance &instance, EffectSettings &settings) override
 Actually do the effect here. More...
 
std::unique_ptr< EffectUIValidatorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
 Add controls to effect panel; always succeeds. More...
 
void DoPopulateOrExchange (ShuttleGui &S, EffectSettingsAccess &access)
 
bool TransferDataToWindow (const EffectSettings &settings) override
 Update controls for the settings. More...
 
bool TransferDataFromWindow (EffectSettings &settings) override
 Update the given settings from controls. More...
 
- Public Member Functions inherited from StatefulEffect
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 ()
 Call once to set up state for whole list of tracks to be processed. More...
 
virtual bool Process (EffectInstance &instance, EffectSettings &settings)=0
 Actually do the effect here. More...
 
virtual bool RealtimeInitialize (EffectSettings &settings, double sampleRate)
 
virtual bool RealtimeAddProcessor (EffectSettings &settings, unsigned numChannels, float sampleRate)
 
virtual bool RealtimeSuspend ()
 
virtual bool RealtimeResume ()
 
virtual bool RealtimeProcessStart (EffectSettings &settings)
 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
 
- 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
 
EffectType GetType () const override
 Type determines how it behaves. More...
 
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...
 
bool LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 Change settings to a user-named preset. More...
 
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...
 
bool LoadFactoryPreset (int id, EffectSettings &settings) const override
 Change settings to the preset whose name is GetFactoryPresets()[id] More...
 
bool LoadFactoryDefaults (EffectSettings &settings) const override
 Change settings back to "factory default". More...
 
unsigned GetAudioInCount () const override
 How many input buffers to allocate at once. More...
 
unsigned GetAudioOutCount () const override
 How many output buffers to allocate at once. More...
 
virtual const EffectParameterMethodsParameters () const
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, bool forceModal=false) override
 
std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
 Adds controls to a panel that is given as the parent window of S More...
 
bool IsGraphicalUI () override
 
bool ValidateUI (EffectSettings &) override
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets (const EffectSettings &settings) const override
 
void ImportPresets (EffectSettings &settings) override
 
bool HasOptions () override
 
void ShowOptions () override
 
const EffectSettingsManagerGetDefinition () const override
 
virtual NumericFormatSymbol GetSelectionFormat ()
 
int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false) override
 Usually applies factory to self and given access. More...
 
bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const override
 
bool LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const override
 
bool IsBatchProcessing () const override
 
void SetBatchProcessing () override
 
void UnsetBatchProcessing () override
 
bool TransferDataToWindow (const EffectSettings &settings) override
 Update controls for the settings. More...
 
bool TransferDataFromWindow (EffectSettings &settings) override
 Update the given settings from controls. More...
 
unsigned TestUIFlags (unsigned mask)
 
bool Delegate (Effect &delegate, EffectSettings &settings)
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={}) const
 
bool EnableApply (bool enable=true)
 
wxWindow * GetUIParent ()
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
virtual int ShowClientInterface (wxWindow &parent, wxDialog &dialog, bool forceModal=false)=0
 
virtual bool IsGraphicalUI ()=0
 
virtual std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access)=0
 Adds controls to a panel that is given as the parent window of S More...
 
virtual bool CanExportPresets ()=0
 
virtual void ExportPresets (const EffectSettings &settings) const =0
 
virtual void ImportPresets (EffectSettings &settings)=0
 
virtual bool HasOptions ()=0
 
virtual void ShowOptions ()=0
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual const EffectSettingsManagerGetDefinition () const =0
 
virtual int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)=0
 Usually applies factory to self and given access. More...
 
virtual void Preview (EffectSettingsAccess &access, bool dryOnly)=0
 
virtual bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0
 
virtual bool 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, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={}, const EffectSettingsAccessPtr &pAccess=nullptr)=0
 Unfortunately complicated dual-use function. More...
 
virtual bool TransferDataToWindow (const EffectSettings &settings)=0
 Update controls for the settings. More...
 
virtual bool TransferDataFromWindow (EffectSettings &settings)=0
 Update the given settings from controls. More...
 
- 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...
 
virtual unsigned GetAudioInCount () const =0
 How many input buffers to allocate at once. More...
 
virtual unsigned GetAudioOutCount () const =0
 How many output buffers to allocate at once. More...
 
virtual int GetMidiInCount () const
 Function that has not yet found a use. More...
 
virtual int GetMidiOutCount () const
 Function that has not yet found a use. 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...
 
- 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 EffectFindClippingFetchParameters (EffectFindClipping &e, EffectSettings &)
 
- Static Public Member Functions inherited from Effect
static EffectFetchParameters (Effect &e, EffectSettings &)
 
static void IncEffectCounter ()
 
- 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 { XO("Find Clipping") }
 
- 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>")
 

Private Member Functions

bool ProcessOne (LabelTrack *lt, int count, const WaveTrack *wt, sampleCount start, sampleCount len)
 
const EffectParameterMethodsParameters () const override
 

Private Attributes

int mStart
 Using int rather than sampleCount because values are only ever small numbers. More...
 
int mStop
 Using int rather than sampleCount because values are only ever small numbers. More...
 
EffectSettingsAccessPtr mpAccess
 

Static Private Attributes

static constexpr EffectParameter Start
 
static constexpr EffectParameter Stop
 

Additional Inherited Members

- Public Types inherited from Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Public Types inherited from EffectPlugin
using EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess >
 
- Public Types inherited from EffectDefinitionInterface
enum class  RealtimeSince : unsigned { Never , Since_3_2 , Always }
 In which versions of Audacity was an effect realtime capable? More...
 
- Protected Member Functions inherited from Effect
bool EnablePreview (bool enable=true)
 
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...
 
virtual std::unique_ptr< EffectUIValidatorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access)
 Add controls to effect panel; always succeeds. 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, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
 
void CopyInputTracks (bool allSyncLockSelected=false)
 
std::shared_ptr< AddedAnalysisTrackAddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
- Protected Member Functions inherited from EffectBase
void Preview (EffectSettingsAccess &access, bool dryOnly) override
 
bool DoEffect (EffectSettings &settings, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent, const EffectDialogFactory &dialogFactory, const EffectSettingsAccessPtr &pAccess) override
 Unfortunately complicated dual-use function. More...
 
virtual bool CheckWhetherSkipEffect (const EffectSettings &settings) const =0
 After Init(), tell whether Process() should be skipped. More...
 
virtual double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const =0
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing () const
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 
virtual bool ValidateUI (EffectSettings &settings)=0
 
virtual bool CloseUI ()=0
 
- Protected Attributes inherited from Effect
wxWeakRef< wxDialog > mHostUIDialog
 This smart pointer tracks the lifetime of the dialog. More...
 
wxWindow * mUIParent {}
 
- Protected Attributes inherited from EffectBase
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0 {}
 
double mT1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 
- Protected Attributes inherited from EffectUIClientInterface
friend EffectUIValidator
 
friend DefaultEffectUIValidator
 
- Static Protected Attributes inherited from EffectBase
static int nEffectsDone = 0
 

Detailed Description

Locates clipping and inserts labels when found.

Definition at line 22 of file FindClipping.h.

Constructor & Destructor Documentation

◆ EffectFindClipping()

EffectFindClipping::EffectFindClipping ( )

Definition at line 50 of file FindClipping.cpp.

51{
52 Parameters().Reset(*this);
53}
const EffectParameterMethods & Parameters() const override
virtual void Reset(Effect &effect) const =0

References Parameters(), and EffectParameterMethods::Reset().

Referenced by Parameters().

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

◆ ~EffectFindClipping()

EffectFindClipping::~EffectFindClipping ( )
virtual

Definition at line 55 of file FindClipping.cpp.

56{
57}

Member Function Documentation

◆ DoPopulateOrExchange()

void EffectFindClipping::DoPopulateOrExchange ( ShuttleGui S,
EffectSettingsAccess access 
)

Definition at line 224 of file FindClipping.cpp.

226{
227 mpAccess = access.shared_from_this();
228 S.StartMultiColumn(2, wxALIGN_CENTER);
229 {
230 S
231 .Validator<IntegerValidator<int>>(
232 &mStart, NumValidatorStyle::DEFAULT, Start.min)
233 .TieTextBox(XXO("&Start threshold (samples):"), mStart, 10);
234
235 S
236 .Validator<IntegerValidator<int>>(
237 &mStop, NumValidatorStyle::DEFAULT, Stop.min)
238 .TieTextBox(XXO("St&op threshold (samples):"), mStop, 10);
239 }
240 S.EndMultiColumn();
241}
#define XXO(s)
Definition: Internat.h:44
#define S(N)
Definition: ToChars.cpp:64
static constexpr EffectParameter Start
Definition: FindClipping.h:66
int mStop
Using int rather than sampleCount because values are only ever small numbers.
Definition: FindClipping.h:60
EffectSettingsAccessPtr mpAccess
Definition: FindClipping.h:62
static constexpr EffectParameter Stop
Definition: FindClipping.h:68
int mStart
Using int rather than sampleCount because values are only ever small numbers.
Definition: FindClipping.h:59
const Type min
Minimum value.
Definition: Shuttle.h:30

References EffectParameter< Structure, Member, Type, Value >::min, mpAccess, mStart, mStop, S, Start, Stop, and XXO.

Referenced by PopulateOrExchange(), TransferDataFromWindow(), and TransferDataToWindow().

Here is the caller graph for this function:

◆ FetchParameters()

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

Definition at line 26 of file FindClipping.h.

26{ return &e; }

◆ GetDescription()

TranslatableString EffectFindClipping::GetDescription ( ) const
overridevirtual

Reimplemented from Effect.

Definition at line 66 of file FindClipping.cpp.

67{
68 return XO("Creates labels where clipping is detected");
69}
#define XO(s)
Definition: Internat.h:31

References XO.

◆ GetSymbol()

ComponentInterfaceSymbol EffectFindClipping::GetSymbol ( ) const
overridevirtual

Reimplemented from Effect.

Definition at line 61 of file FindClipping.cpp.

62{
63 return Symbol;
64}
static const ComponentInterfaceSymbol Symbol
Definition: FindClipping.h:27

References Symbol.

◆ GetType()

EffectType EffectFindClipping::GetType ( ) const
overridevirtual

Type determines how it behaves.

Reimplemented from Effect.

Definition at line 78 of file FindClipping.cpp.

79{
80 return EffectTypeAnalyze;
81}
@ EffectTypeAnalyze

References EffectTypeAnalyze.

◆ ManualPage()

ManualPageID EffectFindClipping::ManualPage ( ) const
overridevirtual

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

Reimplemented from EffectDefinitionInterface.

Definition at line 71 of file FindClipping.cpp.

72{
73 return L"Find_Clipping";
74}

◆ Parameters()

const EffectParameterMethods & EffectFindClipping::Parameters ( ) const
overrideprivatevirtual

Reimplemented from Effect.

Definition at line 37 of file FindClipping.cpp.

38{
40 Start, Stop
41 > parameters;
42 return parameters;
43}
Generates EffectParameterMethods overrides from variadic template arguments.

References EffectFindClipping(), Start, and Stop.

Referenced by EffectFindClipping().

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

◆ PopulateOrExchange()

std::unique_ptr< EffectUIValidator > EffectFindClipping::PopulateOrExchange ( ShuttleGui S,
EffectInstance instance,
EffectSettingsAccess access 
)
overridevirtual

Add controls to effect panel; always succeeds.

Returns
if not null, then return it from Effect::PopulateUI instead of a DefaultEffectUIValidator; default implementation returns null

Reimplemented from Effect.

Definition at line 217 of file FindClipping.cpp.

219{
220 DoPopulateOrExchange(S, access);
221 return nullptr;
222}
void DoPopulateOrExchange(ShuttleGui &S, EffectSettingsAccess &access)

References DoPopulateOrExchange(), and S.

Here is the call graph for this function:

◆ Process()

bool EffectFindClipping::Process ( EffectInstance instance,
EffectSettings settings 
)
overridevirtual

Actually do the effect here.

Returns
success

Implements StatefulEffectBase.

Definition at line 85 of file FindClipping.cpp.

86{
87 std::shared_ptr<AddedAnalysisTrack> addedTrack;
88 std::optional<ModifiedAnalysisTrack> modifiedTrack;
89 const wxString name{ _("Clipping") };
90
91 auto clt = *inputTracks()->Any< const LabelTrack >().find_if(
92 [&]( const Track *track ){ return track->GetName() == name; } );
93
94 LabelTrack *lt{};
95 if (!clt)
96 addedTrack = (AddAnalysisTrack(name)), lt = addedTrack->get();
97 else
98 modifiedTrack.emplace(ModifyAnalysisTrack(clt, name)),
99 lt = modifiedTrack->get();
100
101 int count = 0;
102
103 // JC: Only process selected tracks.
104 for (auto t : inputTracks()->Selected< const WaveTrack >()) {
105 double trackStart = t->GetStartTime();
106 double trackEnd = t->GetEndTime();
107 double t0 = mT0 < trackStart ? trackStart : mT0;
108 double t1 = mT1 > trackEnd ? trackEnd : mT1;
109
110 if (t1 > t0) {
111 auto start = t->TimeToLongSamples(t0);
112 auto end = t->TimeToLongSamples(t1);
113 auto len = end - start;
114
115 if (!ProcessOne(lt, count, t, start, len)) {
116 return false;
117 }
118 }
119
120 count++;
121 }
122
123 // No cancellation, so commit the addition of the track.
124 if (addedTrack)
125 addedTrack->Commit();
126 if (modifiedTrack)
127 modifiedTrack->Commit();
128 return true;
129}
const TranslatableString name
Definition: Distortion.cpp:82
#define _(s)
Definition: Internat.h:75
double mT1
Definition: EffectBase.h:107
const TrackList * inputTracks() const
Definition: EffectBase.h:102
double mT0
Definition: EffectBase.h:106
bool ProcessOne(LabelTrack *lt, int count, const WaveTrack *wt, sampleCount start, sampleCount len)
ModifiedAnalysisTrack ModifyAnalysisTrack(const LabelTrack *pOrigTrack, const wxString &name=wxString())
Definition: Effect.cpp:855
std::shared_ptr< AddedAnalysisTrack > AddAnalysisTrack(const wxString &name=wxString())
Definition: Effect.cpp:804
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:89
double GetStartTime() const override
Definition: LabelTrack.cpp:346
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
wxString GetName() const
Definition: Track.h:466
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1435
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1452
A Track that contains audio waveform data.
Definition: WaveTrack.h:57
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References _, Effect::AddAnalysisTrack(), TrackList::Any(), PackedArray::end(), Track::GetName(), LabelTrack::GetStartTime(), EffectBase::inputTracks(), Effect::ModifyAnalysisTrack(), EffectBase::mT0, EffectBase::mT1, name, ProcessOne(), and TrackList::Selected().

Here is the call graph for this function:

◆ ProcessOne()

bool EffectFindClipping::ProcessOne ( LabelTrack lt,
int  count,
const WaveTrack wt,
sampleCount  start,
sampleCount  len 
)
private

Definition at line 131 of file FindClipping.cpp.

136{
137 bool bGoodResult = true;
138 size_t blockSize = (mStart * 1000);
139
140 if (len < mStart) {
141 return true;
142 }
143
144 Floats buffer;
145 try {
146 // mStart should be positive.
147 // if we are throwing bad_alloc and mStart is negative, find out why.
148 if (mStart < 0 || (int)blockSize < mStart)
149 // overflow
150 throw std::bad_alloc{};
151 buffer.reinit(blockSize);
152 }
153 catch( const std::bad_alloc & ) {
154 Effect::MessageBox( XO("Requested value exceeds memory capacity.") );
155 return false;
156 }
157
158 float *ptr = buffer.get();
159
160 decltype(len) s = 0, startrun = 0, stoprun = 0, samps = 0;
161 decltype(blockSize) block = 0;
162 double startTime = -1.0;
163
164 while (s < len) {
165 if (block == 0) {
166 if (TrackProgress(count,
167 s.as_double() /
168 len.as_double() )) {
169 bGoodResult = false;
170 break;
171 }
172
173 block = limitSampleBufferSize( blockSize, len - s );
174
175 wt->GetFloats(buffer.get(), start + s, block);
176 ptr = buffer.get();
177 }
178
179 float v = fabs(*ptr++);
180 if (v >= MAX_AUDIO) {
181 if (startrun == 0) {
182 startTime = wt->LongSamplesToTime(start + s);
183 samps = 0;
184 }
185 else {
186 stoprun = 0;
187 }
188 startrun++;
189 samps++;
190 }
191 else {
192 if (startrun >= mStart) {
193 stoprun++;
194 samps++;
195
196 if (stoprun >= mStop) {
197 lt->AddLabel(SelectedRegion(startTime,
198 wt->LongSamplesToTime(start + s - mStop)),
199 wxString::Format(wxT("%lld of %lld"), startrun.as_long_long(), (samps - mStop).as_long_long()));
200 startrun = 0;
201 stoprun = 0;
202 samps = 0;
203 }
204 }
205 else {
206 startrun = 0;
207 }
208 }
209
210 s++;
211 block--;
212 }
213
214 return bGoodResult;
215}
#define MAX_AUDIO
Definition: MemoryX.h:538
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:23
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:57
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={}) const
Definition: Effect.cpp:871
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:693
int AddLabel(const SelectedRegion &region, const wxString &title)
Definition: LabelTrack.cpp:952
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Retrieve samples from a track in floating-point format, regardless of the storage format.
Definition: SampleTrack.h:67
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
Definition: SampleTrack.cpp:47
Defines a selected portion of a project.
double as_double() const
Definition: SampleCount.h:45

References LabelTrack::AddLabel(), sampleCount::as_double(), SampleTrack::GetFloats(), limitSampleBufferSize(), SampleTrack::LongSamplesToTime(), MAX_AUDIO, Effect::MessageBox(), mStart, mStop, ArrayOf< X >::reinit(), Effect::TrackProgress(), and XO.

Referenced by Process().

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

◆ TransferDataFromWindow()

bool EffectFindClipping::TransferDataFromWindow ( EffectSettings settings)
overridevirtual

Update the given settings from controls.

Reimplemented from Effect.

Definition at line 252 of file FindClipping.cpp.

253{
255 // To do: eliminate this and just use validators for controls
257
258 return true;
259}
@ eIsGettingFromDialog
Definition: ShuttleGui.h:40
wxWindow * mUIParent
Definition: Effect.h:270
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628

References DoPopulateOrExchange(), eIsGettingFromDialog, mpAccess, Effect::mUIParent, and S.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool EffectFindClipping::TransferDataToWindow ( const EffectSettings settings)
overridevirtual

Update controls for the settings.

Reimplemented from Effect.

Definition at line 243 of file FindClipping.cpp.

244{
246 // To do: eliminate this and just use validators for controls
248
249 return true;
250}
@ eIsSettingToDialog
Definition: ShuttleGui.h:41

References DoPopulateOrExchange(), eIsSettingToDialog, mpAccess, Effect::mUIParent, and S.

Here is the call graph for this function:

Member Data Documentation

◆ mpAccess

EffectSettingsAccessPtr EffectFindClipping::mpAccess
private

◆ mStart

int EffectFindClipping::mStart
private

Using int rather than sampleCount because values are only ever small numbers.

Definition at line 59 of file FindClipping.h.

Referenced by DoPopulateOrExchange(), and ProcessOne().

◆ mStop

int EffectFindClipping::mStop
private

Using int rather than sampleCount because values are only ever small numbers.

Definition at line 60 of file FindClipping.h.

Referenced by DoPopulateOrExchange(), and ProcessOne().

◆ Start

constexpr EffectParameter EffectFindClipping::Start
staticconstexprprivate
Initial value:
L"Duty Cycle Start", 3, 1, INT_MAX, 1 }

Definition at line 66 of file FindClipping.h.

Referenced by DoPopulateOrExchange(), and Parameters().

◆ Stop

constexpr EffectParameter EffectFindClipping::Stop
staticconstexprprivate
Initial value:
L"Duty Cycle End", 3, 1, INT_MAX, 1 }

Definition at line 68 of file FindClipping.h.

Referenced by DoPopulateOrExchange(), and Parameters().

◆ Symbol

const ComponentInterfaceSymbol EffectFindClipping::Symbol { XO("Find Clipping") }
static

Definition at line 27 of file FindClipping.h.

Referenced by GetSymbol().


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