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

Method Process

libraries/lib-builtin-effects/PaulstretchBase.cpp:132–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132bool PaulstretchBase::Process(EffectInstance&, EffectSettings&)
133{
134 // Pass true because sync lock adjustment is needed
135 EffectOutputTracks outputs { *mTracks, GetType(), { { mT0, mT1 } }, true };
136 auto newT1 = mT1;
137 int count = 0;
138 // Process selected wave tracks first, to find the new t1 value
139 for (const auto track : outputs.Get().Selected<WaveTrack>())
140 {
141 double trackStart = track->GetStartTime();
142 double trackEnd = track->GetEndTime();
143 double t0 = mT0 < trackStart ? trackStart : mT0;
144 double t1 = mT1 > trackEnd ? trackEnd : mT1;
145 if (t1 > t0)
146 {
147 auto tempTrack = track->EmptyCopy();
148 const auto channels = track->Channels();
149 auto iter = tempTrack->Channels().begin();
150 for (const auto pChannel : channels)
151 {
152 if (!ProcessOne(*pChannel, **iter++, t0, t1, count++))
153 return false;
154 }
155 tempTrack->Flush();
156 newT1 = std::max(newT1, mT0 + tempTrack->GetEndTime());
157 PasteTimeWarper warper { t1, t0 + tempTrack->GetEndTime() };
158 constexpr auto preserve = false;
159 constexpr auto merge = true;
160 track->ClearAndPaste(t0, t1, *tempTrack, preserve, merge, &warper);
161 }
162 else
163 count += track->NChannels();
164 }
165
166 // Sync lock adjustment of other tracks
167 outputs.Get().Any().Visit(
168 [&](auto&& fallthrough) {
169 return [&](WaveTrack& track) {
170 if (!track.IsSelected())
171 fallthrough();
172 };
173 },
174 [&](Track& track) {
175 if (SyncLock::IsSyncLockSelected(track))
176 track.SyncLockAdjust(mT1, newT1);
177 });
178 mT1 = newT1;
179
180 outputs.Commit();
181
182 return true;
183}
184
185bool PaulstretchBase::ProcessOne(
186 const WaveChannel& track, WaveChannel& outputTrack, double t0, double t1,

Callers

nothing calls this directly

Calls 15

ProcessOneFunction · 0.85
maxFunction · 0.85
EmptyCopyMethod · 0.80
ChannelsMethod · 0.80
ClearAndPasteMethod · 0.80
GetMethod · 0.45
GetStartTimeMethod · 0.45
GetEndTimeMethod · 0.45
beginMethod · 0.45
FlushMethod · 0.45
NChannelsMethod · 0.45
VisitMethod · 0.45

Tested by

no test coverage detected