| 155 | } |
| 156 | |
| 157 | bool AutoDuckBase::Process(EffectInstance&, EffectSettings&) |
| 158 | { |
| 159 | if (GetNumWaveTracks() == 0 || !mControlTrack) |
| 160 | return false; |
| 161 | |
| 162 | bool cancel = false; |
| 163 | |
| 164 | auto start = mControlTrack->TimeToLongSamples(mT0 + mOuterFadeDownLen); |
| 165 | auto end = mControlTrack->TimeToLongSamples(mT1 - mOuterFadeUpLen); |
| 166 | |
| 167 | if (end <= start) |
| 168 | return false; |
| 169 | |
| 170 | WaveTrack::Holder pFirstTrack; |
| 171 | auto pControlTrack = mControlTrack; |
| 172 | // If there is any stretch in the control track, substitute a temporary |
| 173 | // rendering before trying to use GetFloats |
| 174 | { |
| 175 | const auto t0 = pControlTrack->LongSamplesToTime(start); |
| 176 | const auto t1 = pControlTrack->LongSamplesToTime(end); |
| 177 | if (TimeStretching::HasPitchOrSpeed(*pControlTrack, t0, t1)) |
| 178 | { |
| 179 | pFirstTrack = pControlTrack->Duplicate()->SharedPointer<WaveTrack>(); |
| 180 | if (pFirstTrack) |
| 181 | { |
| 182 | UserException::WithCancellableProgress( |
| 183 | [&](const ProgressReporter& reportProgress) { |
| 184 | pFirstTrack->ApplyPitchAndSpeed( |
| 185 | { { t0, t1 } }, reportProgress); |
| 186 | }, |
| 187 | TimeStretching::defaultStretchRenderingTitle, |
| 188 | XO("Rendering Control-Track Time-Stretched Audio")); |
| 189 | pControlTrack = pFirstTrack.get(); |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | // the minimum number of samples we have to wait until the maximum |
| 195 | // pause has been exceeded |
| 196 | double maxPause = mMaximumPause; |
| 197 | |
| 198 | // We don't fade in until we have time enough to actually fade out again |
| 199 | if (maxPause < mOuterFadeDownLen + mOuterFadeUpLen) |
| 200 | maxPause = mOuterFadeDownLen + mOuterFadeUpLen; |
| 201 | |
| 202 | auto minSamplesPause = pControlTrack->TimeToLongSamples(maxPause); |
| 203 | |
| 204 | double threshold = DB_TO_LINEAR(mThresholdDb); |
| 205 | |
| 206 | // adjust the threshold so we can compare it to the rmsSum value |
| 207 | threshold = threshold * threshold * kRMSWindowSize; |
| 208 | |
| 209 | int rmsPos = 0; |
| 210 | double rmsSum = 0; |
| 211 | // to make the progress bar appear more natural, we first look for all |
| 212 | // duck regions and apply them all at once afterwards |
| 213 | std::vector<AutoDuckRegion> regions; |
| 214 | bool inDuckRegion = false; |
nothing calls this directly
no test coverage detected