MCPcopy Create free account
hub / github.com/audacity/audacity / DoEffect

Method DoEffect

libraries/lib-effects/EffectBase.cpp:57–208  ·  view source on GitHub ↗

TODO: Lift the possible user-prompting part out of this function, so that the recursive paths into this function via Effect::Delegate are simplified, and we don't have both EffectSettings and EffectSettingsAccessPtr If pAccess is not null, settings should have come from its Get()

Source from the content-addressed store, hash-verified

55// and we don't have both EffectSettings and EffectSettingsAccessPtr
56// If pAccess is not null, settings should have come from its Get()
57bool EffectBase::DoEffect(EffectSettings &settings,
58 const InstanceFinder &finder,
59 double projectRate,
60 TrackList *list,
61 WaveTrackFactory *factory,
62 NotifyingSelectedRegion &selectedRegion,
63 unsigned flags,
64 const EffectSettingsAccessPtr &pAccess)
65{
66 auto cleanup0 = valueRestorer(mUIFlags, flags);
67 wxASSERT(selectedRegion.duration() >= 0.0);
68
69 mFactory = factory;
70 mProjectRate = projectRate;
71
72 SetTracks(list);
73 // Don't hold a dangling pointer when done
74 Finally Do([&]{ SetTracks(nullptr); });
75
76 // This is for performance purposes only, no additional recovery implied
77 auto &pProject = *const_cast<AudacityProject*>(FindProject()); // how to remove this const_cast?
78 TransactionScope trans(pProject, "Effect");
79
80 // Update track/group counts
81 CountWaveTracks();
82
83 bool isSelection = false;
84
85 auto duration = 0.0;
86 if (GetType() == EffectTypeGenerate)
87 GetConfig(GetDefinition(), PluginSettings::Private,
88 CurrentSettingsGroup(),
89 EffectSettingsExtra::DurationKey(), duration, GetDefaultDuration());
90
91 WaveTrack *newTrack{};
92 bool success = false;
93 auto oldDuration = duration;
94
95 auto cleanup = finally( [&] {
96 if (!success) {
97 if (newTrack) {
98 mTracks->Remove(*newTrack);
99 }
100 // On failure, restore the old duration setting
101 settings.extra.SetDuration(oldDuration);
102 }
103 else
104 trans.Commit();
105
106 mPresetNames.clear();
107 } );
108
109 // We don't yet know the effect type for code in the Nyquist Prompt, so
110 // assume it requires a track and handle errors when the effect runs.
111 if ((GetType() == EffectTypeGenerate || GetPath() == NYQUIST_PROMPT_ID) && (mNumTracks == 0)) {
112 auto track = mFactory->Create();
113 track->SetName(mTracks->MakeUniqueTrackName(WaveTrack::GetDefaultAudioTrackNamePreference()));
114 newTrack = mTracks->Add(track);

Callers 1

DelegateMethod · 0.45

Calls 15

valueRestorerFunction · 0.85
GetConfigFunction · 0.85
finallyFunction · 0.85
MakeUniqueTrackNameMethod · 0.80
setTimesMethod · 0.80
MakeProgressFunction · 0.50
RemoveMethod · 0.45
CommitMethod · 0.45
clearMethod · 0.45
CreateMethod · 0.45
SetNameMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected