| 24 | }; |
| 25 | |
| 26 | void LFOModSource::processBlock() { |
| 27 | // Calculate LFO output |
| 28 | mOutput = LFO_SHAPES[shape->getIndex()].calc(mCurPhase) / 2.0f; |
| 29 | if (!bipolar->get()) mOutput = mOutput + 0.5f; // Make unipolar if needed |
| 30 | |
| 31 | // Update phase for the next block |
| 32 | if (sync->get()) { |
| 33 | const float divInBars = std::pow(2, juce::roundToInt(ParamRanges::SYNC_DIV_MAX * rate->convertTo0to1(rate->get()))); |
| 34 | mCurPhase += mRadPerBlock / (mBarsPerSec / divInBars); |
| 35 | } else { |
| 36 | mCurPhase += mRadPerBlock * rate->get(); |
| 37 | } |
| 38 | |
| 39 | // Wrap phase to keep it in the range [0, 2PI) |
| 40 | if (mCurPhase >= juce::MathConstants<double>::twoPi) mCurPhase -= juce::MathConstants<double>::twoPi; |
| 41 | } |
| 42 | |
| 43 | juce::Range<float> LFOModSource::getRange() { |
| 44 | if (bipolar->get()) { |
no test coverage detected