From 111278c61b53e2689d51f166894bf2250612cfd7 Mon Sep 17 00:00:00 2001 From: "v.audacity" Date: Sat, 3 Mar 2012 01:34:14 +0000 Subject: [PATCH] In WaveTrack.*: * Fix P2 bug described by Bill Wharrie in "Problem dragging clips between tracks with different sample rates" thread on audacity-quality. Made sure the clips get resampled to the destination WaveTrack rate, and marked changed. * Comment out unused override of WaveTrack::MoveClipToTrack(). * Added an ANSWER-ME about what appears to be a useless declaration and assignment. In WaveClip.cpp, remove wxASSERT that Michael was trying to convince me to do yesterday. In debugging this, found a case when it's not a bad call. Thanks, Michael! :-) In TrackPanel.cpp, removed some cruft. --- src/TrackPanel.cpp | 2 -- src/WaveClip.cpp | 7 +------ src/WaveTrack.cpp | 19 +++++++++++-------- src/WaveTrack.h | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 5ebd21138..955d5b711 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -7668,8 +7668,6 @@ bool TrackPanel::MoveClipToTrack(WaveClip *clip, WaveTrack* dst) src2->MoveClipToTrack(clip2, dst2); // update the captured clip array. - bool did1, did2; - did1 = did2 = false; for (i = 0; i < mCapturedClipArray.GetCount(); i++) { if (clip && mCapturedClipArray[i].clip == clip) { mCapturedClipArray[i].track = dst; diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index d73926f7c..dcd27e418 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -1242,14 +1242,9 @@ bool WaveClip::Paste(double t0, WaveClip* other) sampleCount s0; TimeToSamplesClip(t0, &s0); - // Check whether sample formats match. + // Force sample formats to match. if (pastedClip->mSequence->GetSampleFormat() != mSequence->GetSampleFormat()) - { - // In debug mode, fail because that's probably a bad call to this method. - // In release, adjust the source to match the destination, so we don't do a bad paste. - wxASSERT(false); pastedClip->ConvertToSampleFormat(mSequence->GetSampleFormat()); - } bool result = false; if (mSequence->Paste(s0, pastedClip->mSequence)) diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 31fe160e9..10c8176d5 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -1839,21 +1839,24 @@ int WaveTrack::GetNumClips() const return mClips.GetCount(); } -void WaveTrack::MoveClipToTrack(int clipIndex, WaveTrack* dest) -{ - WaveClipList::compatibility_iterator node = mClips.Item(clipIndex); - WaveClip* clip = node->GetData(); - mClips.DeleteNode(node); - dest->mClips.Append(clip); -} +// unused +//void WaveTrack::MoveClipToTrack(int clipIndex, WaveTrack* dest) +//{ +// WaveClipList::compatibility_iterator node = mClips.Item(clipIndex); +// WaveClip* clip = node->GetData(); +// mClips.DeleteNode(node); +// dest->mClips.Append(clip); +//} void WaveTrack::MoveClipToTrack(WaveClip *clip, WaveTrack* dest) { for (WaveClipList::compatibility_iterator it=GetClipIterator(); it; it=it->GetNext()) { if (it->GetData() == clip) { - WaveClip* clip = it->GetData(); + WaveClip* clip = it->GetData(); // ANSWER-ME: Why declare and assign this to another variable, when we just verified the 'clip' parameter is the right value?! mClips.DeleteNode(it); dest->mClips.Append(clip); + clip->Resample(dest->GetRate()); + clip->MarkChanged(); return; // JKC iterator is now 'defunct' so better return straight away. } } diff --git a/src/WaveTrack.h b/src/WaveTrack.h index d2f2e8f49..da487ccf2 100644 --- a/src/WaveTrack.h +++ b/src/WaveTrack.h @@ -317,7 +317,7 @@ class AUDACITY_DLL_API WaveTrack: public Track { // Move a clip into a new track. This will remove the clip // in this cliplist and add it to the cliplist of the // other clip. No fancy additional stuff is done. - void MoveClipToTrack(int clipIndex, WaveTrack* dest); + // unused void MoveClipToTrack(int clipIndex, WaveTrack* dest); void MoveClipToTrack(WaveClip *clip, WaveTrack* dest); // Remove the clip from the track and return a pointer to it.