Files
serumalt/Source/SubOscillator.cpp
T
biggy e4cea300db chore: land janitor round 1 and graft integration
Round 1 findings and fixes, all previously uncommitted:
- FXProcessor per-slot DSP history repair (HEAD does not compile without it)
- SynthVoice::getModulationValue, editor control-lock guard
- ExactCompare.h naming the deliberate exact float comparisons
- KnobLookAndFeel replacing the never-installed SerumLookAndFeel
- 55 first-party compiler warnings to 0
- AGENT.md renamed to AGENTS.md across Source/
- graft repository context graph and its hooks
- JANITOR_TASKS.md and UI_UX_AUDIT.md records
2026-10-06 08:50:45 +02:00

36 lines
860 B
C++

#include "SubOscillator.h"
namespace serum
{
void SubOscillator::noteOn()
{
phase = 0.0;
}
void SubOscillator::processAdd (double freqHz, int shape, float level, float& out) noexcept
{
if (level <= 0.0f || freqHz <= 0.0)
return;
// The octave shift is baked into freqHz by the voice; here we just phase-accumulate.
const double inc = juce::MathConstants<double>::twoPi * freqHz / sr;
phase += inc;
phase -= std::floor (phase * (1.0 / juce::MathConstants<double>::twoPi)) * juce::MathConstants<double>::twoPi;
float s = 0.0f;
if (shape == (int) SubShape::Triangle)
{
const float p = (float) (phase * (1.0 / juce::MathConstants<double>::twoPi));
s = 1.0f - 4.0f * std::abs (p - 0.5f);
}
else
{
s = (float) std::sin (phase);
}
out += s * level;
}
} // namespace serum