MCPcopy Create free account
hub / github.com/LabSound/LabSound / process

Method process

src/core/SampledAudioNode.cpp:440–539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

438
439
440 void SampledAudioNode::process(ContextRenderLock& r, int framesToProcess)
441 {
442 if (_internals->bus_setting_updated) {
443 _internals->bus_setting_updated = false;
444 setBus(r, m_sourceBus->valueBus());
445 }
446 _internals->greatest_cursor = -1;
447
448 AudioBus* dstBus = output(0)->bus(r);
449 size_t dstChannelCount = dstBus->numberOfChannels();
450 std::shared_ptr<AudioBus> srcBus = m_sourceBus->valueBus();
451
452 // move requested starts to the internal schedule if there's a source bus.
453 // if there's no source bus, the schedule requests are discarded.
454 {
455 Scheduled s;
456 while (_internals->incoming.try_dequeue(s))
457 {
458 if (s.loopCount == -3)
459 {
460 m_retainedSourceBus = s.sourceBus;
461 m_sourceBus->setBus(s.sourceBus.get());
462 srcBus = s.sourceBus;
463 this->_internals->bus_setting_updated = false; // setting bus causes this -3 state to occur so clear it immediately
464 }
465 else if (s.loopCount == -2)
466 {
467 _internals->scheduled.clear();
468 }
469 else if (srcBus)
470 {
471 _internals->scheduled.push_back(s);
472 }
473 }
474 }
475
476 // zero out the buffer for summing, or for silence
477 for (int i = 0; i < dstChannelCount; ++i)
478 output(0)->bus(r)->zero();
479
480 // silence the outputs if there's nothing to play.
481 int schedule_count = static_cast<int>(_internals->scheduled.size());
482 if (!schedule_count || !srcBus)
483 return;
484
485 // if there's something to play, conform the output channel count.
486 int srcChannelCount = srcBus->numberOfChannels();
487 if (dstChannelCount != srcChannelCount)
488 {
489 output(0)->setNumberOfChannels(r, srcChannelCount);
490 dstChannelCount = srcChannelCount;
491 dstBus = output(0)->bus(r);
492 }
493
494 // compute the frame timing in samples and seconds
495 uint64_t quantumStartFrame = r.context()->currentSampleFrame();
496 uint64_t quantumEndFrame = quantumStartFrame + AudioNode::ProcessingSizeInFrames;
497 double quantumDuration = static_cast<double>(AudioNode::ProcessingSizeInFrames) / r.context()->sampleRate();

Callers

nothing calls this directly

Calls 15

valueBusMethod · 0.80
getMethod · 0.80
clearMethod · 0.80
sizeMethod · 0.80
currentSampleFrameMethod · 0.80
enqueueEventMethod · 0.80
busMethod · 0.45
numberOfChannelsMethod · 0.45
setBusMethod · 0.45
zeroMethod · 0.45
setNumberOfChannelsMethod · 0.45
contextMethod · 0.45

Tested by

no test coverage detected