36 std::vector<std::pair<double, double> > clipStartEndTimes;
38 std::vector<std::pair<double, double> > clipRealStartEndTimes;
40 std::vector<wxString> clipNames;
41 for (
const auto &clip : oldTrack.
GetClips()) {
42 auto clipStartT = clip->GetPlayStartTime();
43 auto clipEndT = clip->GetPlayEndTime();
44 if ( clipEndT <= startT )
46 if ( clipStartT >= startT + lenT )
50 clipRealStartEndTimes.emplace_back(clipStartT, clipEndT);
52 if ( clipStartT < startT )
54 if( clipEndT > startT + lenT )
55 clipEndT = startT + lenT;
58 clipStartEndTimes.emplace_back(clipStartT, clipEndT);
59 clipNames.push_back(clip->GetName());
62 for (
unsigned int i = 0; i < clipStartEndTimes.size(); ++i) {
64 auto [start,
end] = clipStartEndTimes[i];
66 auto toClipOutput = newContents.
Copy(start - startT,
end - startT);
68 oldTrack.
Paste(start, toClipOutput.get());
78 auto [realStart, realEnd] = clipRealStartEndTimes[i];
79 if ((realStart != start || realEnd !=
end) &&
80 !(realStart <= startT && realEnd >= startT + lenT) )
81 oldTrack.
Join(realStart, realEnd);
void PasteOverPreservingClips(WaveTrack &oldTrack, sampleCount start, sampleCount len, WaveTrack &newContents)
Substitute new contents into existing track, preserving clip boundaries.
double LongSamplesToTime(sampleCount pos) const
Convert correctly between a number of samples and an (absolute) time in seconds.
void SetName(const wxString &name)
A Track that contains audio waveform data.
void Paste(double t0, const Track *src) override
void Join(double t0, double t1)
WaveClip * GetClipAtTime(double time)
void Clear(double t0, double t1) override
double GetRate() const override
WaveClipHolders & GetClips()
Track::Holder Copy(double t0, double t1, bool forClipboard=true) const override
Positions or offsets within audio files need a wide type.
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.