From 518df314ebca6b8fad99c628a996d246614fd319 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 13 Sep 2018 10:17:59 -0400 Subject: [PATCH 1/3] Rewrite GetLink(ed) in vamp effects --- src/effects/vamp/VampEffect.cpp | 40 ++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/effects/vamp/VampEffect.cpp b/src/effects/vamp/VampEffect.cpp index bb6e95b12..e326594c3 100644 --- a/src/effects/vamp/VampEffect.cpp +++ b/src/effects/vamp/VampEffect.cpp @@ -299,25 +299,25 @@ bool VampEffect::Init() { mRate = 0.0; - for (auto left : inputTracks()->Leaders< const WaveTrack >() ) - { - if (mRate == 0.0) - { - mRate = left->GetRate(); - } - - if (left->GetLinked()) - { - auto right = static_cast( left->GetLink() ); + // PRL: this loop checked that channels of a track have the same rate, + // but there was no check that all tracks have one rate, and only the first + // is remembered in mRate. Is that correct? + for (auto leader : inputTracks()->Leaders()) { + auto channelGroup = TrackList::Channels( leader ); + auto rate = (*channelGroup.first++) -> GetRate(); + for(auto channel : channelGroup) { + if (rate != channel->GetRate()) // PRL: Track rate might not match individual clip rates. // So is this check not adequate? - if (left->GetRate() != right->GetRate()) - { - Effect::MessageBox(_("Sorry, Vamp Plug-ins cannot be run on stereo tracks where the individual channels of the track do not match.")); - return false; + { + // TODO: more-than-two-channels-message + Effect::MessageBox(_("Sorry, Vamp Plug-ins cannot be run on stereo tracks where the individual channels of the track do not match.")); + return false; } } + if (mRate == 0.0) + mRate = rate; } if (mRate <= 0.0) @@ -361,22 +361,26 @@ bool VampEffect::Process() std::vector> addedTracks; - for (auto left : inputTracks()->Leaders< const WaveTrack >() ) + for (auto leader : inputTracks()->Leaders()) { + auto channelGroup = TrackList::Channels(leader); + auto left = *channelGroup.first++; + sampleCount lstart, rstart = 0; sampleCount len; GetSamples(left, &lstart, &len); unsigned channels = 1; - const WaveTrack *right{}; - if (left->GetLinked()) + const WaveTrack *right = *channelGroup.first++; + if (right) { - right = static_cast< const WaveTrack* >( left->GetLink() ); channels = 2; GetSamples(right, &rstart, &len); } + // TODO: more-than-two-channels + size_t step = mPlugin->getPreferredStepSize(); size_t block = mPlugin->getPreferredBlockSize(); From 48ae1eb3c98d5a9542ee5a25889f6a9afb0cf47e Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 20 Apr 2017 11:45:18 -0400 Subject: [PATCH 2/3] Rewrite GetLink(ed) in SoundTouch --- src/effects/SoundTouchEffect.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/effects/SoundTouchEffect.cpp b/src/effects/SoundTouchEffect.cpp index dd77863c9..dba8b3e83 100644 --- a/src/effects/SoundTouchEffect.cpp +++ b/src/effects/SoundTouchEffect.cpp @@ -120,10 +120,10 @@ bool EffectSoundTouch::ProcessWithTimeWarper(const TimeWarper &warper) // Process only if the right marker is to the right of the left marker if (mCurT1 > mCurT0) { - if (leftTrack->GetLinked()) { + // TODO: more-than-two-channels + auto channels = TrackList::Channels(leftTrack); + if (auto rightTrack = * ++ channels.begin()) { double t; - // Assume linked track is wave - WaveTrack* rightTrack = static_cast(leftTrack->GetLink()); //Adjust bounds by the right tracks markers t = rightTrack->GetStartTime(); From 22c85dd99c882a2d16d3050c86c761859d5422bd Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 20 Apr 2017 11:52:28 -0400 Subject: [PATCH 3/3] Rewrite GetLink(ed) in SBSMS --- src/effects/SBSMSEffect.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/effects/SBSMSEffect.cpp b/src/effects/SBSMSEffect.cpp index ec9023553..a0e1cac0e 100644 --- a/src/effects/SBSMSEffect.cpp +++ b/src/effects/SBSMSEffect.cpp @@ -252,11 +252,11 @@ bool EffectSBSMS::Process() auto start = leftTrack->TimeToLongSamples(mCurT0); auto end = leftTrack->TimeToLongSamples(mCurT1); - WaveTrack* rightTrack = NULL; - if (leftTrack->GetLinked()) { + // TODO: more-than-two-channels + WaveTrack *rightTrack = + * ++ TrackList::Channels(leftTrack).begin(); + if (rightTrack) { double t; - // Assume linked track is wave or null - rightTrack = static_cast(leftTrack->GetLink()); //Adjust bounds by the right tracks markers t = rightTrack->GetStartTime();