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

Method Process

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

Source from the content-addressed store, hash-verified

293}
294
295bool EffectStage::Process(EffectInstance &instance,
296 size_t channel, const Buffers &data, size_t curBlockSize,
297 size_t outBufferOffset) const
298{
299 size_t processed{};
300 try {
301 const auto positions = mInBuffers.Positions();
302 const auto nPositions = mInBuffers.Channels();
303 // channel may be nonzero in the case of a plug-in that only reads
304 // one channel at a time, so multiple instances are made to mix stereo
305 assert(channel <= nPositions);
306 std::vector<float *> inPositions(
307 positions + channel, positions + nPositions - channel);
308 // When the plug-in expects many input channels, replicate the last
309 // buffer (assumed to be zero-filled) as dummy input
310 inPositions.resize(
311 instance.GetAudioInCount() - channel, inPositions.back());
312
313 std::vector<float *> advancedOutPositions;
314 const auto size = instance.GetAudioOutCount() - channel;
315 advancedOutPositions.reserve(size);
316
317 auto outPositions = data.Positions();
318 // It is assumed that data has at least one dummy buffer last
319 auto channels = data.Channels();
320 // channel may be nonzero in the case of a plug-in that only writes
321 // one channel at a time, so multiple instances are made to mix stereo
322 for (size_t ii = channel; ii < channels; ++ii)
323 advancedOutPositions.push_back(outPositions[ii] + outBufferOffset);
324 // When the plug-in expects many output channels, replicate the last
325 // as dummy output
326 advancedOutPositions.resize(size, advancedOutPositions.back());
327
328 processed = instance.ProcessBlock(mSettings,
329 inPositions.data(), advancedOutPositions.data(), curBlockSize);
330 }
331 catch (const AudacityException &) {
332 // PRL: Bug 437:
333 // Pass this along to our application-level handler
334 throw;
335 }
336 catch (...) {
337 // PRL:
338 // Exceptions for other reasons, maybe in third-party code...
339 // Continue treating them as we used to, but I wonder if these
340 // should now be treated the same way.
341 return false;
342 }
343
344 return (processed == curBlockSize);
345}
346
347sampleCount EffectStage::Remaining() const
348{

Callers

nothing calls this directly

Calls 6

ChannelsMethod · 0.80
GetAudioInCountMethod · 0.45
GetAudioOutCountMethod · 0.45
push_backMethod · 0.45
ProcessBlockMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected