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

Method Finalize

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

Source from the content-addressed store, hash-verified

428}
429
430void SBSMSBase::Finalize(
431 WaveTrack &orig, const WaveTrack &out, const TimeWarper &warper)
432{
433 assert(orig.NChannels() == out.NChannels());
434 // Silenced samples will be inserted in gaps between clips, so capture where these
435 // gaps are for later deletion
436 std::vector<std::pair<double, double>> gaps;
437 double last = mT0;
438 auto clips = orig.SortedIntervalArray();
439 auto front = clips.front();
440 auto back = clips.back();
441 for (auto &clip : clips) {
442 auto st = clip->GetPlayStartTime();
443 auto et = clip->GetPlayEndTime();
444
445 if (st >= mT0 || et < mT1) {
446 if (mT0 < st && clip == front) {
447 gaps.push_back(std::make_pair(mT0, st));
448 }
449 else if (last < st && mT0 <= last ) {
450 gaps.push_back(std::make_pair(last, st));
451 }
452
453 if (et < mT1 && clip == back) {
454 gaps.push_back(std::make_pair(et, mT1));
455 }
456 }
457 last = et;
458 }
459
460 // Take the output track and insert it in place of the original sample data
461 orig.ClearAndPaste(mT0, mT1, out, true, true, &warper);
462
463 // Finally, recreate the gaps
464 for (auto gap : gaps) {
465 const auto st = orig.SnapToSample(gap.first);
466 const auto et = orig.SnapToSample(gap.second);
467 if (st >= mT0 && et <= mT1 && st != et)
468 orig.SplitDelete(warper.Warp(st), warper.Warp(et));
469 }
470}
471
472#endif

Callers

nothing calls this directly

Calls 9

SortedIntervalArrayMethod · 0.80
ClearAndPasteMethod · 0.80
SnapToSampleMethod · 0.80
NChannelsMethod · 0.45
GetPlayStartTimeMethod · 0.45
GetPlayEndTimeMethod · 0.45
push_backMethod · 0.45
SplitDeleteMethod · 0.45
WarpMethod · 0.45

Tested by

no test coverage detected