Audacity 3.2.0
Effect.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Effect.cpp
6
7 Dominic Mazzoni
8 Vaughan Johnson
9 Martyn Shaw
10
11*******************************************************************//*******************************************************************/
17
18
19#include "Effect.h"
20
21#include <algorithm>
22
23#include <wx/defs.h>
24#include <wx/sizer.h>
25
26#include "ConfigInterface.h"
27#include "../LabelTrack.h"
28#include "../ProjectSettings.h"
29#include "../SelectFile.h"
30#include "../ShuttleAutomation.h"
31#include "../ShuttleGui.h"
32#include "../SyncLock.h"
33#include "ViewInfo.h"
34#include "../WaveTrack.h"
35#include "wxFileNameWrapper.h"
36#include "../widgets/ProgressDialog.h"
37#include "../widgets/NumericTextCtrl.h"
38#include "../widgets/AudacityMessageBox.h"
39#include "../widgets/VetoDialogHook.h"
40
41#include <unordered_map>
42
43static const int kPlayID = 20102;
44static const int kRewindID = 20103;
45static const int kFFwdID = 20104;
46
47using t2bHash = std::unordered_map< void*, bool >;
48
50{
51 return GetEffect().Process(*this, settings);
52}
53
55{
56}
57
59{
60 // Destroying what is usually the unique Effect object of its subclass,
61 // which lasts until the end of the session.
62 // Maybe there is a non-modal realtime dialog still open.
63 if (mHostUIDialog)
64 mHostUIDialog->Close();
65}
66
67// ComponentInterface implementation
68
70{
72}
73
75{
76 return {};
77}
78
80{
81 return XO("Audacity");
82}
83
84wxString Effect::GetVersion() const
85{
86 return AUDACITY_VERSION_STRING;
87}
88
90{
91 return {};
92}
93
94// EffectDefinitionInterface implementation
95
97{
98 return EffectTypeNone;
99}
100
102{
103 // Unusually, the internal and visible strings differ for the built-in
104 // effect family.
105 return { wxT("Audacity"), XO("Built-in") };
106}
107
109{
110 return true;
111}
112
114{
115 return true;
116}
117
119{
121}
122
124{
125 return true;
126}
127
128std::shared_ptr<EffectInstance> StatefulEffect::MakeInstance() const
129{
130 // Cheat with const-cast to return an object that calls through to
131 // non-const methods of a stateful effect.
132 // Stateless effects should override this function and be really const
133 // correct.
134 return std::make_shared<Instance>(const_cast<StatefulEffect&>(*this));
135}
136
138{
139 return 0;
140}
141
143{
144 return 0;
145}
146
148{
149 static const CapturedParameters<Effect> empty;
150 return empty;
151}
152
154 wxWindow &parent, wxDialog &dialog, bool forceModal)
155{
156 // Remember the dialog with a weak pointer, but don't control its lifetime
157 mUIDialog = &dialog;
158 mUIDialog->Layout();
159 mUIDialog->Fit();
160 mUIDialog->SetMinSize(mUIDialog->GetSize());
161
163 return 0;
164
165 if( SupportsRealtime() && !forceModal )
166 {
167 mUIDialog->Show();
168 // Return false to bypass effect processing
169 return 0;
170 }
171
172 return mUIDialog->ShowModal();
173}
174
175int Effect::ShowHostInterface(wxWindow &parent,
177 std::shared_ptr<EffectInstance> &pInstance, EffectSettingsAccess &access,
178 bool forceModal)
180 if (!IsInteractive())
181 // Effect without UI just proceeds quietly to apply it destructively.
182 return wxID_APPLY;
183
184 if (mHostUIDialog)
185 {
186 // Realtime effect has shown its nonmodal dialog, now hides it, and does
187 // nothing else.
188 if ( mHostUIDialog->Close(true) )
189 mHostUIDialog = nullptr;
190 return 0;
191 }
192
193 // Create the dialog
194 // Host, not client, is responsible for invoking the factory and managing
195 // the lifetime of the dialog.
196 // The usual factory lets the client (which is this, when self-hosting)
197 // populate it. That factory function is called indirectly through a
198 // std::function to avoid source code dependency cycles.
199 EffectUIClientInterface *const client = this;
200 mHostUIDialog = factory(parent, *this, *client, pInstance, access);
201 if (!mHostUIDialog)
202 return 0;
203
204 // Let the client show the dialog and decide whether to keep it open
205 auto result = client->ShowClientInterface(parent, *mHostUIDialog, forceModal);
206 if (mHostUIDialog && !mHostUIDialog->IsShown())
207 // Client didn't show it, or showed it modally and closed it
208 // So destroy it.
209 // (I think mHostUIDialog only needs to be a local variable in this
210 // function -- that it is always null when the function begins -- but
211 // that may change. PRL)
212 mHostUIDialog->Destroy();
213
214 return result;
215}
216
218{
219 Parameters().Visit(*this, visitor, settings);
220 return true;
221}
222
224 ConstSettingsVisitor &visitor, const EffectSettings &settings) const
225{
226 Parameters().Visit(*this, visitor, settings);
227 return true;
228}
229
231 const EffectSettings &settings, CommandParameters & parms) const
232{
233 Parameters().Get( *this, settings, parms );
234 return true;
235}
236
238 const CommandParameters & parms, EffectSettings &settings) const
239{
240 // The first argument, and with it the const_cast, will disappear when
241 // all built-in effects are stateless.
242 return Parameters().Set( *const_cast<Effect*>(this), parms, settings );
243}
244
247{
248 // Find one string in the registry and then reinterpret it
249 // as complete settings
250 wxString parms;
252 name, wxT("Parameters"), parms))
253 return false;
254
255 return LoadSettingsFromString(parms, settings);
256}
257
259 const RegistryPath & name, const EffectSettings &settings) const
260{
261 // Save all settings as a single string value in the registry
262 wxString parms;
263 if (!SaveSettingsAsString(settings, parms))
264 return false;
265
267 name, wxT("Parameters"), parms);
268}
269
271{
272 return {};
273}
274
276{
277 return true;
278}
279
281{
283}
284
285// EffectUIClientInterface implementation
286
287std::unique_ptr<EffectUIValidator> Effect::PopulateUI(ShuttleGui &S,
288 EffectInstance &instance, EffectSettingsAccess &access)
289{
290 auto parent = S.GetParent();
291 mUIParent = parent;
292
293// LoadUserPreset(CurrentSettingsGroup());
294
295 // Let the effect subclass provide its own validator if it wants
296 auto result = PopulateOrExchange(S, instance, access);
297
298 mUIParent->SetMinSize(mUIParent->GetSizer()->GetMinSize());
299
300 if (!result) {
301 // No custom validator object? Then use the default
302 result = std::make_unique<DefaultEffectUIValidator>(*this, access);
303 }
304 mUIParent->PushEventHandler(this);
305 return result;
306}
307
309{
310 return false;
311}
312
314{
315 return true;
316}
317
319{
320 if (mUIParent)
321 mUIParent->RemoveEventHandler(this);
322
323 mUIParent = NULL;
324 mUIDialog = NULL;
325
326 return true;
327}
328
330{
331 return true;
332}
333
335{
336 static const FileNames::FileTypes result {
337 { XO("Presets"), { wxT("txt") }, true },
339 };
340 return result;
341};
342
344{
345 wxString params;
347 auto commandId = GetSquashedName(GetSymbol().Internal());
348 params = commandId.GET() + ":" + params;
349
350 auto path = SelectFile(FileNames::Operation::Presets,
351 XO("Export Effect Parameters"),
352 wxEmptyString,
353 wxEmptyString,
354 wxEmptyString,
355 PresetTypes(),
356 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
357 nullptr);
358 if (path.empty()) {
359 return;
360 }
361
362 // Create/Open the file
363 wxFFile f(path, wxT("wb"));
364 if (!f.IsOpened())
365 {
367 XO("Could not open file: \"%s\"").Format( path ),
368 XO("Error Saving Effect Presets"),
369 wxICON_EXCLAMATION,
370 NULL);
371 return;
372 }
373
374 f.Write(params);
375 if (f.Error())
376 {
378 XO("Error writing to file: \"%s\"").Format( path ),
379 XO("Error Saving Effect Presets"),
380 wxICON_EXCLAMATION,
381 NULL);
382 }
383
384 f.Close();
385
386
387 //SetWindowTitle();
388
389}
390
392{
393 wxString params;
394
395 auto path = SelectFile(FileNames::Operation::Presets,
396 XO("Import Effect Parameters"),
397 wxEmptyString,
398 wxEmptyString,
399 wxEmptyString,
400 PresetTypes(),
401 wxFD_OPEN | wxRESIZE_BORDER,
402 nullptr);
403 if (path.empty()) {
404 return;
405 }
406
407 wxFFile f(path);
408 if (f.IsOpened()) {
409 if (f.ReadAll(&params)) {
410 wxString ident = params.BeforeFirst(':');
411 params = params.AfterFirst(':');
412
413 auto commandId = GetSquashedName(GetSymbol().Internal());
414
415 if (ident != commandId) {
416 // effect identifiers are a sensible length!
417 // must also have some params.
418 if ((params.Length() < 2 ) || (ident.Length() < 2) || (ident.Length() > 30))
419 {
421 /* i18n-hint %s will be replaced by a file name */
422 XO("%s: is not a valid presets file.\n")
423 .Format(wxFileNameFromPath(path)));
424 }
425 else
426 {
428 /* i18n-hint %s will be replaced by a file name */
429 XO("%s: is for a different Effect, Generator or Analyzer.\n")
430 .Format(wxFileNameFromPath(path)));
431 }
432 return;
433 }
435 }
436 }
437
438 //SetWindowTitle();
439
440}
441
443{
444 return false;
445}
446
448{
449}
450
451// EffectPlugin implementation
452
454{
455 return *this;
456}
457
459{
460 if( !IsBatchProcessing() && FindProject() )
463}
464
466{
467 return wxT("SavedState");
468}
469
470// Effect implementation
471
473 const EffectSettings &settings, wxString & parms) const
474{
477 S.mpEap = &eap;
478 if( VisitSettings( S, settings ) ){
479 ;// got eap value using VisitSettings.
480 }
481 // Won't be needed in future
482 else if (!SaveSettings(settings, eap))
483 {
484 return false;
485 }
486
487 return eap.GetParameters(parms);
488}
489
491 const wxString & parms, EffectSettings &settings) const
492{
493 // If the string starts with one of certain significant substrings,
494 // then the rest of the string is reinterpreted as part of a registry key,
495 // and a user or factory preset is then loaded.
496 // (Where did these prefixes come from? See EffectPresetsDialog; and
497 // ultimately the uses of it by EffectManager::GetPreset, which is used by
498 // the macro management dialog)
499 wxString preset = parms;
500 bool success = false;
501 if (preset.StartsWith(kUserPresetIdent))
502 {
503 preset.Replace(kUserPresetIdent, wxEmptyString, false);
505 }
506 else if (preset.StartsWith(kFactoryPresetIdent))
507 {
508 preset.Replace(kFactoryPresetIdent, wxEmptyString, false);
509 auto presets = GetFactoryPresets();
510 success = LoadFactoryPreset(
511 make_iterator_range( presets ).index( preset ), settings );
512 }
513 else if (preset.StartsWith(kCurrentSettingsIdent))
514 {
515 preset.Replace(kCurrentSettingsIdent, wxEmptyString, false);
517 }
518 else if (preset.StartsWith(kFactoryDefaultsIdent))
519 {
520 preset.Replace(kFactoryDefaultsIdent, wxEmptyString, false);
522 }
523 else
524 {
525 // If the string did not start with any of the significant substrings,
526 // then use VisitSettings or LoadSettings to reinterpret it,
527 // or use LoadSettings.
528 // This interprets what was written by SaveSettings, above.
529 CommandParameters eap(parms);
531 S.SetForValidating( &eap );
532 // VisitSettings returns false if not defined for this effect.
533 // To do: fix const_cast in use of VisitSettings
534 if ( !const_cast<Effect*>(this)->VisitSettings(S, settings) )
535 // the old method...
536 success = LoadSettings(eap, settings);
537 else if( !S.bOK )
538 success = false;
539 else{
540 success = true;
541 S.SetForWriting( &eap );
542 const_cast<Effect*>(this)->VisitSettings(S, settings);
543 }
544 }
545
546 if (!success)
547 {
549 XO("%s: Could not load settings below. Default settings will be used.\n\n%s")
550 .Format( GetName(), preset ) );
551 // We are using default settings and we still wish to continue.
552 return true;
553 //return false;
554 }
555 return true;
556}
557
558unsigned Effect::TestUIFlags(unsigned mask) {
559 return mask & mUIFlags;
560}
561
563{
564 return mIsBatch;
565}
566
568{
569 mIsBatch = true;
570 // Save effect's internal state in a special registry path
571 // just for this purpose
572 // If effect is not stateful, this step doesn't really matter, and the
573 // settings object is a dummy
574 auto dummySettings = MakeSettings();
575 SaveUserPreset(GetSavedStateGroup(), dummySettings);
576}
577
579{
580 mIsBatch = false;
581 // Restore effect's internal state from registry
582 // If effect is not stateful, this call doesn't really matter, and the
583 // settings object is a dummy
584 auto dummySettings = MakeSettings();
585 LoadUserPreset(GetSavedStateGroup(), dummySettings);
586}
587
589{
591 region.setTimes( mT0, mT1 );
592
593 return delegate.DoEffect(settings, mProjectRate, mTracks, mFactory,
594 region, mUIFlags, nullptr, nullptr, nullptr);
595}
596
597std::unique_ptr<EffectUIValidator> Effect::PopulateOrExchange(
599{
600 return nullptr;
601}
602
604{
605 return true;
606}
607
609{
610 return true;
611}
612
613bool Effect::EnableApply(bool enable)
614{
615 // May be called during initialization, so try to find the dialog
616 wxWindow *dlg = mUIDialog;
617 if (!dlg && mUIParent)
618 {
619 dlg = wxGetTopLevelParent(mUIParent);
620 }
621
622 if (dlg)
623 {
624 wxWindow *apply = dlg->FindWindow(wxID_APPLY);
625
626 // Don't allow focus to get trapped
627 if (!enable)
628 {
629 wxWindow *focus = dlg->FindFocus();
630 if (focus == apply)
631 {
632 dlg->FindWindow(wxID_CLOSE)->SetFocus();
633 }
634 }
635
636 apply->Enable(enable);
637 }
638
639 EnablePreview(enable);
640
641 return enable;
642}
643
644bool Effect::EnablePreview(bool enable)
645{
646 // May be called during initialization, so try to find the dialog
647 wxWindow *dlg = mUIDialog;
648 if (!dlg && mUIParent)
649 {
650 dlg = wxGetTopLevelParent(mUIParent);
651 }
652
653 if (dlg)
654 {
655 wxWindow *play = dlg->FindWindow(kPlayID);
656 if (play)
657 {
658 wxWindow *rewind = dlg->FindWindow(kRewindID);
659 wxWindow *ffwd = dlg->FindWindow(kFFwdID);
660
661 // Don't allow focus to get trapped
662 if (!enable)
663 {
664 wxWindow *focus = dlg->FindFocus();
665 if (focus && (focus == play || focus == rewind || focus == ffwd))
666 {
667 dlg->FindWindow(wxID_CLOSE)->SetFocus();
668 }
669 }
670
671 play->Enable(enable);
672 if (SupportsRealtime())
673 {
674 if (rewind)
675 rewind->Enable(enable);
676 if (ffwd)
677 ffwd->Enable(enable);
678 }
679 }
680 }
681
682 return enable;
683}
684
685bool Effect::TotalProgress(double frac, const TranslatableString &msg) const
686{
687 auto updateResult = (mProgress ?
688 mProgress->Poll(frac * 1000, 1000, msg) :
690 return (updateResult != ProgressResult::Success);
691}
692
694 int whichTrack, double frac, const TranslatableString &msg) const
695{
696 auto updateResult = (mProgress ?
697 mProgress->Poll(whichTrack + frac, (double) mNumTracks, msg) :
699 return (updateResult != ProgressResult::Success);
700}
701
703 int whichGroup, double frac, const TranslatableString &msg) const
704{
705 auto updateResult = (mProgress ?
706 mProgress->Poll(whichGroup + frac, (double) mNumGroups, msg) :
708 return (updateResult != ProgressResult::Success);
709}
710
712 const WaveTrack &track, const WaveTrack *pRight,
713 sampleCount *start, sampleCount *len)
714{
715 auto t0 = std::max( mT0, track.GetStartTime() );
716 auto t1 = std::min( mT1, track.GetEndTime() );
717
718 if ( pRight ) {
719 t0 = std::min( t0, std::max( mT0, pRight->GetStartTime() ) );
720 t1 = std::max( t1, std::min( mT1, pRight->GetEndTime() ) );
721 }
722
723 if (t1 > t0) {
724 *start = track.TimeToLongSamples(t0);
725 auto end = track.TimeToLongSamples(t1);
726 *len = end - *start;
727 }
728 else {
729 *start = 0;
730 *len = 0;
731 }
732}
733
734//
735// private methods
736//
737// Use this method to copy the input tracks to mOutputTracks, if
738// doing the processing on them, and replacing the originals only on success (and not cancel).
739// Copy the group tracks that have tracks selected
740// If not all sync-locked selected, then only selected wave tracks.
741void Effect::CopyInputTracks(bool allSyncLockSelected)
742{
743 // Reset map
744 mIMap.clear();
745 mOMap.clear();
746
748 const_cast<AudacityProject*>( FindProject() ) // how to remove this const_cast?
749 );
750
751 auto trackRange = mTracks->Any() +
752 [&] (const Track *pTrack) {
753 return allSyncLockSelected
755 : track_cast<const WaveTrack*>( pTrack ) && pTrack->GetSelected();
756 };
757
758 t2bHash added;
759
760 for (auto aTrack : trackRange)
761 {
762 Track *o = mOutputTracks->Add(aTrack->Duplicate());
763 mIMap.push_back(aTrack);
764 mOMap.push_back(o);
765 }
766}
767
768Track *Effect::AddToOutputTracks(const std::shared_ptr<Track> &t)
769{
770 mIMap.push_back(NULL);
771 mOMap.push_back(t.get());
772 return mOutputTracks->Add(t);
773}
774
776 : mpEffect(pEffect)
777{
778 if(!name.empty())
780 else
782}
783
785{
786 mpEffect = that.mpEffect;
787 mpTrack = that.mpTrack;
788 that.Commit();
789}
790
792{
793 mpEffect = nullptr;
794}
795
797{
798 if (mpEffect) {
799 // not committed -- DELETE the label track
800 mpEffect->mTracks->Remove(mpTrack);
801 }
802}
803
804auto Effect::AddAnalysisTrack(const wxString &name) -> std::shared_ptr<AddedAnalysisTrack>
805{
806 return std::shared_ptr<AddedAnalysisTrack>
807 { safenew AddedAnalysisTrack{ this, name } };
808}
809
811 (Effect *pEffect, const LabelTrack *pOrigTrack, const wxString &name)
812 : mpEffect(pEffect)
813{
814 // copy LabelTrack here, so it can be undone on cancel
815 auto newTrack = pOrigTrack->Copy(pOrigTrack->GetStartTime(), pOrigTrack->GetEndTime());
816
817 mpTrack = static_cast<LabelTrack*>(newTrack.get());
818
819 // Why doesn't LabelTrack::Copy complete the job? :
820 mpTrack->SetOffset(pOrigTrack->GetStartTime());
821 if (!name.empty())
823
824 // mpOrigTrack came from mTracks which we own but expose as const to subclasses
825 // So it's okay that we cast it back to const
827 pEffect->mTracks->Replace(const_cast<LabelTrack*>(pOrigTrack),
828 newTrack );
829}
830
832{
833 mpEffect = that.mpEffect;
834 mpTrack = that.mpTrack;
835 mpOrigTrack = std::move(that.mpOrigTrack);
836 that.Commit();
837}
838
840{
841 mpEffect = nullptr;
842}
843
845{
846 if (mpEffect) {
847 // not committed -- DELETE the label track
848 // mpOrigTrack came from mTracks which we own but expose as const to subclasses
849 // So it's okay that we cast it back to const
850 mpEffect->mTracks->Replace(mpTrack, mpOrigTrack);
851 }
852}
853
855 (const LabelTrack *pOrigTrack, const wxString &name) -> ModifiedAnalysisTrack
856{
857 return{ this, pOrigTrack, name };
858}
859
861{
862 return false;
863}
864
866 const EffectSettings &, double previewLength) const
867{
868 return previewLength;
869}
870
872 long style, const TranslatableString &titleStr) const
873{
874 auto title = titleStr.empty()
875 ? GetName()
876 : XO("%s: %s").Format( GetName(), titleStr );
877 return AudacityMessageBox( message, title, style, mUIParent );
878}
@ Internal
Indicates internal failure from Audacity.
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static RegisteredToolbarFactory factory
int min(int a, int b)
EffectDistortion::Params params
Definition: Distortion.cpp:83
const TranslatableString name
Definition: Distortion.cpp:82
static const FileNames::FileTypes & PresetTypes()
Definition: Effect.cpp:334
static const int kFFwdID
Definition: Effect.cpp:45
static const int kRewindID
Definition: Effect.cpp:44
static const int kPlayID
Definition: Effect.cpp:43
std::unordered_map< void *, bool > t2bHash
Definition: Effect.cpp:47
#define BUILTIN_EFFECT_PREFIX
Definition: Effect.h:20
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.
EffectType
@ EffectTypeNone
std::function< wxDialog *(wxWindow &parent, EffectPlugin &, EffectUIClientInterface &, std::shared_ptr< EffectInstance > &, EffectSettingsAccess &) > EffectDialogFactory
Type of function that creates a dialog for an effect.
Definition: EffectPlugin.h:39
wxString RegistryPath
Definition: Identifier.h:218
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
std::vector< RegistryPath > RegistryPaths
Definition: Identifier.h:219
#define XO(s)
Definition: Internat.h:31
#define safenew
Definition: MemoryX.h:10
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:423
static CommandHandlerObject & ident(AudacityProject &project)
static const auto title
EffectReverbSettings preset
Definition: Reverb.cpp:46
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)
Definition: SelectFile.cpp:17
#define S(N)
Definition: ToChars.cpp:64
static Settings & settings()
Definition: TrackInfo.cpp:87
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
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
LabelTrack * mpTrack
Definition: Effect.h:224
std::shared_ptr< Track > mpOrigTrack
Definition: Effect.h:256
int mNumTracks
Definition: EffectBase.h:136
double mT1
Definition: EffectBase.h:107
std::shared_ptr< TrackList > mOutputTracks
Definition: EffectBase.h:105
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.
Definition: EffectBase.cpp:60
WaveTrackFactory * mFactory
Definition: EffectBase.h:101
TrackList * mTracks
Definition: EffectBase.h:125
std::vector< Track * > mOMap
Definition: EffectBase.h:134
double mProjectRate
Definition: EffectBase.h:99
BasicUI::ProgressDialog * mProgress
Definition: EffectBase.h:98
int mNumGroups
Definition: EffectBase.h:137
std::vector< Track * > mIMap
Definition: EffectBase.h:133
wxWeakRef< wxDialog > mUIDialog
This weak pointer may be the same as mUIParent, or null.
Definition: EffectBase.h:119
double mT0
Definition: EffectBase.h:106
unsigned mUIFlags
Definition: EffectBase.h:113
const AudacityProject * FindProject() const
Definition: EffectBase.cpp:315
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.
Definition: Effect.h:29
bool SaveSettings(const EffectSettings &settings, CommandParameters &parms) const override
Store settings as keys and values.
Definition: Effect.cpp:230
RealtimeSince RealtimeSupport() const override
Since which version of Audacity has the effect supported realtime?
Definition: Effect.cpp:118
const EffectSettingsManager & GetDefinition() const override
Definition: Effect.cpp:453
bool TrackGroupProgress(int whichGroup, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:702
void ShowOptions() override
Definition: Effect.cpp:447
unsigned GetAudioInCount() const override
How many input buffers to allocate at once.
Definition: Effect.cpp:137
bool LoadFactoryPreset(int id, EffectSettings &settings) const override
Change settings to the preset whose name is GetFactoryPresets()[id]
Definition: Effect.cpp:275
bool SaveUserPreset(const RegistryPath &name, const EffectSettings &settings) const override
Save settings in the configuration file as a user-named preset.
Definition: Effect.cpp:258
void SetBatchProcessing() override
Definition: Effect.cpp:567
bool IsGraphicalUI() override
Definition: Effect.cpp:308
bool VisitSettings(SettingsVisitor &visitor, EffectSettings &settings) override
Definition: Effect.cpp:217
bool SaveSettingsAsString(const EffectSettings &settings, wxString &parms) const override
Definition: Effect.cpp:472
wxWeakRef< wxDialog > mHostUIDialog
This smart pointer tracks the lifetime of the dialog.
Definition: Effect.h:269
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:741
bool LoadFactoryDefaults(EffectSettings &settings) const override
Change settings back to "factory default".
Definition: Effect.cpp:280
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={}) const
Definition: Effect.cpp:871
Effect()
Definition: Effect.cpp:54
bool EnableApply(bool enable=true)
Definition: Effect.cpp:613
bool EnablePreview(bool enable=true)
Definition: Effect.cpp:644
bool SupportsAutomation() const override
Whether the effect has any automatable controls.
Definition: Effect.cpp:123
virtual std::unique_ptr< EffectUIValidator > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access)
Add controls to effect panel; always succeeds.
Definition: Effect.cpp:597
bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const override
Restore settings from keys and values.
Definition: Effect.cpp:237
virtual const EffectParameterMethods & Parameters() const
Definition: Effect.cpp:147
wxWindow * mUIParent
Definition: Effect.h:270
TranslatableString GetDescription() const override
Definition: Effect.cpp:89
void ImportPresets(EffectSettings &settings) override
Definition: Effect.cpp:391
virtual NumericFormatSymbol GetSelectionFormat()
Definition: Effect.cpp:458
void ExportPresets(const EffectSettings &settings) const override
Definition: Effect.cpp:343
bool mIsBatch
Definition: Effect.h:278
double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const override
Default implementation returns previewLength
Definition: Effect.cpp:865
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.
Definition: Effect.cpp:175
bool TotalProgress(double frac, const TranslatableString &={}) const
Definition: Effect.cpp:685
Track * AddToOutputTracks(const std::shared_ptr< Track > &t)
Definition: Effect.cpp:768
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:693
bool LoadSettingsFromString(const wxString &parms, EffectSettings &settings) const override
Definition: Effect.cpp:490
bool TransferDataFromWindow(EffectSettings &settings) override
Update the given settings from controls.
Definition: Effect.cpp:608
wxString GetVersion() const override
Definition: Effect.cpp:84
bool CheckWhetherSkipEffect(const EffectSettings &settings) const override
Default implementation returns false.
Definition: Effect.cpp:860
PluginPath GetPath() const override
Definition: Effect.cpp:69
EffectType GetType() const override
Type determines how it behaves.
Definition: Effect.cpp:96
wxString GetSavedStateGroup()
Definition: Effect.cpp:465
bool IsBatchProcessing() const override
Definition: Effect.cpp:562
bool HasOptions() override
Definition: Effect.cpp:442
bool Delegate(Effect &delegate, EffectSettings &settings)
Re-invoke DoEffect on another Effect object that implements the work.
Definition: Effect.cpp:588
virtual ~Effect()
Definition: Effect.cpp:58
VendorSymbol GetVendor() const override
Definition: Effect.cpp:79
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
Definition: Effect.cpp:287
bool CloseUI() override
Definition: Effect.cpp:318
ComponentInterfaceSymbol GetSymbol() const override
Definition: Effect.cpp:74
unsigned GetAudioOutCount() const override
How many output buffers to allocate at once.
Definition: Effect.cpp:142
ModifiedAnalysisTrack ModifyAnalysisTrack(const LabelTrack *pOrigTrack, const wxString &name=wxString())
Definition: Effect.cpp:855
EffectFamilySymbol GetFamily() const override
Report identifier and user-visible name of the effect protocol.
Definition: Effect.cpp:101
void UnsetBatchProcessing() override
Definition: Effect.cpp:578
bool IsDefault() const override
Whether the effect sorts "above the line" in the menus.
Definition: Effect.cpp:113
unsigned TestUIFlags(unsigned mask)
Definition: Effect.cpp:558
bool CanExportPresets() override
Definition: Effect.cpp:329
bool TransferDataToWindow(const EffectSettings &settings) override
Update controls for the settings.
Definition: Effect.cpp:603
RegistryPaths GetFactoryPresets() const override
Report names of factory presets.
Definition: Effect.cpp:270
void GetBounds(const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
Definition: Effect.cpp:711
int ShowClientInterface(wxWindow &parent, wxDialog &dialog, bool forceModal=false) override
Definition: Effect.cpp:153
std::shared_ptr< AddedAnalysisTrack > AddAnalysisTrack(const wxString &name=wxString())
Definition: Effect.cpp:804
bool LoadUserPreset(const RegistryPath &name, EffectSettings &settings) const override
Change settings to a user-named preset.
Definition: Effect.cpp:245
bool IsInteractive() const override
Whether the effect needs a dialog for entry of settings.
Definition: Effect.cpp:108
bool ValidateUI(EffectSettings &) override
Definition: Effect.cpp:313
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
Definition: EffectPlugin.h:56
static const wxString kFactoryPresetIdent
Definition: EffectPlugin.h:57
static const wxString kCurrentSettingsIdent
Definition: EffectPlugin.h:58
static const wxString kFactoryDefaultsIdent
Definition: EffectPlugin.h:59
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
Definition: FileNames.h:76
FILES_API const FileType AllFiles
Definition: FileNames.h:71
Abstract base class used in importing a file.
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).
Definition: LabelTrack.h:89
double GetStartTime() const override
Definition: LabelTrack.cpp:346
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Definition: LabelTrack.cpp:714
double GetEndTime() const override
Definition: LabelTrack.cpp:354
void SetOffset(double dOffset) override
Definition: LabelTrack.cpp:176
static LabelTrack * Create(TrackList &trackList, const wxString &name)
Create a new LabelTrack with specified name and append it to the trackList.
Definition: LabelTrack.cpp:71
bool setTimes(double t0, double t1)
Definition: ViewInfo.cpp:51
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.
Definition: SampleTrack.cpp:42
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
Definition: Shuttle.h:115
SettingsVisitor that gets parameter values into a string.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
SettingsVisitor that sets parameters to a value (from a string)
bool Process(EffectSettings &settings) override
Actually do the effect here.
Definition: Effect.cpp:49
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.
Definition: Effect.cpp:128
static bool IsSelectedOrSyncLockSelected(const Track *pTrack)
Definition: SyncLock.cpp:73
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
void SetName(const wxString &n)
Definition: Track.cpp:79
static std::shared_ptr< TrackList > Create(AudacityProject *pOwner)
Definition: Track.cpp:502
ListOfTracks::value_type Replace(Track *t, const ListOfTracks::value_type &with)
Definition: Track.cpp:728
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1435
Holds a msgid for the translation catalog; may also bind format arguments.
A Track that contains audio waveform data.
Definition: WaveTrack.h:57
double GetStartTime() const override
Get the time at which the first clip in the track starts.
Definition: WaveTrack.cpp:1995
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:2015
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:18
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
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.