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

Method Process

libraries/lib-mixer/Mix.cpp:295–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293}
294
295size_t Mixer::Process(const size_t maxToProcess)
296{
297 assert(maxToProcess <= BufferSize());
298
299 // MB: this is wrong! mT represented warped time, and mTime is too inaccurate to use
300 // it here. It's also unnecessary I think.
301 //if (mT >= mT1)
302 // return 0;
303
304 auto &[mT0, mT1, _, mTime] = *mTimesAndSpeed;
305 auto oldTime = mTime;
306 // backwards (as possibly in scrubbing)
307 const auto backwards = (mT0 > mT1);
308
309 Clear();
310
311 std::optional<size_t> maxOut;
312
313 maxOut = mDownstream->Acquire(mTemp, maxToProcess);
314 mDownstream->Release();
315
316 if (!maxOut)
317 return 0;
318
319 if (backwards)
320 mTime = std::clamp(mTime, mT1, oldTime);
321 else
322 mTime = std::clamp(mTime, oldTime, mT1);
323
324 const auto dstStride = (mInterleaved ? mNumChannels : 1);
325 auto ditherType = mNeedsDither
326 ? (mHighQuality ? gHighQualityDither : gLowQualityDither)
327 : DitherType::none;
328 for (size_t c = 0; c < mNumChannels; ++c)
329 CopySamples(mTemp.GetReadPosition(c), floatSample,
330 (mInterleaved
331 ? mBuffer[0].ptr() + (c * SAMPLE_SIZE(mFormat))
332 : mBuffer[c].ptr()
333 ),
334 mFormat, *maxOut, ditherType,
335 1, dstStride);
336
337 // MB: this doesn't take warping into account, replaced with code based on mSamplePos
338 //mT += (maxOut / mRate);
339
340 assert(*maxOut <= maxToProcess);
341 return *maxOut;
342}
343
344constSamplePtr Mixer::GetBuffer()
345{

Callers 6

ProcessPlaybackSlicesMethod · 0.45
DrainRecordBuffersMethod · 0.45
MixVariableRatesMethod · 0.45
BuildMethod · 0.45
PrintMinidumpFunction · 0.45
performEffectMethod · 0.45

Calls 7

CopySamplesFunction · 0.85
GetReadPositionMethod · 0.80
ptrMethod · 0.80
BufferSizeFunction · 0.70
ClearFunction · 0.70
AcquireMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected