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;
44
45using t2bHash = std::unordered_map< void*, bool >;
46
48{
49 return GetEffect().Process(*this, settings);
50}
51
54{
55 return GetEffect().GetLatency().as_long_long();
56}
57
59{
60}
61
63{
64 // Destroying what is usually the unique Effect object of its subclass,
65 // which lasts until the end of the session.
66 // Maybe there is a non-modal realtime dialog still open.
67 if (mHostUIDialog)
68 mHostUIDialog->Close();
69}
70
71// ComponentInterface implementation
72
74{
76}
77
79{
80 return {};
81}
82
84{
85 return XO("Audacity");
86}
87
88wxString Effect::GetVersion() const
89{
90 return AUDACITY_VERSION_STRING;
91}
92
94{
95 return {};
96}
97
98// EffectDefinitionInterface implementation
99
101{
102 return EffectTypeNone;
103}
104
106{
107 // Unusually, the internal and visible strings differ for the built-in
108 // effect family.
109 return { wxT("Audacity"), XO("Built-in") };
110}
111
113{
114 return true;
115}
116
118{
119 return true;
120}
121
123{
125}
126
128{
129 return true;
130}
131
132std::shared_ptr<EffectInstance> StatefulEffect::MakeInstance() const
133{
134 // Cheat with const-cast to return an object that calls through to
135 // non-const methods of a stateful effect.
136 // Stateless effects should override this function and be really const
137 // correct.
138 return std::make_shared<Instance>(const_cast<StatefulEffect&>(*this));
139}
140
142{
143 static const CapturedParameters<Effect> empty;
144 return empty;
145}
146
147int Effect::ShowClientInterface(wxWindow &parent, wxDialog &dialog,
148 EffectUIValidator *, bool forceModal)
149{
150 // Remember the dialog with a weak pointer, but don't control its lifetime
151 mUIDialog = &dialog;
152 mUIDialog->Layout();
153 mUIDialog->Fit();
154 mUIDialog->SetMinSize(mUIDialog->GetSize());
156 return 0;
157 if (SupportsRealtime() && !forceModal) {
158 mUIDialog->Show();
159 // Return false to bypass effect processing
160 return 0;
161 }
162 return mUIDialog->ShowModal();
163}
164
165int Effect::ShowHostInterface(wxWindow &parent,
167 std::shared_ptr<EffectInstance> &pInstance, EffectSettingsAccess &access,
168 bool forceModal)
169{
170 if (!IsInteractive())
171 // Effect without UI just proceeds quietly to apply it destructively.
172 return wxID_APPLY;
173
174 if (mHostUIDialog)
175 {
176 // Realtime effect has shown its nonmodal dialog, now hides it, and does
177 // nothing else.
178 if ( mHostUIDialog->Close(true) )
179 mHostUIDialog = nullptr;
180 return 0;
181 }
182
183 // Create the dialog
184 // Host, not client, is responsible for invoking the factory and managing
185 // the lifetime of the dialog.
186 // The usual factory lets the client (which is this, when self-hosting)
187 // populate it. That factory function is called indirectly through a
188 // std::function to avoid source code dependency cycles.
189 EffectUIClientInterface *const client = this;
190 auto results = factory(parent, *this, *client, access);
191 mHostUIDialog = results.pDialog;
192 pInstance = results.pInstance;
193 if (!mHostUIDialog)
194 return 0;
195
196 // Let the client show the dialog and decide whether to keep it open
197 auto result = client->ShowClientInterface(parent, *mHostUIDialog,
198 results.pValidator, forceModal);
199 if (mHostUIDialog && !mHostUIDialog->IsShown())
200 // Client didn't show it, or showed it modally and closed it
201 // So destroy it.
202 // (I think mHostUIDialog only needs to be a local variable in this
203 // function -- that it is always null when the function begins -- but
204 // that may change. PRL)
205 mHostUIDialog->Destroy();
206
207 return result;
208}
209
211{
212 Parameters().Visit(*this, visitor, settings);
213 return true;
214}
215
217 ConstSettingsVisitor &visitor, const EffectSettings &settings) const
218{
219 Parameters().Visit(*this, visitor, settings);
220 return true;
221}
222
224 const EffectSettings &settings, CommandParameters & parms) const
225{
226 Parameters().Get( *this, settings, parms );
227 return true;
228}
229
231 const CommandParameters & parms, EffectSettings &settings) const
232{
233 // The first argument, and with it the const_cast, will disappear when
234 // all built-in effects are stateless.
235 return Parameters().Set( *const_cast<Effect*>(this), parms, settings );
236}
237
240{
241 // Find one string in the registry and then reinterpret it
242 // as complete settings
243 wxString parms;
245 name, wxT("Parameters"), parms))
246 return {};
247
248 return LoadSettingsFromString(parms, settings);
249}
250
252 const RegistryPath & name, const EffectSettings &settings) const
253{
254 // Save all settings as a single string value in the registry
255 wxString parms;
256 if (!SaveSettingsAsString(settings, parms))
257 return false;
258
260 name, wxT("Parameters"), parms);
261}
262
264{
265 return {};
266}
267
269{
270 return { nullptr };
271}
272
274{
276}
277
278// EffectUIClientInterface implementation
279
280std::unique_ptr<EffectUIValidator> Effect::PopulateUI(ShuttleGui &S,
281 EffectInstance &instance, EffectSettingsAccess &access,
282 const EffectOutputs *pOutputs)
283{
284 auto parent = S.GetParent();
285 mUIParent = parent;
286
287// LoadUserPreset(CurrentSettingsGroup());
288
289 // Let the effect subclass provide its own validator if it wants
290 auto result = PopulateOrExchange(S, instance, access, pOutputs);
291
292 mUIParent->SetMinSize(mUIParent->GetSizer()->GetMinSize());
293
294 if (!result) {
295 // No custom validator object? Then use the default
296 result = std::make_unique<DefaultEffectUIValidator>(
297 *this, access, S.GetParent());
298 mUIParent->PushEventHandler(this);
299 }
300 return result;
301}
302
304{
305 return false;
306}
307
309{
310 return true;
311}
312
314{
315 mUIParent = nullptr;
316 mUIDialog = nullptr;
317 return true;
318}
319
321{
322 return true;
323}
324
326{
327 static const FileNames::FileTypes result {
328 { XO("Presets"), { wxT("txt") }, true },
330 };
331 return result;
332};
333
335{
336 wxString params;
338 auto commandId = GetSquashedName(GetSymbol().Internal());
339 params = commandId.GET() + ":" + params;
340
341 auto path = SelectFile(FileNames::Operation::Presets,
342 XO("Export Effect Parameters"),
343 wxEmptyString,
344 wxEmptyString,
345 wxEmptyString,
346 PresetTypes(),
347 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
348 nullptr);
349 if (path.empty()) {
350 return;
351 }
352
353 // Create/Open the file
354 wxFFile f(path, wxT("wb"));
355 if (!f.IsOpened())
356 {
358 XO("Could not open file: \"%s\"").Format( path ),
359 XO("Error Saving Effect Presets"),
360 wxICON_EXCLAMATION,
361 NULL);
362 return;
363 }
364
365 f.Write(params);
366 if (f.Error())
367 {
369 XO("Error writing to file: \"%s\"").Format( path ),
370 XO("Error Saving Effect Presets"),
371 wxICON_EXCLAMATION,
372 NULL);
373 }
374
375 f.Close();
376
377
378 //SetWindowTitle();
379
380}
381
383{
384 wxString params;
385
386 auto path = SelectFile(FileNames::Operation::Presets,
387 XO("Import Effect Parameters"),
388 wxEmptyString,
389 wxEmptyString,
390 wxEmptyString,
391 PresetTypes(),
392 wxFD_OPEN | wxRESIZE_BORDER,
393 nullptr);
394 if (path.empty()) {
395 return {};
396 }
397
398 wxFFile f(path);
399 if (!f.IsOpened())
400 return {};
401
402 OptionalMessage result{};
403
404 if (f.ReadAll(&params)) {
405 wxString ident = params.BeforeFirst(':');
406 params = params.AfterFirst(':');
407
408 auto commandId = GetSquashedName(GetSymbol().Internal());
409
410 if (ident != commandId) {
411 // effect identifiers are a sensible length!
412 // must also have some params.
413 if ((params.Length() < 2 ) || (ident.Length() < 2) || (ident.Length() > 30))
414 {
416 /* i18n-hint %s will be replaced by a file name */
417 XO("%s: is not a valid presets file.\n")
418 .Format(wxFileNameFromPath(path)));
419 }
420 else
421 {
423 /* i18n-hint %s will be replaced by a file name */
424 XO("%s: is for a different Effect, Generator or Analyzer.\n")
425 .Format(wxFileNameFromPath(path)));
426 }
427 return {};
428 }
430 }
431
432 //SetWindowTitle();
433
434 return result;
435}
436
438{
439 return false;
440}
441
443{
444}
445
446// EffectPlugin implementation
447
449{
450 return *this;
451}
452
454{
455 if( !IsBatchProcessing() && FindProject() )
458}
459
461{
462 return wxT("SavedState");
463}
464
465// Effect implementation
466
468 const EffectSettings &settings, wxString & parms) const
469{
472 S.mpEap = &eap;
473 if( VisitSettings( S, settings ) ){
474 ;// got eap value using VisitSettings.
475 }
476 // Won't be needed in future
477 else if (!SaveSettings(settings, eap))
478 {
479 return false;
480 }
481
482 return eap.GetParameters(parms);
483}
484
486 const wxString & parms, EffectSettings &settings) const
487{
488 // If the string starts with one of certain significant substrings,
489 // then the rest of the string is reinterpreted as part of a registry key,
490 // and a user or factory preset is then loaded.
491 // (Where did these prefixes come from? See EffectPresetsDialog; and
492 // ultimately the uses of it by EffectManager::GetPreset, which is used by
493 // the macro management dialog)
494 wxString preset = parms;
495 OptionalMessage result;
496 if (preset.StartsWith(kUserPresetIdent))
497 {
498 preset.Replace(kUserPresetIdent, wxEmptyString, false);
500 }
501 else if (preset.StartsWith(kFactoryPresetIdent))
502 {
503 preset.Replace(kFactoryPresetIdent, wxEmptyString, false);
504 auto presets = GetFactoryPresets();
505 result = LoadFactoryPreset(
506 make_iterator_range( presets ).index( preset ), settings );
507 }
508 else if (preset.StartsWith(kCurrentSettingsIdent))
509 {
510 preset.Replace(kCurrentSettingsIdent, wxEmptyString, false);
512 }
513 else if (preset.StartsWith(kFactoryDefaultsIdent))
514 {
515 preset.Replace(kFactoryDefaultsIdent, wxEmptyString, false);
517 }
518 else
519 {
520 // If the string did not start with any of the significant substrings,
521 // then use VisitSettings or LoadSettings to reinterpret it,
522 // or use LoadSettings.
523 // This interprets what was written by SaveSettings, above.
524 CommandParameters eap(parms);
526 S.SetForValidating( &eap );
527 // VisitSettings returns false if not defined for this effect.
528 // To do: fix const_cast in use of VisitSettings
529 if ( !const_cast<Effect*>(this)->VisitSettings(S, settings) ) {
530 // the old method...
531 if (LoadSettings(eap, settings))
532 return { nullptr };
533 }
534 else if( !S.bOK )
535 result = {};
536 else{
537 result = { nullptr };
538 S.SetForWriting( &eap );
539 const_cast<Effect*>(this)->VisitSettings(S, settings);
540 }
541 }
542
543 if (!result)
544 {
546 XO("%s: Could not load settings below. Default settings will be used.\n\n%s")
547 .Format( GetName(), preset ) );
548 // We are using default settings and we still wish to continue.
549 result = { nullptr };
550 //return false;
551 }
552 return result;
553}
554
555unsigned Effect::TestUIFlags(unsigned mask) {
556 return mask & mUIFlags;
557}
558
560{
561 return mIsBatch;
562}
563
565{
566 mIsBatch = true;
567 // Save effect's internal state in a special registry path
568 // just for this purpose
569 // If effect is not stateful, this step doesn't really matter, and the
570 // settings object is a dummy
571 auto dummySettings = MakeSettings();
572 SaveUserPreset(GetSavedStateGroup(), dummySettings);
573}
574
576{
577 mIsBatch = false;
578 // Restore effect's internal state from registry
579 // If effect is not stateful, this call doesn't really matter, and the
580 // settings object is a dummy
581 auto dummySettings = MakeSettings();
582 // Ignore failure
583 (void ) LoadUserPreset(GetSavedStateGroup(), dummySettings);
584}
585
587{
589 region.setTimes( mT0, mT1 );
590
591 return delegate.DoEffect(settings, mProjectRate, mTracks, mFactory,
592 region, mUIFlags, nullptr, nullptr, nullptr);
593}
594
595std::unique_ptr<EffectUIValidator> Effect::PopulateOrExchange(
597 const EffectOutputs *)
598{
599 return nullptr;
600}
601
603{
604 return true;
605}
606
608{
609 return true;
610}
611
612bool Effect::EnableApply(bool enable)
613{
614 // May be called during initialization, so try to find the dialog
615 wxWindow *dlg = mUIDialog;
616 if (!dlg && mUIParent)
617 {
618 dlg = wxGetTopLevelParent(mUIParent);
619 }
620
621 if (dlg)
622 {
623 wxWindow *apply = dlg->FindWindow(wxID_APPLY);
624
625 // Don't allow focus to get trapped
626 if (!enable)
627 {
628 wxWindow *focus = dlg->FindFocus();
629 if (focus == apply)
630 {
631 dlg->FindWindow(wxID_CLOSE)->SetFocus();
632 }
633 }
634
635 if (apply)
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 // Don't allow focus to get trapped
659 if (!enable)
660 {
661 wxWindow *focus = dlg->FindFocus();
662 if (focus == play)
663 {
664 dlg->FindWindow(wxID_CLOSE)->SetFocus();
665 }
666 }
667
668 play->Enable(enable);
669 }
670 }
671
672 return enable;
673}
674
675bool Effect::TotalProgress(double frac, const TranslatableString &msg) const
676{
677 auto updateResult = (mProgress ?
678 mProgress->Poll(frac * 1000, 1000, msg) :
680 return (updateResult != ProgressResult::Success);
681}
682
684 int whichTrack, double frac, const TranslatableString &msg) const
685{
686 auto updateResult = (mProgress ?
687 mProgress->Poll((whichTrack + frac) * 1000,
688 (double) mNumTracks * 1000, msg) :
690 return (updateResult != ProgressResult::Success);
691}
692
694 int whichGroup, double frac, const TranslatableString &msg) const
695{
696 auto updateResult = (mProgress ?
697 mProgress->Poll((whichGroup + frac) * 1000,
698 (double) mNumGroups * 1000, msg) :
700 return (updateResult != ProgressResult::Success);
701}
702
704 const WaveTrack &track, const WaveTrack *pRight,
705 sampleCount *start, sampleCount *len)
706{
707 auto t0 = std::max( mT0, track.GetStartTime() );
708 auto t1 = std::min( mT1, track.GetEndTime() );
709
710 if ( pRight ) {
711 t0 = std::min( t0, std::max( mT0, pRight->GetStartTime() ) );
712 t1 = std::max( t1, std::min( mT1, pRight->GetEndTime() ) );
713 }
714
715 if (t1 > t0) {
716 *start = track.TimeToLongSamples(t0);
717 auto end = track.TimeToLongSamples(t1);
718 *len = end - *start;
719 }
720 else {
721 *start = 0;
722 *len = 0;
723 }
724}
725
726//
727// private methods
728//
729// Use this method to copy the input tracks to mOutputTracks, if
730// doing the processing on them, and replacing the originals only on success (and not cancel).
731// Copy the group tracks that have tracks selected
732// If not all sync-locked selected, then only selected wave tracks.
733void Effect::CopyInputTracks(bool allSyncLockSelected)
734{
735 // Reset map
736 mIMap.clear();
737 mOMap.clear();
738
740 const_cast<AudacityProject*>( FindProject() ) // how to remove this const_cast?
741 );
742
743 auto trackRange = mTracks->Any() +
744 [&] (const Track *pTrack) {
745 return allSyncLockSelected
747 : track_cast<const WaveTrack*>( pTrack ) && pTrack->GetSelected();
748 };
749
750 t2bHash added;
751
752 for (auto aTrack : trackRange)
753 {
754 Track *o = mOutputTracks->Add(aTrack->Duplicate());
755 mIMap.push_back(aTrack);
756 mOMap.push_back(o);
757 }
758}
759
760Track *Effect::AddToOutputTracks(const std::shared_ptr<Track> &t)
761{
762 mIMap.push_back(NULL);
763 mOMap.push_back(t.get());
764 return mOutputTracks->Add(t);
765}
766
768 : mpEffect(pEffect)
769{
770 if(!name.empty())
772 else
774}
775
777{
778 mpEffect = that.mpEffect;
779 mpTrack = that.mpTrack;
780 that.Commit();
781}
782
784{
785 mpEffect = nullptr;
786}
787
789{
790 if (mpEffect) {
791 // not committed -- DELETE the label track
792 mpEffect->mTracks->Remove(mpTrack);
793 }
794}
795
796auto Effect::AddAnalysisTrack(const wxString &name) -> std::shared_ptr<AddedAnalysisTrack>
797{
798 return std::shared_ptr<AddedAnalysisTrack>
799 { safenew AddedAnalysisTrack{ this, name } };
800}
801
803 (Effect *pEffect, const LabelTrack *pOrigTrack, const wxString &name)
804 : mpEffect(pEffect)
805{
806 // copy LabelTrack here, so it can be undone on cancel
807 auto newTrack = pOrigTrack->Copy(pOrigTrack->GetStartTime(), pOrigTrack->GetEndTime());
808
809 mpTrack = static_cast<LabelTrack*>(newTrack.get());
810
811 // Why doesn't LabelTrack::Copy complete the job? :
812 mpTrack->SetOffset(pOrigTrack->GetStartTime());
813 if (!name.empty())
815
816 // mpOrigTrack came from mTracks which we own but expose as const to subclasses
817 // So it's okay that we cast it back to const
819 pEffect->mTracks->Replace(const_cast<LabelTrack*>(pOrigTrack),
820 newTrack );
821}
822
824{
825 mpEffect = that.mpEffect;
826 mpTrack = that.mpTrack;
827 mpOrigTrack = std::move(that.mpOrigTrack);
828 that.Commit();
829}
830
832{
833 mpEffect = nullptr;
834}
835
837{
838 if (mpEffect) {
839 // not committed -- DELETE the label track
840 // mpOrigTrack came from mTracks which we own but expose as const to subclasses
841 // So it's okay that we cast it back to const
842 mpEffect->mTracks->Replace(mpTrack, mpOrigTrack);
843 }
844}
845
847 (const LabelTrack *pOrigTrack, const wxString &name) -> ModifiedAnalysisTrack
848{
849 return{ this, pOrigTrack, name };
850}
851
853{
854 return false;
855}
856
858 const EffectSettings &, double previewLength) const
859{
860 return previewLength;
861}
862
864 long style, const TranslatableString &titleStr) const
865{
866 auto title = titleStr.empty()
867 ? GetName()
868 : XO("%s: %s").Format( GetName(), titleStr );
869 return AudacityMessageBox( message, title, style, mUIParent );
870}
872{
873 return this;
874}
875
878 wxWindow *pParent)
879 : EffectUIValidator{ effect, access }, mpParent{ pParent }
880{
881}
882
884{
885 Disconnect();
886}
887
889{
890 bool result {};
892 result = mEffect.ValidateUI(settings);
893 return nullptr;
894 });
895 return result;
896}
897
899{
900 return mEffect.IsGraphicalUI();
901}
902
904{
905 if (mpParent) {
906 mpParent->PopEventHandler();
907 mpParent = nullptr;
908 }
909}
wxT("CloseDown"))
@ Internal
Indicates internal failure from Audacity.
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
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:325
static const int kPlayID
Definition: Effect.cpp:43
std::unordered_map< void *, bool > t2bHash
Definition: Effect.cpp:45
#define BUILTIN_EFFECT_PREFIX
Definition: Effect.h:19
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::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
EffectType
@ EffectTypeNone
std::function< DialogFactoryResults(wxWindow &parent, EffectPlugin &, EffectUIClientInterface &, EffectSettingsAccess &) > EffectDialogFactory
Type of function that creates a dialog for an effect.
Definition: EffectPlugin.h:41
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:431
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
bool ValidateUI() override
Calls mEffect.ValidateUI()
Definition: Effect.cpp:888
~DefaultEffectUIValidator() override
Calls Disconnect.
Definition: Effect.cpp:883
DefaultEffectUIValidator(EffectUIClientInterface &effect, EffectSettingsAccess &access, wxWindow *pParent=nullptr)
Definition: Effect.cpp:876
wxWindow * mpParent
Definition: Effect.h:57
void Disconnect() override
On the first call only, may disconnect from further event handling.
Definition: Effect.cpp:903
bool IsGraphicalUI() override
Definition: Effect.cpp:898
LabelTrack * mpTrack
Definition: Effect.h:261
std::shared_ptr< Track > mpOrigTrack
Definition: Effect.h:293
int mNumTracks
Definition: EffectBase.h:138
double mT1
Definition: EffectBase.h:109
std::shared_ptr< TrackList > mOutputTracks
Definition: EffectBase.h:107
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:103
TrackList * mTracks
Definition: EffectBase.h:127
std::vector< Track * > mOMap
Definition: EffectBase.h:136
double mProjectRate
Definition: EffectBase.h:101
BasicUI::ProgressDialog * mProgress
Definition: EffectBase.h:100
int mNumGroups
Definition: EffectBase.h:139
std::vector< Track * > mIMap
Definition: EffectBase.h:135
wxWeakRef< wxDialog > mUIDialog
This weak pointer may be the same as mUIParent, or null.
Definition: EffectBase.h:121
double mT0
Definition: EffectBase.h:108
unsigned mUIFlags
Definition: EffectBase.h:115
const AudacityProject * FindProject() const
Definition: EffectBase.cpp:319
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:63
bool SaveSettings(const EffectSettings &settings, CommandParameters &parms) const override
Store settings as keys and values.
Definition: Effect.cpp:223
RealtimeSince RealtimeSupport() const override
Since which version of Audacity has the effect supported realtime?
Definition: Effect.cpp:122
const EffectSettingsManager & GetDefinition() const override
Definition: Effect.cpp:448
bool TrackGroupProgress(int whichGroup, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:693
void ShowOptions() override
Definition: Effect.cpp:442
bool SaveUserPreset(const RegistryPath &name, const EffectSettings &settings) const override
Save settings in the configuration file as a user-named preset.
Definition: Effect.cpp:251
void SetBatchProcessing() override
Definition: Effect.cpp:564
OptionalMessage LoadFactoryDefaults(EffectSettings &settings) const override
Definition: Effect.cpp:273
bool IsGraphicalUI() override
Definition: Effect.cpp:303
EffectUIClientInterface * GetEffectUIClientInterface() override
Returns the EffectUIClientInterface instance for this effect.
Definition: Effect.cpp:871
bool VisitSettings(SettingsVisitor &visitor, EffectSettings &settings) override
Definition: Effect.cpp:210
bool SaveSettingsAsString(const EffectSettings &settings, wxString &parms) const override
Definition: Effect.cpp:467
wxWeakRef< wxDialog > mHostUIDialog
This smart pointer tracks the lifetime of the dialog.
Definition: Effect.h:306
void CopyInputTracks(bool allSyncLockSelected=false)
Definition: Effect.cpp:733
OptionalMessage LoadSettingsFromString(const wxString &parms, EffectSettings &settings) const override
Definition: Effect.cpp:485
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={}) const
Definition: Effect.cpp:863
Effect()
Definition: Effect.cpp:58
bool EnableApply(bool enable=true)
Definition: Effect.cpp:612
bool EnablePreview(bool enable=true)
Definition: Effect.cpp:644
bool SupportsAutomation() const override
Whether the effect has any automatable controls.
Definition: Effect.cpp:127
bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const override
Restore settings from keys and values.
Definition: Effect.cpp:230
virtual const EffectParameterMethods & Parameters() const
Definition: Effect.cpp:141
wxWindow * mUIParent
Definition: Effect.h:307
TranslatableString GetDescription() const override
Definition: Effect.cpp:93
virtual NumericFormatSymbol GetSelectionFormat()
Definition: Effect.cpp:453
void ExportPresets(const EffectSettings &settings) const override
Definition: Effect.cpp:334
bool mIsBatch
Definition: Effect.h:315
double CalcPreviewInputLength(const EffectSettings &settings, double previewLength) const override
Default implementation returns previewLength
Definition: Effect.cpp:857
OptionalMessage LoadFactoryPreset(int id, EffectSettings &settings) const override
Definition: Effect.cpp:268
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:165
bool TotalProgress(double frac, const TranslatableString &={}) const
Definition: Effect.cpp:675
Track * AddToOutputTracks(const std::shared_ptr< Track > &t)
Definition: Effect.cpp:760
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:683
bool TransferDataFromWindow(EffectSettings &settings) override
Update the given settings from controls.
Definition: Effect.cpp:607
wxString GetVersion() const override
Definition: Effect.cpp:88
bool CheckWhetherSkipEffect(const EffectSettings &settings) const override
Default implementation returns false.
Definition: Effect.cpp:852
PluginPath GetPath() const override
Definition: Effect.cpp:73
EffectType GetType() const override
Type determines how it behaves.
Definition: Effect.cpp:100
wxString GetSavedStateGroup()
Definition: Effect.cpp:460
OptionalMessage ImportPresets(EffectSettings &settings) override
Definition: Effect.cpp:382
bool IsBatchProcessing() const override
Definition: Effect.cpp:559
bool HasOptions() override
Definition: Effect.cpp:437
bool Delegate(Effect &delegate, EffectSettings &settings)
Re-invoke DoEffect on another Effect object that implements the work.
Definition: Effect.cpp:586
int ShowClientInterface(wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal) override
Definition: Effect.cpp:147
virtual ~Effect()
Definition: Effect.cpp:62
VendorSymbol GetVendor() const override
Definition: Effect.cpp:83
bool CloseUI() override
Definition: Effect.cpp:313
OptionalMessage LoadUserPreset(const RegistryPath &name, EffectSettings &settings) const override
Definition: Effect.cpp:238
ComponentInterfaceSymbol GetSymbol() const override
Definition: Effect.cpp:78
ModifiedAnalysisTrack ModifyAnalysisTrack(const LabelTrack *pOrigTrack, const wxString &name=wxString())
Definition: Effect.cpp:847
EffectFamilySymbol GetFamily() const override
Report identifier and user-visible name of the effect protocol.
Definition: Effect.cpp:105
void UnsetBatchProcessing() override
Definition: Effect.cpp:575
bool IsDefault() const override
Whether the effect sorts "above the line" in the menus.
Definition: Effect.cpp:117
virtual std::unique_ptr< EffectUIValidator > PopulateOrExchange(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs)
Add controls to effect panel; always succeeds.
Definition: Effect.cpp:595
unsigned TestUIFlags(unsigned mask)
Definition: Effect.cpp:555
bool CanExportPresets() override
Definition: Effect.cpp:320
std::unique_ptr< EffectUIValidator > PopulateUI(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
Adds controls to a panel that is given as the parent window of S
Definition: Effect.cpp:280
bool TransferDataToWindow(const EffectSettings &settings) override
Update controls for the settings.
Definition: Effect.cpp:602
RegistryPaths GetFactoryPresets() const override
Report names of factory presets.
Definition: Effect.cpp:263
void GetBounds(const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
Definition: Effect.cpp:703
std::shared_ptr< AddedAnalysisTrack > AddAnalysisTrack(const wxString &name=wxString())
Definition: Effect.cpp:796
bool IsInteractive() const override
Whether the effect needs a dialog for entry of settings.
Definition: Effect.cpp:112
bool ValidateUI(EffectSettings &) override
Definition: Effect.cpp:308
Performs effect computation.
uint64_t SampleCount
Hold values to send to effect output meters.
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:58
static const wxString kFactoryPresetIdent
Definition: EffectPlugin.h:59
static const wxString kCurrentSettingsIdent
Definition: EffectPlugin.h:60
static const wxString kFactoryDefaultsIdent
Definition: EffectPlugin.h:61
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
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, EffectUIValidator *pValidator, bool forceModal=false)=0
virtual bool ValidateUI(EffectSettings &settings)=0
virtual bool IsGraphicalUI()=0
Interface for transferring values from a panel of effect controls.
EffectSettingsAccess & mAccess
EffectUIClientInterface & mEffect
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)
SampleCount GetLatency(const EffectSettings &settings, double sampleRate) const override
Definition: Effect.cpp:52
bool Process(EffectSettings &settings) override
Actually do the effect here.
Definition: Effect.cpp:47
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:132
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:724
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1437
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:2005
double GetEndTime() const override
Get the time at which the last clip in the track ends, plus recorded stuff.
Definition: WaveTrack.cpp:2025
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
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)
static RegisteredToolbarFactory factory
Externalized state of a plug-in.