MCPcopy Create free account
hub / github.com/audacity/audacity / Process

Method Process

libraries/lib-builtin-effects/EqualizationBase.cpp:308–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308bool 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 }
357done:
358
359 if (bGoodResult)
360 outputs.Commit();
361
362 return bGoodResult;
363}
364
365// EqualizationBase implementation

Callers

nothing calls this directly

Calls 15

ProcessOneFunction · 0.85
TimeToLongSamplesMethod · 0.80
EmptyCopyMethod · 0.80
ChannelsMethod · 0.80
ClearAndPasteMethod · 0.80
CalcFilterMethod · 0.45
GetMethod · 0.45
GetStartTimeMethod · 0.45
GetEndTimeMethod · 0.45
ConvertToSampleFormatMethod · 0.45
beginMethod · 0.45
GetMaxBlockSizeMethod · 0.45

Tested by

no test coverage detected