@TODO change the interface: // if true is returned, rate_array[0] applies to the entire quantum // if the computed total rate has any illegal values, true will be returned, and a default rate of 1.f bool SampledAudioNode::totalPitchRate(ContextRenderLock& r, float*& rate);
| 549 | /// // if the computed total rate has any illegal values, true will be returned, and a default rate of 1.f |
| 550 | /// bool SampledAudioNode::totalPitchRate(ContextRenderLock& r, float*& rate); |
| 551 | float SampledAudioNode::totalPitchRate(ContextRenderLock& r) |
| 552 | { |
| 553 | std::shared_ptr<AudioBus> srcBus = m_sourceBus->valueBus(); |
| 554 | |
| 555 | // if there's no bus, pitchrate is defaulted. |
| 556 | if (!srcBus) |
| 557 | return 1.f; |
| 558 | |
| 559 | double sampleRateFactor = sampleRateFactor = srcBus->sampleRate() / r.context()->sampleRate(); |
| 560 | |
| 561 | /// @fixme these values should be per sample, not per quantum |
| 562 | /// -or- they should be settings if they don't vary per sample |
| 563 | double basePitchRate = playbackRate()->value(); |
| 564 | |
| 565 | /// @fixme these values should be per sample, not per quantum |
| 566 | double totalRate = m_dopplerRate->value() * sampleRateFactor * basePitchRate; |
| 567 | totalRate *= pow(2, detune()->value() / 1200); |
| 568 | |
| 569 | // Sanity check the total rate. It's very important that the resampler not get any bad rate values. |
| 570 | totalRate = std::max(0.0, totalRate); |
| 571 | |
| 572 | // Revisit these lower bounds if ever this node can compute ultra low resampling rates. |
| 573 | if (totalRate < 1.e-2f) |
| 574 | totalRate = 1; // a value of zero is considered an illegal value so the default is imposed |
| 575 | totalRate = std::min(100.0, totalRate); |
| 576 | |
| 577 | bool isTotalRateValid = !std::isnan(totalRate) && !std::isinf(totalRate); |
| 578 | if (!isTotalRateValid) |
| 579 | totalRate = 1.0; |
| 580 | |
| 581 | return (float) totalRate; |
| 582 | } |
| 583 | |
| 584 | } // namespace lab |
nothing calls this directly
no test coverage detected