45 mTracks = pTracks ? pTracks->shared_from_this() :
nullptr;
67 wxASSERT(selectedRegion.
duration() >= 0.0);
83 bool isSelection =
false;
93 auto oldDuration = duration;
95 auto cleanup =
finally( [&] {
101 settings.extra.SetDuration(oldDuration);
114 newTrack =
mTracks->Add(track);
115 newTrack->SetSelected(
true);
118 mT0 = selectedRegion.
t0();
119 mT1 = selectedRegion.
t1();
127 duration = quantMT1 - quantMT0;
133 auto newFormat = (isSelection
138 settings.extra.SetDuration(duration);
139 settings.extra.SetDurationFormat(newFormat);
146 pAccess->ModifySettings(
updater);
148 mF0 = selectedRegion.
f0();
149 mF1 = selectedRegion.
f1();
158 std::shared_ptr<EffectInstance> pInstance;
169 auto pInstanceEx = std::dynamic_pointer_cast<EffectInstanceEx>(pInstance);
174 pInstanceEx = std::dynamic_pointer_cast<EffectInstanceEx>(
MakeInstance());
176 if (!pInstanceEx || !pInstanceEx->Init())
184 bool returnVal =
true;
186 if (skipFlag ==
false)
198 returnVal = pInstanceEx->Process(
settings);
201 if (returnVal && (
mT1 >=
mT0 ))
240 -> std::optional<InstancePointer>
242 auto result = plugin.MakeInstance();
243 if (
auto pInstanceEx = std::dynamic_pointer_cast<EffectInstanceEx>(result)
244 ; pInstanceEx && pInstanceEx->Init())
245 return { pInstanceEx };
251 return [&plugin](
auto&) {
return FindInstance(plugin); };
@ Internal
Indicates internal failure from Audacity.
Toolkit-neutral facade for basic user interface services.
const RegistryPath & CurrentSettingsGroup()
Component of a configuration key path, for last-used destructive settings.
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
#define QUANTIZED_TIME(time, rate)
#define NYQUIST_PROMPT_ID
static Settings & settings()
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
virtual PluginPath GetPath() const =0
TranslatableString GetName() const
WaveTrackFactory * mFactory
void SetPreviewFullSelectionFlag(bool previewDurationFlag)
void SetLinearEffectFlag(bool linearEffectFlag)
const TrackList * inputTracks() const
virtual std::any BeginPreview(const EffectSettings &settings)
Called when Preview() starts, to allow temporary effect state changes.
virtual bool CheckWhetherSkipEffect(const EffectSettings &settings) const =0
After Init(), tell whether Process() should be skipped.
BasicUI::ProgressDialog * mProgress
bool DoEffect(EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess) override
std::shared_ptr< TrackList > mTracks
bool mPreviewFullSelection
static std::optional< InstancePointer > FindInstance(EffectPlugin &plugin)
wxArrayString mPresetNames
double GetDefaultDuration()
static InstanceFinder DefaultInstanceFinder(EffectPlugin &plugin)
void SetTracks(TrackList *pTracks)
const AudacityProject * FindProject() const
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.
Factory of instances of an effect.
std::function< std::optional< InstancePointer >(EffectSettings &settings) > InstanceFinder
std::shared_ptr< EffectSettingsAccess > EffectSettingsAccessPtr
virtual const EffectSettingsManager & GetDefinition() const =0
bool setTimes(double t0, double t1)
static const int UndefinedFrequency
bool ReadWithDefault(T *pVar, const T &defaultValue) const
overload of ReadWithDefault returning a boolean that is true if the value was previously defined */
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
AudacityProject * GetOwner()
RAII for a database transaction, possibly nested.
bool Commit()
Commit the transaction.
Used to create or clone a WaveTrack, with appropriate context from the project that will own the trac...
std::shared_ptr< WaveTrack > Create()
Creates an unnamed empty WaveTrack with default sample format and default rate.
A Track that contains audio waveform data.
static wxString GetDefaultAudioTrackNamePreference()
size_t NChannels() const override
A constant property.
std::unique_ptr< ProgressDialog > MakeProgress(const TranslatableString &title, const TranslatableString &message, unsigned flags=(ProgressShowStop|ProgressShowCancel), const TranslatableString &remainingLabelText={})
Create and display a progress dialog.
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)
PROJECT_RATE_API IntSetting DefaultSampleRate
Externalized state of a plug-in.
"finally" as in The C++ Programming Language, 4th ed., p. 358 Useful for defining ad-hoc RAII actions...