27#include "../LabelTrack.h"
28#include "../ProjectSettings.h"
29#include "../SelectFile.h"
30#include "../ShuttleAutomation.h"
31#include "../ShuttleGui.h"
32#include "../SyncLock.h"
34#include "../WaveTrack.h"
36#include "../widgets/ProgressDialog.h"
37#include "../widgets/NumericTextCtrl.h"
38#include "../widgets/AudacityMessageBox.h"
39#include "../widgets/VetoDialogHook.h"
41#include <unordered_map>
47using t2bHash = std::unordered_map< void*, bool >;
81 return XO(
"Audacity");
86 return AUDACITY_VERSION_STRING;
105 return { wxT(
"Audacity"),
XO(
"Built-in") };
134 return std::make_shared<Instance>(
const_cast<StatefulEffect&
>(*
this));
154 wxWindow &parent, wxDialog &dialog,
bool forceModal)
252 name, wxT(
"Parameters"), parms))
267 name, wxT(
"Parameters"), parms);
290 auto parent =
S.GetParent();
302 result = std::make_unique<DefaultEffectUIValidator>(*
this, access);
337 {
XO(
"Presets"), { wxT(
"txt") },
true },
350 auto path =
SelectFile(FileNames::Operation::Presets,
351 XO(
"Export Effect Parameters"),
356 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
363 wxFFile f(path, wxT(
"wb"));
367 XO(
"Could not open file: \"%s\"").
Format( path ),
368 XO(
"Error Saving Effect Presets"),
378 XO(
"Error writing to file: \"%s\"").
Format( path ),
379 XO(
"Error Saving Effect Presets"),
395 auto path =
SelectFile(FileNames::Operation::Presets,
396 XO(
"Import Effect Parameters"),
401 wxFD_OPEN | wxRESIZE_BORDER,
415 if (
ident != commandId) {
418 if ((
params.Length() < 2 ) || (
ident.Length() < 2) || (
ident.Length() > 30))
422 XO(
"%s: is not a valid presets file.\n")
423 .
Format(wxFileNameFromPath(path)));
429 XO(
"%s: is for a different Effect, Generator or Analyzer.\n")
430 .
Format(wxFileNameFromPath(path)));
467 return wxT(
"SavedState");
500 bool success =
false;
531 S.SetForValidating( &eap );
541 S.SetForWriting( &eap );
549 XO(
"%s: Could not load settings below. Default settings will be used.\n\n%s")
594 region,
mUIFlags,
nullptr,
nullptr,
nullptr);
624 wxWindow *apply = dlg->FindWindow(wxID_APPLY);
629 wxWindow *focus = dlg->FindFocus();
632 dlg->FindWindow(wxID_CLOSE)->SetFocus();
636 apply->Enable(enable);
655 wxWindow *play = dlg->FindWindow(
kPlayID);
658 wxWindow *rewind = dlg->FindWindow(
kRewindID);
659 wxWindow *ffwd = dlg->FindWindow(
kFFwdID);
664 wxWindow *focus = dlg->FindFocus();
665 if (focus && (focus == play || focus == rewind || focus == ffwd))
667 dlg->FindWindow(wxID_CLOSE)->SetFocus();
671 play->Enable(enable);
675 rewind->Enable(enable);
677 ffwd->Enable(enable);
752 [&] (
const Track *pTrack) {
753 return allSyncLockSelected
755 : track_cast<const WaveTrack*>( pTrack ) && pTrack->GetSelected();
760 for (
auto aTrack : trackRange)
763 mIMap.push_back(aTrack);
770 mIMap.push_back(NULL);
771 mOMap.push_back(t.get());
786 mpEffect = that.mpEffect;
787 mpTrack = that.mpTrack;
800 mpEffect->mTracks->Remove(mpTrack);
806 return std::shared_ptr<AddedAnalysisTrack>
833 mpEffect = that.mpEffect;
834 mpTrack = that.mpTrack;
835 mpOrigTrack = std::move(that.mpOrigTrack);
850 mpEffect->mTracks->Replace(mpTrack, mpOrigTrack);
857 return{
this, pOrigTrack,
name };
868 return previewLength;
876 :
XO(
"%s: %s").Format(
GetName(), titleStr );
@ Internal
Indicates internal failure from Audacity.
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
EffectDistortion::Params params
const TranslatableString name
static const FileNames::FileTypes & PresetTypes()
static const int kRewindID
std::unordered_map< void *, bool > t2bHash
#define BUILTIN_EFFECT_PREFIX
RegistryPath UserPresetsGroup(const RegistryPath &name)
Compute part of a registry path, given a name which may be empty.
const RegistryPath & FactoryDefaultsGroup()
Component of a configuration key path, for default state of MakeSettings()
const RegistryPath & CurrentSettingsGroup()
Component of a configuration key path, for last-used destructive settings.
std::function< wxDialog *(wxWindow &parent, EffectPlugin &, EffectUIClientInterface &, std::shared_ptr< EffectInstance > &, EffectSettingsAccess &) > EffectDialogFactory
Type of function that creates a dialog for an effect.
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
std::vector< RegistryPath > RegistryPaths
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
static CommandHandlerObject & ident(AudacityProject &project)
EffectReverbSettings preset
FilePath SelectFile(FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
static Settings & settings()
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
virtual ProgressResult Poll(unsigned long long numerator, unsigned long long denominator, const TranslatableString &message={})=0
Update the bar and poll for clicks. Call only on the main thread.
Generates EffectParameterMethods overrides from variadic template arguments.
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
bool GetParameters(wxString &parms)
TranslatableString GetName() const
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
const wxString & Internal() const
std::shared_ptr< Track > mpOrigTrack
std::shared_ptr< TrackList > mOutputTracks
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.
WaveTrackFactory * mFactory
std::vector< Track * > mOMap
BasicUI::ProgressDialog * mProgress
std::vector< Track * > mIMap
wxWeakRef< wxDialog > mUIDialog
This weak pointer may be the same as mUIParent, or null.
const AudacityProject * FindProject() const
bool SupportsRealtime() const
static Identifier GetSquashedName(const Identifier &ident)
A utility that strips spaces and CamelCases a name.
RealtimeSince
In which versions of Audacity was an effect realtime capable?
Base class for many of the effects in Audacity.
bool SaveSettings(const EffectSettings &settings, CommandParameters &parms) const override
Store settings as keys and values.
RealtimeSince RealtimeSupport() const override
Since which version of Audacity has the effect supported realtime?
const EffectSettingsManager & GetDefinition() const override
bool TrackGroupProgress(int whichGroup, double frac, const TranslatableString &={}) const
void ShowOptions() override
unsigned GetAudioInCount() const override
How many input buffers to allocate at once.
bool LoadFactoryPreset(int id, EffectSettings &settings) const override
Change settings to the preset whose name is GetFactoryPresets()[id]
bool SaveUserPreset(const RegistryPath &name, const EffectSettings &settings) const override
Save settings in the configuration file as a user-named preset.
void SetBatchProcessing() override
bool IsGraphicalUI() override
bool VisitSettings(SettingsVisitor &visitor, EffectSettings &settings) override
bool SaveSettingsAsString(const EffectSettings &settings, wxString &parms) const override
wxWeakRef< wxDialog > mHostUIDialog
This smart pointer tracks the lifetime of the dialog.
void CopyInputTracks(bool allSyncLockSelected=false)
bool LoadFactoryDefaults(EffectSettings &settings) const override
Change settings back to "factory default".
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={}) const
bool EnableApply(bool enable=true)
bool EnablePreview(bool enable=true)
bool SupportsAutomation() const override
Whether the effect has any automatable controls.
virtual std::unique_ptr< EffectUIValidator > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access)
Add controls to effect panel; always succeeds.
bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const override
Restore settings from keys and values.
virtual const EffectParameterMethods & Parameters() const
TranslatableString GetDescription() const override
void ImportPresets(EffectSettings &settings) override
virtual NumericFormatSymbol GetSelectionFormat()
void ExportPresets(const EffectSettings &settings) const override
double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const override
Default implementation returns previewLength
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.
bool TotalProgress(double frac, const TranslatableString &={}) const
Track * AddToOutputTracks(const std::shared_ptr< Track > &t)
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
bool LoadSettingsFromString(const wxString &parms, EffectSettings &settings) const override
bool TransferDataFromWindow(EffectSettings &settings) override
Update the given settings from controls.
wxString GetVersion() const override
bool CheckWhetherSkipEffect(const EffectSettings &settings) const override
Default implementation returns false.
PluginPath GetPath() const override
EffectType GetType() const override
Type determines how it behaves.
wxString GetSavedStateGroup()
bool IsBatchProcessing() const override
bool HasOptions() override
bool Delegate(Effect &delegate, EffectSettings &settings)
Re-invoke DoEffect on another Effect object that implements the work.
VendorSymbol GetVendor() const override
std::unique_ptr< EffectUIValidator > PopulateUI(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
Adds controls to a panel that is given as the parent window of S
ComponentInterfaceSymbol GetSymbol() const override
unsigned GetAudioOutCount() const override
How many output buffers to allocate at once.
ModifiedAnalysisTrack ModifyAnalysisTrack(const LabelTrack *pOrigTrack, const wxString &name=wxString())
EffectFamilySymbol GetFamily() const override
Report identifier and user-visible name of the effect protocol.
void UnsetBatchProcessing() override
bool IsDefault() const override
Whether the effect sorts "above the line" in the menus.
unsigned TestUIFlags(unsigned mask)
bool CanExportPresets() override
bool TransferDataToWindow(const EffectSettings &settings) override
Update controls for the settings.
RegistryPaths GetFactoryPresets() const override
Report names of factory presets.
void GetBounds(const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
int ShowClientInterface(wxWindow &parent, wxDialog &dialog, bool forceModal=false) override
std::shared_ptr< AddedAnalysisTrack > AddAnalysisTrack(const wxString &name=wxString())
bool LoadUserPreset(const RegistryPath &name, EffectSettings &settings) const override
Change settings to a user-named preset.
bool IsInteractive() const override
Whether the effect needs a dialog for entry of settings.
bool ValidateUI(EffectSettings &) override
Performs effect computation.
Interface for manipulations of an Effect's settings.
virtual bool Set(Effect &effect, const CommandParameters &parms, EffectSettings &settings) const =0
virtual void Get(const Effect &effect, const EffectSettings &settings, CommandParameters &parms) const =0
virtual void Visit(Effect &effect, SettingsVisitor &visitor, EffectSettings &settings) const =0
static const wxString kUserPresetIdent
static const wxString kFactoryPresetIdent
static const wxString kCurrentSettingsIdent
static const wxString kFactoryDefaultsIdent
EffectSettingsManager is an EffectDefinitionInterface that adds a factory function for EffectSettings...
virtual EffectSettings MakeSettings() const
EffectUIClientInterface is an abstract base class to populate a UI and validate UI values....
virtual int ShowClientInterface(wxWindow &parent, wxDialog &dialog, bool forceModal=false)=0
std::vector< FileType > FileTypes
FILES_API const FileType AllFiles
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.
A LabelTrack is a Track that holds labels (LabelStruct).
double GetStartTime() const override
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
double GetEndTime() const override
void SetOffset(double dOffset) override
static LabelTrack * Create(TrackList &trackList, const wxString &name)
Create a new LabelTrack with specified name and append it to the trackList.
bool setTimes(double t0, double t1)
static NumericFormatSymbol HoursMinsSecondsFormat()
static ProjectSettings & Get(AudacityProject &project)
const NumericFormatSymbol & GetSelectionFormat() const
sampleCount TimeToLongSamples(double t0) const
Convert correctly between an (absolute) time in seconds and a number of samples.
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
SettingsVisitor that gets parameter values into a string.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
SettingsVisitor that sets parameters to a value (from a string)
bool Process(EffectSettings &settings) override
Actually do the effect here.
StatefulEffectBase & GetEffect() const
virtual bool Process(EffectInstance &instance, EffectSettings &settings)=0
Actually do the effect here.
std::shared_ptr< EffectInstance > MakeInstance() const override
Make an object maintaining short-term state of an Effect.
static bool IsSelectedOrSyncLockSelected(const Track *pTrack)
Abstract base class for an object holding data associated with points on a time axis.
void SetName(const wxString &n)
static std::shared_ptr< TrackList > Create(AudacityProject *pOwner)
ListOfTracks::value_type Replace(Track *t, const ListOfTracks::value_type &with)
auto Any() -> TrackIterRange< TrackType >
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
double GetStartTime() const override
Get the time at which the first clip in the track starts.
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Positions or offsets within audio files need a wide type.
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
bool SetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, const Value &value)
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)
Externalized state of a plug-in.