| 429 | } |
| 430 | |
| 431 | void 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 | |
| 482 | void PolyBLEPNode::process(ContextRenderLock & r, int bufferSize) |
| 483 | { |
nothing calls this directly
no test coverage detected