| 126 | } |
| 127 | |
| 128 | bool ChangeSpeedBase::Process(EffectInstance&, EffectSettings&) |
| 129 | { |
| 130 | // Similar to SoundTouchBase::Process() |
| 131 | |
| 132 | // Iterate over each track. |
| 133 | // All needed because this effect needs to introduce |
| 134 | // silence in the sync-lock group tracks to keep sync |
| 135 | EffectOutputTracks outputs { *mTracks, GetType(), { { mT0, mT1 } }, true }; |
| 136 | bool bGoodResult = true; |
| 137 | |
| 138 | mCurTrackNum = 0; |
| 139 | |
| 140 | mFactor = 100.0 / (100.0 + m_PercentChange); |
| 141 | |
| 142 | outputs.Get().Any().VisitWhile( |
| 143 | bGoodResult, |
| 144 | [&](LabelTrack& lt) { |
| 145 | if (SyncLock::IsSelectedOrSyncLockSelected(lt)) |
| 146 | { |
| 147 | if (!ProcessLabelTrack(<)) |
| 148 | bGoodResult = false; |
| 149 | } |
| 150 | }, |
| 151 | [&](auto&& fallthrough) { |
| 152 | return [&](WaveTrack& outWaveTrack) { |
| 153 | if (!outWaveTrack.GetSelected()) |
| 154 | return fallthrough(); |
| 155 | |
| 156 | // Get start and end times from track |
| 157 | mCurT0 = outWaveTrack.GetStartTime(); |
| 158 | mCurT1 = outWaveTrack.GetEndTime(); |
| 159 | |
| 160 | // Set the current bounds to whichever left marker is |
| 161 | // greater and whichever right marker is less: |
| 162 | mCurT0 = std::max(mT0, mCurT0); |
| 163 | mCurT1 = std::min(mT1, mCurT1); |
| 164 | |
| 165 | // Process only if the right marker is to the right of the left |
| 166 | // marker |
| 167 | if (mCurT1 > mCurT0) |
| 168 | { |
| 169 | // Transform the marker timepoints to samples |
| 170 | auto start = outWaveTrack.TimeToLongSamples(mCurT0); |
| 171 | auto end = outWaveTrack.TimeToLongSamples(mCurT1); |
| 172 | |
| 173 | const auto gaps = FindGaps(outWaveTrack, mCurT0, mCurT1); |
| 174 | |
| 175 | auto pNewTrack = outWaveTrack.EmptyCopy(); |
| 176 | auto iter = pNewTrack->Channels().begin(); |
| 177 | for (const auto pChannel : outWaveTrack.Channels()) |
| 178 | { |
| 179 | // ProcessOne() (implemented below) processes a single channel |
| 180 | if (ProcessOne(*pChannel, **iter++, start, end)) |
| 181 | ++mCurTrackNum; |
| 182 | else |
| 183 | { |
| 184 | pNewTrack.reset(); |
| 185 | break; |
no test coverage detected