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

Method processPolyBLEP

src/extended/PolyBLEPNode.cpp:431–480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

429}
430
431void PolyBLEPNode::processPolyBLEP(ContextRenderLock & r, int bufferSize, int offset, int count)
432{
433 AudioBus * outputBus = output(0)->bus(r);
434 if (!r.context() || !isInitialized() || !outputBus->numberOfChannels())
435 {
436 outputBus->zero();
437 return;
438 }
439
440 const float sample_rate = r.context()->sampleRate();
441 polyblep->setSampleRate(sample_rate);
442
443 int nonSilentFramesToProcess = count;
444
445 if (!nonSilentFramesToProcess)
446 {
447 outputBus->zero();
448 return;
449 }
450
451 if (bufferSize > m_amplitudeValues.size()) m_amplitudeValues.allocate(bufferSize);
452
453 // fetch the amplitudes
454 float * amplitudes = m_amplitudeValues.data();
455 if (m_amplitude->hasSampleAccurateValues())
456 {
457 m_amplitude->calculateSampleAccurateValues(r, amplitudes, bufferSize);
458 }
459 else
460 {
461 m_amplitude->smooth(r);
462 float amp = m_amplitude->smoothedValue();
463 for (int i = 0; i < bufferSize; ++i) amplitudes[i] = amp;
464 }
465
466 // calculate and write the wave
467 float* destination = outputBus->channel(0)->mutableData() + offset;
468
469 /// @fixme these values should be per sample, not per quantum
470 /// -or- they should be settings if they don't vary per sample
471 polyblep->setFrequency(m_frequency->value());
472 polyblep->setWaveform(static_cast<PolyBLEPType>(m_type->valueUint32()));
473
474 for (int i = offset; i < offset + nonSilentFramesToProcess; ++i)
475 {
476 destination[i] = (amplitudes[i] * static_cast<float>(polyblep->getPhaseAndIncrement()));
477 }
478
479 outputBus->clearSilentFlag();
480}
481
482void PolyBLEPNode::process(ContextRenderLock & r, int bufferSize)
483{

Callers

nothing calls this directly

Calls 15

sizeMethod · 0.80
allocateMethod · 0.80
smoothMethod · 0.80
smoothedValueMethod · 0.80
mutableDataMethod · 0.80
channelMethod · 0.80
setFrequencyMethod · 0.80
setWaveformMethod · 0.80
valueUint32Method · 0.80
getPhaseAndIncrementMethod · 0.80

Tested by

no test coverage detected