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

Method Process

libraries/lib-builtin-effects/RepeatBase.cpp:53–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51// Effect implementation
52
53bool RepeatBase::Process(EffectInstance&, EffectSettings&)
54{
55 // Set up mOutputTracks.
56 // This effect needs all for sync-lock grouping.
57 EffectOutputTracks outputs { *mTracks, GetType(), { { mT0, mT1 } }, true };
58
59 int nTrack = 0;
60 bool bGoodResult = true;
61 double maxDestLen = 0.0; // used to change selection to generated bit
62
63 outputs.Get().Any().VisitWhile(
64 bGoodResult,
65 [&](LabelTrack& track) {
66 if (SyncLock::IsSelectedOrSyncLockSelected(track))
67 {
68 if (!track.Repeat(mT0, mT1, repeatCount))
69 bGoodResult = false;
70 }
71 },
72 [&](auto&& fallthrough) {
73 return [&](WaveTrack& track) {
74 if (!track.GetSelected())
75 return fallthrough(); // Fall through to next lambda
76 auto start = track.TimeToLongSamples(mT0);
77 auto end = track.TimeToLongSamples(mT1);
78 auto len = end - start;
79 const double tLen = track.LongSamplesToTime(len);
80 const double tc = mT0 + tLen;
81
82 if (len <= 0)
83 return;
84
85 auto firstTemp =
86 std::static_pointer_cast<WaveTrack>(track.Copy(mT0, mT1));
87
88 auto t0 = tc;
89 for (size_t j = 0; j < repeatCount; ++j)
90 {
91 if (TrackProgress(nTrack, j / repeatCount))
92 {
93 // TrackProgress returns true on Cancel.
94 bGoodResult = false;
95 return;
96 }
97 track.Paste(t0, *firstTemp);
98 t0 += tLen;
99 }
100 if (t0 > maxDestLen)
101 maxDestLen = t0;
102
103 const auto compareIntervals = [](const auto& a, const auto& b) {
104 return a->Start() < b->Start();
105 };
106
107 const auto eps = 0.5 / track.GetRate();
108 auto sortedIntervals =
109 std::vector(track.Intervals().begin(), track.Intervals().end());
110 auto sourceIntervals = std::vector(

Callers

nothing calls this directly

Calls 15

VisitWhileMethod · 0.80
RepeatMethod · 0.80
TimeToLongSamplesMethod · 0.80
LongSamplesToTimeMethod · 0.80
IntervalsMethod · 0.80
AnyMethod · 0.45
GetMethod · 0.45
GetSelectedMethod · 0.45
CopyMethod · 0.45
PasteMethod · 0.45
StartMethod · 0.45
GetRateMethod · 0.45

Tested by

no test coverage detected