Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
EffectBase Class Referenceabstract

Base class for many of the effects in Audacity. More...

#include <EffectBase.h>

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

Public Member Functions

 EffectBase ()
 
 ~EffectBase () override
 
bool IsLinearEffect () const
 
bool PreviewsFullSelection () const
 
void SetTracks (TrackList *pTracks)
 
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 ReplaceProcessedTracks (const bool bGoodResult)
 
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 bool SaveSettings (const EffectSettings &settings, CommandParameters &parms) const =0
 Store settings as keys and values. More...
 
virtual bool LoadSettings (const CommandParameters &parms, EffectSettings &settings) const =0
 Restore settings from keys and values. More...
 
virtual RegistryPaths GetFactoryPresets () const =0
 Report names of factory presets. More...
 
virtual OptionalMessage LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const =0
 
virtual bool SaveUserPreset (const RegistryPath &name, const EffectSettings &settings) const =0
 Save settings in the configuration file as a user-named preset. More...
 
virtual OptionalMessage LoadFactoryPreset (int id, EffectSettings &settings) const =0
 
virtual OptionalMessage LoadFactoryDefaults (EffectSettings &settings) const =0
 
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 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...
 

Public Attributes

TrackListmTracks {}
 
int mNumTracks {}
 
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
double mT0 {}
 
double mT1 {}
 
bool mIsPreview { false }
 

Protected Member Functions

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

std::shared_ptr< TrackListmOutputTracks
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 

Static Protected Attributes

static int nEffectsDone = 0
 

Private Member Functions

double GetDefaultDuration ()
 

Private Attributes

bool mIsLinearEffect { false }
 
bool mPreviewFullSelection { false }
 
std::vector< Track * > mIMap
 
std::vector< Track * > mOMap
 
int mNumGroups {}
 

Friends

class Effect
 

Additional Inherited Members

- 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...
 
- 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>")
 

Detailed Description

Base class for many of the effects in Audacity.

Definition at line 26 of file EffectBase.h.

Constructor & Destructor Documentation

◆ EffectBase()

EffectBase::EffectBase ( )

Definition at line 34 of file EffectBase.cpp.

35{
36 // PRL: I think this initialization of mProjectRate doesn't matter
37 // because it is always reassigned in DoEffect before it is used
38 // STF: but can't call AudioIOBase::GetOptimalSupportedSampleRate() here.
39 // (Which is called to compute the default-default value.) (Bug 2280)
41}
double mProjectRate
Definition: EffectBase.h:115
bool ReadWithDefault(T *pVar, const T &defaultValue) const
overload of ReadWithDefault returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:206
PROJECT_RATE_API IntSetting DefaultSampleRate

References QualitySettings::DefaultSampleRate, mProjectRate, and Setting< T >::ReadWithDefault().

Here is the call graph for this function:

◆ ~EffectBase()

EffectBase::~EffectBase ( )
overridedefault

Member Function Documentation

◆ BeginPreview()

std::any EffectBase::BeginPreview ( const EffectSettings settings)
virtual

Called when Preview() starts, to allow temporary effect state changes.

default returns a null

Returns
will undo its effects in its destructor before Preview() finishes

Reimplemented in EffectAmplify, and EffectTimeScale.

Definition at line 316 of file EffectBase.cpp.

317{
318 return {};
319}

Referenced by EffectPreview().

Here is the caller graph for this function:

◆ CalcPreviewInputLength()

virtual double EffectBase::CalcPreviewInputLength ( const EffectSettings settings,
double  previewLength 
) const
pure virtual

Implemented in Effect, EffectChangeSpeed, EffectPaulstretch, EffectTimeScale, and EffectTruncSilence.

Referenced by EffectPreview().

Here is the caller graph for this function:

◆ CheckWhetherSkipEffect()

virtual bool EffectBase::CheckWhetherSkipEffect ( const EffectSettings settings) const
protectedpure virtual

After Init(), tell whether Process() should be skipped.

Implemented in Effect, EffectBassTreble, EffectChangeSpeed, EffectClickRemoval, EffectNoiseRemoval, and EffectNormalize.

Referenced by DoEffect().

Here is the caller graph for this function:

◆ CountWaveTracks()

void EffectBase::CountWaveTracks ( )

Definition at line 310 of file EffectBase.cpp.

311{
312 mNumTracks = mTracks->Selected< const WaveTrack >().size();
314}
int mNumTracks
Definition: EffectBase.h:113
TrackList * mTracks
Definition: EffectBase.h:112
int mNumGroups
Definition: EffectBase.h:138
auto SelectedLeaders() -> TrackIterRange< TrackType >
Definition: Track.h:1364
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1330
A Track that contains audio waveform data.
Definition: WaveTrack.h:51

References mNumGroups, mNumTracks, mTracks, TrackList::Selected(), TrackList::SelectedLeaders(), and size.

Referenced by DoEffect(), and EffectPreview().

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

◆ DefaultInstanceFinder()

auto EffectBase::DefaultInstanceFinder ( EffectPlugin plugin)
static

Definition at line 331 of file EffectBase.cpp.

332{
333 return [&plugin](auto&) { return FindInstance(plugin); };
334}
static std::optional< InstancePointer > FindInstance(EffectPlugin &plugin)
Definition: EffectBase.cpp:321

Referenced by Effect::Delegate().

Here is the caller graph for this function:

◆ DoEffect()

bool EffectBase::DoEffect ( EffectSettings settings,
const InstanceFinder finder,
double  projectRate,
TrackList list,
WaveTrackFactory factory,
NotifyingSelectedRegion selectedRegion,
unsigned  flags,
const EffectSettingsAccessPtr pAccess 
)
overridevirtual

Will only operate on tracks that have the "selected" flag set to true, which is consistent with Audacity's standard UI, and only when finder succeeds

Returns
true on success
Parameters
settingsAlways given; only for processing
pAccessSometimes given; only for UI

Implements EffectPlugin.

Definition at line 54 of file EffectBase.cpp.

62{
63 auto cleanup0 = valueRestorer(mUIFlags, flags);
64 wxASSERT(selectedRegion.duration() >= 0.0);
65
66 mOutputTracks.reset();
67
69 mProjectRate = projectRate;
70
71 SetTracks(list);
72 // Don't hold a dangling pointer when done
73 Finally Do([&]{ SetTracks(nullptr); });
74
75 // This is for performance purposes only, no additional recovery implied
76 auto &pProject = *const_cast<AudacityProject*>(FindProject()); // how to remove this const_cast?
77 TransactionScope trans(pProject, "Effect");
78
79 // Update track/group counts
81
82 bool isSelection = false;
83
84 auto duration = 0.0;
89
90 WaveTrack *newTrack{};
91 bool success = false;
92 auto oldDuration = duration;
93
94 auto cleanup = finally( [&] {
95 if (!success) {
96 if (newTrack) {
97 mTracks->Remove(newTrack);
98 }
99 // On failure, restore the old duration setting
100 settings.extra.SetDuration(oldDuration);
101 }
102 else
103 trans.Commit();
104
105 ReplaceProcessedTracks( false );
106 mPresetNames.clear();
107 } );
108
109 // We don't yet know the effect type for code in the Nyquist Prompt, so
110 // assume it requires a track and handle errors when the effect runs.
111 if ((GetType() == EffectTypeGenerate || GetPath() == NYQUIST_PROMPT_ID) && (mNumTracks == 0)) {
112 auto track = mFactory->Create();
114 newTrack = mTracks->Add(track);
115 newTrack->SetSelected(true);
116 }
117
118 mT0 = selectedRegion.t0();
119 mT1 = selectedRegion.t1();
120 if (mT1 > mT0)
121 {
122 // there is a selection: let's fit in there...
123 // MJS: note that this is just for the TTC and is independent of the track rate
124 // but we do need to make sure we have the right number of samples at the project rate
125 double quantMT0 = QUANTIZED_TIME(mT0, mProjectRate);
126 double quantMT1 = QUANTIZED_TIME(mT1, mProjectRate);
127 duration = quantMT1 - quantMT0;
128 isSelection = true;
129 mT1 = mT0 + duration;
130 }
131
132 // This is happening inside EffectSettingsAccess::ModifySettings
133 auto newFormat = isSelection
136 auto updater = [&](EffectSettings &settings) {
137 settings.extra.SetDuration(duration);
138 settings.extra.SetDurationFormat( newFormat );
139 return nullptr;
140 };
141 // Update our copy of settings; update the EffectSettingsAccess too,
142 // if we are going to show a dialog
144 if (pAccess)
145 pAccess->ModifySettings(updater);
146
147#ifdef EXPERIMENTAL_SPECTRAL_EDITING
148 mF0 = selectedRegion.f0();
149 mF1 = selectedRegion.f1();
151 mPresetNames.push_back(L"control-f0");
153 mPresetNames.push_back(L"control-f1");
154
155#endif
157
158 // Allow the dialog factory to fill this in, but it might not
159 std::shared_ptr<EffectInstance> pInstance;
160
161 if (IsInteractive()) {
162 if (!finder)
163 return false;
164 else if (auto result = finder(settings))
165 pInstance = *result;
166 else
167 return false;
168 }
169
170 auto pInstanceEx = std::dynamic_pointer_cast<EffectInstanceEx>(pInstance);
171 if (!pInstanceEx) {
172 // Path that skipped the dialog factory -- effect may be non-interactive
173 // or this is batch mode processing or repeat of last effect with stored
174 // settings.
175 pInstanceEx = std::dynamic_pointer_cast<EffectInstanceEx>(MakeInstance());
176 // Note: Init may read parameters from preferences
177 if (!pInstanceEx || !pInstanceEx->Init())
178 return false;
179 }
180
181
182 // If the dialog was shown, then it has been closed without errors or
183 // cancellation, and any change of duration has been saved in the config file
184
185 bool returnVal = true;
186 bool skipFlag = CheckWhetherSkipEffect(settings);
187 if (skipFlag == false)
188 {
189 using namespace BasicUI;
190 auto name = GetName();
191 auto progress = MakeProgress(
192 name,
193 XO("Applying %s...").Format( name ),
195 );
196 auto vr = valueRestorer( mProgress, progress.get() );
197
198 assert(pInstanceEx); // null check above
199 returnVal = pInstanceEx->Process(settings);
200 }
201
202 if (returnVal && (mT1 >= mT0 ))
203 {
204 selectedRegion.setTimes(mT0, mT1);
205 }
206
207 success = returnVal;
208 return returnVal;
209}
const TranslatableString name
Definition: Distortion.cpp:76
const RegistryPath & CurrentSettingsGroup()
Component of a configuration key path, for last-used destructive settings.
@ EffectTypeGenerate
XO("Cut/Copy/Paste")
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
Definition: MemoryX.h:251
#define QUANTIZED_TIME(time, rate)
Definition: MemoryX.h:558
#define NYQUIST_PROMPT_ID
static Settings & settings()
Definition: TrackInfo.cpp:83
static CustomUpdaterValue updater
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
virtual PluginPath GetPath() const =0
TranslatableString GetName() const
double mT1
Definition: EffectBase.h:119
std::shared_ptr< TrackList > mOutputTracks
Definition: EffectBase.h:97
WaveTrackFactory * mFactory
Definition: EffectBase.h:117
void CountWaveTracks()
Definition: EffectBase.cpp:310
virtual bool CheckWhetherSkipEffect(const EffectSettings &settings) const =0
After Init(), tell whether Process() should be skipped.
BasicUI::ProgressDialog * mProgress
Definition: EffectBase.h:114
wxArrayString mPresetNames
Definition: EffectBase.h:102
double GetDefaultDuration()
Definition: EffectBase.cpp:45
double mT0
Definition: EffectBase.h:118
unsigned mUIFlags
Definition: EffectBase.h:103
void SetTracks(TrackList *pTracks)
Definition: EffectBase.h:36
void ReplaceProcessedTracks(const bool bGoodResult)
Definition: EffectBase.cpp:224
const AudacityProject * FindProject() const
Definition: EffectBase.cpp:303
virtual EffectType GetType() const =0
Type determines how it behaves.
virtual bool IsInteractive() const =0
Whether the effect needs a dialog for entry of settings.
virtual std::shared_ptr< EffectInstance > MakeInstance() const =0
Make an object maintaining short-term state of an Effect.
virtual const EffectSettingsManager & GetDefinition() const =0
static const RegistryPath & DurationKey()
Abstract base class used in importing a file.
double t1() const
Definition: ViewInfo.h:36
double f1() const
Definition: ViewInfo.h:38
double duration() const
Definition: ViewInfo.h:41
bool setTimes(double t0, double t1)
Definition: ViewInfo.cpp:51
double f0() const
Definition: ViewInfo.h:37
double t0() const
Definition: ViewInfo.h:35
static const int UndefinedFrequency
wxString MakeUniqueTrackName(const wxString &baseTrackName) const
Returns string that contains baseTrackName, but is guaranteed to be unique among other tracks in that...
Definition: Track.cpp:442
TrackKind * Add(const std::shared_ptr< TrackKind > &t)
Definition: Track.h:1446
TrackNodePointer Remove(Track *t)
Remove the Track and return an iterator to what followed it.
Definition: Track.cpp:706
RAII for a database transaction, possibly nested.
std::shared_ptr< WaveTrack > Create()
Creates an unnamed empty WaveTrack with default sample format and default rate.
Definition: WaveTrack.cpp:182
static wxString GetDefaultAudioTrackNamePreference()
Definition: WaveTrack.cpp:164
@ ProgressShowCancel
Definition: BasicUI.h:141
std::unique_ptr< ProgressDialog > MakeProgress(const TranslatableString &title, const TranslatableString &message, unsigned flags=(ProgressShowStop|ProgressShowCancel), const TranslatableString &remainingLabelText={})
Create and display a progress dialog.
Definition: BasicUI.h:289
NUMERIC_FORMATS_API NumericFormatSymbol DefaultSelectionFormat()
NUMERIC_FORMATS_API NumericFormatSymbol TimeAndSampleFormat()
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)
static RegisteredToolbarFactory factory
Externalized state of a plug-in.
"finally" as in The C++ Programming Language, 4th ed., p. 358 Useful for defining ad-hoc RAII actions...
Definition: MemoryX.h:173

References TrackList::Add(), CheckWhetherSkipEffect(), TransactionScope::Commit(), CountWaveTracks(), WaveTrackFactory::Create(), CurrentSettingsGroup(), NumericConverterFormats::DefaultSelectionFormat(), NotifyingSelectedRegion::duration(), EffectSettingsExtra::DurationKey(), EffectTypeGenerate, NotifyingSelectedRegion::f0(), NotifyingSelectedRegion::f1(), cloud::factory, FindProject(), PluginSettings::GetConfig(), WaveTrack::GetDefaultAudioTrackNamePreference(), GetDefaultDuration(), EffectPlugin::GetDefinition(), ComponentInterface::GetName(), ComponentInterface::GetPath(), EffectDefinitionInterface::GetType(), EffectDefinitionInterface::IsInteractive(), EffectInstanceFactory::MakeInstance(), BasicUI::MakeProgress(), TrackList::MakeUniqueTrackName(), mFactory, mNumTracks, mOutputTracks, mPresetNames, mProgress, mProjectRate, mT0, mT1, mTracks, mUIFlags, name, NYQUIST_PROMPT_ID, PluginSettings::Private, BasicUI::ProgressShowCancel, QUANTIZED_TIME, TrackList::Remove(), ReplaceProcessedTracks(), NotifyingSelectedRegion::setTimes(), settings(), SetTracks(), NotifyingSelectedRegion::t0(), NotifyingSelectedRegion::t1(), NumericConverterFormats::TimeAndSampleFormat(), SelectedRegion::UndefinedFrequency, updater, valueRestorer(), and XO().

Referenced by Effect::Delegate().

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

◆ FindInstance()

auto EffectBase::FindInstance ( EffectPlugin plugin)
static

Definition at line 321 of file EffectBase.cpp.

323{
324 auto result = plugin.MakeInstance();
325 if (auto pInstanceEx = std::dynamic_pointer_cast<EffectInstanceEx>(result)
326 ; pInstanceEx && pInstanceEx->Init())
327 return { pInstanceEx };
328 return {};
329}

Referenced by EffectUIHost::InitializeInstance().

Here is the caller graph for this function:

◆ FindProject()

const AudacityProject * EffectBase::FindProject ( ) const
protected

Definition at line 303 of file EffectBase.cpp.

304{
305 if (!inputTracks())
306 return nullptr;
307 return inputTracks()->GetOwner();
308}
const TrackList * inputTracks() const
Definition: EffectBase.h:94
AudacityProject * GetOwner()
Definition: Track.h:1249

References TrackList::GetOwner(), and inputTracks().

Referenced by Effect::CopyInputTracks(), DoEffect(), Effect::GetSelectionFormat(), EffectEqualization::Init(), NyquistEffect::Init(), Generator::Process(), NyquistEffect::Process(), EffectTwoPassSimpleMono::Process(), EffectTruncSilence::ProcessIndependently(), and PerTrackEffect::ProcessPass().

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

◆ GetDefaultDuration()

double EffectBase::GetDefaultDuration ( )
private

Definition at line 45 of file EffectBase.cpp.

46{
47 return 30.0;
48}

Referenced by DoEffect().

Here is the caller graph for this function:

◆ inputTracks()

const TrackList * EffectBase::inputTracks ( ) const
inlineprotected

◆ IsLinearEffect()

bool EffectBase::IsLinearEffect ( ) const
inline

Definition at line 33 of file EffectBase.h.

33{ return mIsLinearEffect; }
bool mIsLinearEffect
Definition: EffectBase.h:132

Referenced by EffectPreview().

Here is the caller graph for this function:

◆ IsPreviewing()

bool EffectBase::IsPreviewing ( ) const
inlineprotected

Definition at line 89 of file EffectBase.h.

89{ return mIsPreview; }
bool mIsPreview
Definition: EffectBase.h:120

Referenced by NyquistEffect::Process(), EffectPaulstretch::ProcessOne(), and PerTrackEffect::ProcessPass().

Here is the caller graph for this function:

◆ PreviewsFullSelection()

bool EffectBase::PreviewsFullSelection ( ) const
inline

Definition at line 34 of file EffectBase.h.

34{ return mPreviewFullSelection; }
bool mPreviewFullSelection
Definition: EffectBase.h:133

Referenced by EffectPreview().

Here is the caller graph for this function:

◆ ReplaceProcessedTracks()

void EffectBase::ReplaceProcessedTracks ( const bool  bGoodResult)

Definition at line 224 of file EffectBase.cpp.

225{
226 if (!bGoodResult) {
227 // Free resources, unless already freed.
228
229 // Processing failed or was cancelled so throw away the processed tracks.
230 if ( mOutputTracks )
231 mOutputTracks->Clear();
232
233 // Reset map
234 mIMap.clear();
235 mOMap.clear();
236
237 //TODO:undo the non-gui ODTask transfer
238 return;
239 }
240
241 // Assume resources need to be freed.
242 wxASSERT(mOutputTracks); // Make sure we at least did the CopyInputTracks().
243
244 auto iterOut = mOutputTracks->ListOfTracks::begin(),
245 iterEnd = mOutputTracks->ListOfTracks::end();
246
247 size_t cnt = mOMap.size();
248 size_t i = 0;
249
250 for (; iterOut != iterEnd; ++i) {
251 ListOfTracks::value_type o = *iterOut;
252 // If tracks were removed from mOutputTracks, then there will be
253 // tracks in the map that must be removed from mTracks.
254 while (i < cnt && mOMap[i] != o.get()) {
255 const auto t = mIMap[i];
256 if (t) {
257 mTracks->Remove(t);
258 }
259 i++;
260 }
261
262 // This should never happen
263 wxASSERT(i < cnt);
264
265 // Remove the track from the output list...don't DELETE it
266 iterOut = mOutputTracks->erase(iterOut);
267
268 const auto t = mIMap[i];
269 if (t == NULL)
270 {
271 // This track is a NEW addition to output tracks; add it to mTracks
272 mTracks->Add( o );
273 }
274 else
275 {
276 // Replace mTracks entry with the NEW track
277 mTracks->Replace(t, o);
278 }
279 }
280
281 // If tracks were removed from mOutputTracks, then there may be tracks
282 // left at the end of the map that must be removed from mTracks.
283 while (i < cnt) {
284 const auto t = mIMap[i];
285 if (t) {
286 mTracks->Remove(t);
287 }
288 i++;
289 }
290
291 // Reset map
292 mIMap.clear();
293 mOMap.clear();
294
295 // Make sure we processed everything
296 wxASSERT(mOutputTracks->empty());
297
298 // The output list is no longer needed
299 mOutputTracks.reset();
300 nEffectsDone++;
301}
std::vector< Track * > mOMap
Definition: EffectBase.h:136
std::vector< Track * > mIMap
Definition: EffectBase.h:135
static int nEffectsDone
Definition: EffectBase.h:92
ListOfTracks::value_type Replace(Track *t, const ListOfTracks::value_type &with)
Definition: Track.cpp:632

References TrackList::Add(), mIMap, mOMap, mOutputTracks, mTracks, nEffectsDone, TrackList::Remove(), and TrackList::Replace().

Referenced by DoEffect(), EffectTruncSilence::DoRemoval(), EffectPreview(), EffectTruncSilence::FindSilences(), EffectAutoDuck::Process(), EffectChangeSpeed::Process(), EffectClickRemoval::Process(), EffectEqualization::Process(), Generator::Process(), EffectLoudness::Process(), EffectNoiseReduction::Process(), EffectNoiseRemoval::Process(), EffectNormalize::Process(), NyquistEffect::Process(), EffectPaulstretch::Process(), EffectRepair::Process(), EffectRepeat::Process(), EffectReverse::Process(), EffectSBSMS::Process(), EffectSimpleMono::Process(), EffectStereoToMono::Process(), EffectTruncSilence::Process(), and EffectTwoPassSimpleMono::Process().

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

◆ SetLinearEffectFlag()

void EffectBase::SetLinearEffectFlag ( bool  linearEffectFlag)
protected

Definition at line 211 of file EffectBase.cpp.

212{
213 mIsLinearEffect = linearEffectFlag;
214}

References mIsLinearEffect.

Referenced by EffectBassTreble::EffectBassTreble(), EffectDistortion::EffectDistortion(), EffectEcho::EffectEcho(), EffectEqualization::EffectEqualization(), EffectLoudness::EffectLoudness(), EffectNoise::EffectNoise(), EffectPhaser::EffectPhaser(), EffectReverb::EffectReverb(), EffectSilence::EffectSilence(), EffectWahwah::EffectWahwah(), and NyquistEffect::Parse().

Here is the caller graph for this function:

◆ SetPreviewFullSelectionFlag()

void EffectBase::SetPreviewFullSelectionFlag ( bool  previewDurationFlag)
protected

Definition at line 216 of file EffectBase.cpp.

217{
218 mPreviewFullSelection = previewDurationFlag;
219}

References mPreviewFullSelection.

Referenced by NyquistEffect::Parse().

Here is the caller graph for this function:

◆ SetTracks()

void EffectBase::SetTracks ( TrackList pTracks)
inline

Definition at line 36 of file EffectBase.h.

36{ mTracks = pTracks; }

Referenced by DoEffect(), and EffectManager::PromptUser().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ Effect

friend class Effect
friend

Definition at line 106 of file EffectBase.h.

Member Data Documentation

◆ mFactory

WaveTrackFactory* EffectBase::mFactory {}

Definition at line 117 of file EffectBase.h.

Referenced by Effect::Delegate(), DoEffect(), and EffectPreview().

◆ mIMap

std::vector<Track*> EffectBase::mIMap
private

◆ mIsLinearEffect

bool EffectBase::mIsLinearEffect { false }
private

Definition at line 132 of file EffectBase.h.

Referenced by SetLinearEffectFlag().

◆ mIsPreview

bool EffectBase::mIsPreview { false }

Definition at line 120 of file EffectBase.h.

Referenced by EffectPreview().

◆ mNumGroups

int EffectBase::mNumGroups {}
private

◆ mNumTracks

int EffectBase::mNumTracks {}

◆ mOMap

std::vector<Track*> EffectBase::mOMap
private

◆ mOutputTracks

std::shared_ptr<TrackList> EffectBase::mOutputTracks
protected

◆ mPresetNames

wxArrayString EffectBase::mPresetNames
protected

Definition at line 102 of file EffectBase.h.

Referenced by DoEffect(), and NyquistEffect::Parse().

◆ mPreviewFullSelection

bool EffectBase::mPreviewFullSelection { false }
private

Definition at line 133 of file EffectBase.h.

Referenced by SetPreviewFullSelectionFlag().

◆ mProgress

BasicUI::ProgressDialog* EffectBase::mProgress {}

◆ mProjectRate

double EffectBase::mProjectRate {}

◆ mT0

double EffectBase::mT0 {}

◆ mT1

double EffectBase::mT1 {}

◆ mTracks

TrackList* EffectBase::mTracks {}

◆ mUIFlags

unsigned EffectBase::mUIFlags { 0 }
protected

Definition at line 103 of file EffectBase.h.

Referenced by Effect::Delegate(), DoEffect(), and Effect::TestUIFlags().

◆ nEffectsDone

int EffectBase::nEffectsDone = 0
staticprotected

Definition at line 92 of file EffectBase.h.

Referenced by NyquistEffect::Process(), and ReplaceProcessedTracks().


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