1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-20 23:51:18 +01:00

Use TypeSwitch and track_cast

This commit is contained in:
Paul Licameli
2017-04-11 18:16:03 -04:00
parent fd10ed26cd
commit 51842fc78b
13 changed files with 806 additions and 872 deletions

View File

@@ -576,40 +576,43 @@ void NoteTrack::Paste(double t, const Track *src)
// the destination track).
//Check that src is a non-NULL NoteTrack
if (src == NULL || src->GetKind() != Track::Note)
bool bOk = src && src->TypeSwitch< bool >( [&](const NoteTrack *other) {
auto myOffset = this->GetOffset();
if (t < myOffset) {
// workaround strange behavior described at
// http://bugzilla.audacityteam.org/show_bug.cgi?id=1735#c3
SetOffset(t);
InsertSilence(t, myOffset - t);
}
double delta = 0.0;
auto &seq = GetSeq();
auto offset = other->GetOffset();
if ( offset > 0 ) {
seq.convert_to_seconds();
seq.insert_silence( t - GetOffset(), offset );
t += offset;
// Is this needed or does Alg_seq::insert_silence take care of it?
//delta += offset;
}
// This seems to be needed:
delta += std::max( 0.0, t - GetEndTime() );
// This, not:
//delta += other->GetSeq().get_real_dur();
seq.paste(t - GetOffset(), &other->GetSeq());
AddToDuration( delta );
return true;
});
if ( !bOk )
// THROW_INCONSISTENCY_EXCEPTION; // ?
return;
auto myOffset = this->GetOffset();
if (t < myOffset) {
// workaround strange behavior described at
// http://bugzilla.audacityteam.org/show_bug.cgi?id=1735#c3
SetOffset(t);
InsertSilence(t, myOffset - t);
}
NoteTrack* other = (NoteTrack*)src;
double delta = 0.0;
auto &seq = GetSeq();
auto offset = other->GetOffset();
if ( offset > 0 ) {
seq.convert_to_seconds();
seq.insert_silence( t - GetOffset(), offset );
t += offset;
// Is this needed or does Alg_seq::insert_silence take care of it?
//delta += offset;
}
// This seems to be needed:
delta += std::max( 0.0, t - GetEndTime() );
// This, not:
//delta += other->GetSeq().get_real_dur();
seq.paste(t - GetOffset(), &other->GetSeq());
AddToDuration( delta );
;
}
void NoteTrack::Silence(double t0, double t1)