A bank of band-limited square-wave oscillators at fixed frequencies, summed into one output.
More...
|
| void | prepare (SampleType sample_rate) |
| | Set the sample rate and re-arm the existing oscillators for it.
|
| void | set_partials (const Partial *partials, std::size_t count) |
| | Install the bank's partials.
|
| void | set_partials (const std::vector< Partial > &partials) |
| | Convenience overload for a std::vector of partials.
|
| std::size_t | size () const noexcept |
| void | set_frequency (std::size_t index, SampleType hz) noexcept |
| | Retune one oscillator in place. No allocation; out-of-range is a no-op.
|
| void | set_amplitude (std::size_t index, SampleType amp) noexcept |
| | Reweight one oscillator in place. No allocation; out-of-range is a no-op.
|
| SampleType | frequency (std::size_t index) const noexcept |
| SampleType | amplitude (std::size_t index) const noexcept |
| void | set_level (SampleType level) noexcept |
| | Overall output gain applied after the weighted sum.
|
| SampleType | level () const noexcept |
| void | reset () noexcept |
| | Zero every oscillator's phase so the cluster restarts coherent.
|
| SampleType | process () noexcept |
| | Sum of the weighted band-limited squares for the next sample.
|
| SampleType | peak_bound () const noexcept |
| | The largest magnitude process() can return with the current partials and level: |level| times the sum of the absolute weights.
|
template<typename SampleType = float>
class pulp::signal::SquareOscBankT< SampleType >
A bank of band-limited square-wave oscillators at fixed frequencies, summed into one output.
This is a reusable excitation source for metallic and electronic sounds: callers choose any number of independently tuned, weighted square oscillators, then apply their own filtering and amplitude envelope.
The frequencies are deliberately inharmonic (not integer multiples of a fundamental): a metallic timbre is a dense, clangorous cluster of partials with no shared period, which is exactly what a handful of detuned squares summed together produce. A single square already carries only odd harmonics; six of them at incommensurate pitches fill the spectrum without ever landing on a tidy harmonic series.
Each oscillator is the repository's band-limited OscillatorT set to its square waveform, so the sum inherits that class's polyBLEP anti-aliasing rather than a naive sign() square's alias skirt. See the anti-alias assertions in test_square_osc_bank.cpp for the measured alias floor.
RT contract: prepare() and set_partials() size the internal storage and may allocate. Every per-sample and per-parameter call after that – process(), reset(), set_frequency(), set_amplitude(), set_level() – allocates nothing and never resizes.