mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-04 09:39:42 +02:00
Bug 373/378 (P2) - Fix a case where one track of an aligned stereo pair could be moved independently
This commit is contained in:
parent
cf49d77dda
commit
fbe3a80ab1
@ -2626,12 +2626,14 @@ void TrackPanel::StartSlide(wxMouseEvent & event)
|
||||
Track *partner = mTracks->GetLink(vt);
|
||||
if (mCapturedClip && partner && partner->GetKind() == Track::Wave) {
|
||||
// WaveClip::GetClipAtX doesn't work unless the clip is on the screen and can return bad info otherwise
|
||||
// vt is guaranteed to be onscreen, so we ask for the approx. time at that point
|
||||
|
||||
sampleCount xSample = mCapturedClip->GetSampleNumberAtX(event.m_x);
|
||||
|
||||
if (xSample >= 0) {
|
||||
WaveClip *clip = ((WaveTrack *)partner)->GetClipAtSample(xSample);
|
||||
// instead calculate the time manually
|
||||
double rate = ((WaveTrack*)partner)->GetRate();
|
||||
double pps = mViewInfo->zoom;
|
||||
double tt = (event.m_x - GetLeftOffset()) / pps + mViewInfo->h;
|
||||
sampleCount s0 = (sampleCount)(tt * rate + 0.5);
|
||||
|
||||
if (s0 >= 0) {
|
||||
WaveClip *clip = ((WaveTrack *)partner)->GetClipAtSample(s0);
|
||||
if (clip) {
|
||||
mCapturedClipArray.Add(TrackClip(partner, clip));
|
||||
}
|
||||
|
@ -1030,18 +1030,6 @@ void WaveClip::GetDisplayRect(wxRect* r)
|
||||
*r = mDisplayRect;
|
||||
}
|
||||
|
||||
// only works if the clip is on screen an mDisplayRect is set.
|
||||
sampleCount WaveClip::GetSampleNumberAtX(int xcoord)
|
||||
{
|
||||
if (mDisplayRect.width > 0 &&
|
||||
xcoord >= mDisplayRect.x && xcoord < mDisplayRect.x + mDisplayRect.width) {
|
||||
float cursor = (xcoord - mDisplayRect.x) / mDisplayRect.width;
|
||||
return GetStartSample() + GetNumSamples() * cursor;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool WaveClip::Append(samplePtr buffer, sampleFormat format,
|
||||
sampleCount len, unsigned int stride /* = 1 */,
|
||||
XMLWriter* blockFileLog /*=NULL*/)
|
||||
|
@ -152,9 +152,6 @@ public:
|
||||
void ClearDisplayRect();
|
||||
void SetDisplayRect(const wxRect& r);
|
||||
void GetDisplayRect(wxRect* r);
|
||||
/// Get the absolute sample number at the x pixel specified by xcoord.
|
||||
/// Only works if the clip is onscreen (returned by WaveTrack::GetClipAtX)
|
||||
sampleCount GetSampleNumberAtX(int xcoord);
|
||||
|
||||
/** Whenever you do an operation to the sequence that will change the number
|
||||
* of samples (that is, the length of the clip), you will want to call this
|
||||
|
Loading…
x
Reference in New Issue
Block a user