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( [&] {
98 assert(newTrack->IsLeader());
102 settings.extra.SetDuration(oldDuration);
115 newTrack =
mTracks->Add(track);
117 assert(newTrack->IsLeader());
118 newTrack->SetSelected(
true);
121 mT0 = selectedRegion.
t0();
122 mT1 = selectedRegion.
t1();
130 duration = quantMT1 - quantMT0;
136 auto newFormat = isSelection
140 settings.extra.SetDuration(duration);
141 settings.extra.SetDurationFormat( newFormat );
148 pAccess->ModifySettings(
updater);
150#ifdef EXPERIMENTAL_SPECTRAL_EDITING
151 mF0 = selectedRegion.
f0();
152 mF1 = selectedRegion.
f1();
162 std::shared_ptr<EffectInstance> pInstance;
167 else if (
auto result = finder(
settings))
173 auto pInstanceEx = std::dynamic_pointer_cast<EffectInstanceEx>(pInstance);
178 pInstanceEx = std::dynamic_pointer_cast<EffectInstanceEx>(
MakeInstance());
180 if (!pInstanceEx || !pInstanceEx->Init())
188 bool returnVal =
true;
190 if (skipFlag ==
false)
202 returnVal = pInstanceEx->Process(
settings);
205 if (returnVal && (
mT1 >=
mT0 ))
244 -> std::optional<InstancePointer>
246 auto result = plugin.MakeInstance();
247 if (
auto pInstanceEx = std::dynamic_pointer_cast<EffectInstanceEx>(result)
248 ; pInstanceEx && pInstanceEx->Init())
249 return { pInstanceEx };
255 return [&plugin](
auto&) {
return FindInstance(plugin); };
Toolkit-neutral facade for basic user interface services.
const TranslatableString name
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
May report more than one only when this is a leader track.
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
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...