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

Method Process

libraries/lib-builtin-effects/SBSMSBase.cpp:226–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226bool SBSMSBase::Process(EffectInstance &, EffectSettings &)
227{
228 bool bGoodResult = true;
229
230 //Iterate over each track
231 //all needed because this effect needs to introduce silence in the group tracks to keep sync
232 EffectOutputTracks outputs { *mTracks, GetType(), { { mT0, mT1 } }, true };
233 mCurTrackNum = 0;
234
235 double maxDuration = 0.0;
236
237 Slide rateSlide(rateSlideType,rateStart,rateEnd);
238 Slide pitchSlide(pitchSlideType,pitchStart,pitchEnd);
239 mTotalStretch = rateSlide.getTotalStretch();
240
241 outputs.Get().Any().VisitWhile(bGoodResult,
242 [&](auto &&fallthrough){ return [&](LabelTrack &lt) {
243 if (!(lt.GetSelected() || SyncLock::IsSyncLockSelected(lt)))
244 return fallthrough();
245 if (!ProcessLabelTrack(&lt))
246 bGoodResult = false;
247 }; },
248 [&](auto &&fallthrough){ return [&](WaveTrack &track) {
249 if (!track.GetSelected())
250 return fallthrough();
251
252 if (!track.NIntervals())
253 return fallthrough();
254
255 // Process only if the right marker is to the right of the left marker
256 if (mT1 > mT0) {
257 const auto start = track.TimeToLongSamples(mT0);
258 const auto end = track.TimeToLongSamples(mT1);
259
260 // TODO: more-than-two-channels
261 auto channels = track.Channels();
262 const auto leftTrack = (*channels.begin()).get();
263 const auto rightTrack = (channels.size() > 1)
264 ? (* ++ channels.first).get()
265 : nullptr;
266 if (rightTrack)
267 mCurTrackNum++; // Increment for rightTrack, too.
268
269 // SBSMS has a fixed sample rate - we just convert to its sample
270 // rate and then convert back
271 const float srTrack = track.GetRate();
272 const float srProcess = bLinkRatePitch ? srTrack : 44100.0;
273
274 // the resampler needs a callback to supply its samples
275 ResampleBuf rb;
276 const auto maxBlockSize = track.GetMaxBlockSize();
277 rb.blockSize = maxBlockSize;
278 rb.buf.reinit(rb.blockSize, true);
279 rb.leftTrack = leftTrack;
280 rb.rightTrack = rightTrack ? rightTrack : leftTrack;
281 rb.leftBuffer.reinit(maxBlockSize, true);
282 rb.rightBuffer.reinit(maxBlockSize, true);
283

Callers

nothing calls this directly

Calls 15

createTimeWarperFunction · 0.85
limitSampleBufferSizeFunction · 0.85
VisitWhileMethod · 0.80
TimeToLongSamplesMethod · 0.80
ChannelsMethod · 0.80
EmptyCopyMethod · 0.80
getTotalStretchMethod · 0.45
AnyMethod · 0.45
GetMethod · 0.45
GetSelectedMethod · 0.45
NIntervalsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected