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

Function EffectPreview

src/effects/EffectPreview.cpp:24–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22#include "WaveTrack.h"
23
24void EffectPreview(EffectBase &effect,
25 EffectSettingsAccess &access, std::function<void()> updateUI, bool dryOnly)
26{
27 auto cleanup0 = effect.BeginPreview(access.Get());
28
29 // These are temporary state in the Effect object that are meant be moved to
30 // a new class EffectContext
31 const auto numTracks = effect.mNumTracks;
32 const auto rate = effect.mProjectRate;
33 const auto &factory = effect.mFactory;
34 auto &mT0 = effect.mT0;
35 auto &mT1 = effect.mT1;
36 auto &mTracks = effect.mTracks;
37 auto &mProgress = effect.mProgress;
38 auto &mIsPreview = effect.mIsPreview;
39
40 // Get certain immutable properties of the effect
41 const auto previewFullSelection = effect.PreviewsFullSelection();
42 const auto isLinearEffect = effect.IsLinearEffect();
43
44 if (numTracks == 0) { // nothing to preview
45 return;
46 }
47
48 auto gAudioIO = AudioIO::Get();
49 if (gAudioIO->IsBusy()) {
50 return;
51 }
52
53 const auto FocusDialog = BasicUI::FindFocus();
54 assert(FocusDialog); // postcondition
55
56 double previewDuration;
57 bool isNyquist = effect.GetFamily() == NYQUISTEFFECTS_FAMILY;
58 bool isGenerator = effect.GetType() == EffectTypeGenerate;
59
60 // Mix a few seconds of audio from all of the tracks
61 double previewLen;
62 gPrefs->Read(wxT("/AudioIO/EffectsPreviewLen"), &previewLen, 6.0);
63
64 const auto &settings = access.Get();
65 if (isNyquist && isGenerator)
66 previewDuration = effect.CalcPreviewInputLength(settings, previewLen);
67 else
68 previewDuration = std::min(settings.extra.GetDuration(),
69 effect.CalcPreviewInputLength(settings, previewLen));
70
71 double t1 = mT0 + previewDuration;
72
73 if ((t1 > mT1) && !isGenerator) {
74 t1 = mT1;
75 }
76
77 if (t1 <= mT0)
78 return;
79
80 bool success = true;
81

Callers 2

OnPlayMethod · 0.85
OnPreviewMethod · 0.85

Calls 15

GetFunction · 0.85
FindFocusFunction · 0.85
finallyFunction · 0.85
valueRestorerFunction · 0.85
SetFocusFunction · 0.85
CreateFunction · 0.85
MixAndRenderFunction · 0.85
ShowErrorDialogFunction · 0.85
IsBusyMethod · 0.80
GetDurationMethod · 0.80
SetMuteMethod · 0.80
CountWaveTracksMethod · 0.80

Tested by

no test coverage detected