| 306 | } |
| 307 | |
| 308 | bool EqualizationBase::Process(EffectInstance&, EffectSettings&) |
| 309 | { |
| 310 | EffectOutputTracks outputs { *mTracks, GetType(), { { mT0, mT1 } } }; |
| 311 | mParameters.CalcFilter(); |
| 312 | bool bGoodResult = true; |
| 313 | |
| 314 | int count = 0; |
| 315 | for (auto track : outputs.Get().Selected<WaveTrack>()) |
| 316 | { |
| 317 | double trackStart = track->GetStartTime(); |
| 318 | double trackEnd = track->GetEndTime(); |
| 319 | double t0 = mT0 < trackStart ? trackStart : mT0; |
| 320 | double t1 = mT1 > trackEnd ? trackEnd : mT1; |
| 321 | |
| 322 | if (t1 > t0) |
| 323 | { |
| 324 | auto start = track->TimeToLongSamples(t0); |
| 325 | auto end = track->TimeToLongSamples(t1); |
| 326 | auto len = end - start; |
| 327 | |
| 328 | auto pTempTrack = track->EmptyCopy(); |
| 329 | pTempTrack->ConvertToSampleFormat(floatSample); |
| 330 | auto iter0 = pTempTrack->Channels().begin(); |
| 331 | |
| 332 | for (const auto pChannel : track->Channels()) |
| 333 | { |
| 334 | constexpr auto windowSize = EqualizationFilter::windowSize; |
| 335 | const auto& M = mParameters.mM; |
| 336 | |
| 337 | wxASSERT(M - 1 < windowSize); |
| 338 | size_t L = windowSize - (M - 1); // Process L samples at a go |
| 339 | auto s = start; |
| 340 | auto idealBlockLen = pChannel->GetMaxBlockSize() * 4; |
| 341 | if (idealBlockLen % L != 0) |
| 342 | idealBlockLen += (L - (idealBlockLen % L)); |
| 343 | auto pNewChannel = *iter0++; |
| 344 | Task task { M, idealBlockLen, *pNewChannel }; |
| 345 | bGoodResult = ProcessOne(task, count, *pChannel, start, len); |
| 346 | if (!bGoodResult) |
| 347 | goto done; |
| 348 | } |
| 349 | pTempTrack->Flush(); |
| 350 | // Remove trailing data from the temp track |
| 351 | pTempTrack->Clear(t1 - t0, pTempTrack->GetEndTime()); |
| 352 | track->ClearAndPaste(t0, t1, *pTempTrack, true, true); |
| 353 | } |
| 354 | |
| 355 | count++; |
| 356 | } |
| 357 | done: |
| 358 | |
| 359 | if (bGoodResult) |
| 360 | outputs.Commit(); |
| 361 | |
| 362 | return bGoodResult; |
| 363 | } |
| 364 | |
| 365 | // EqualizationBase implementation |
nothing calls this directly
no test coverage detected