|
Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
|
A pulse oscillator with phase modulation: pitch, width, anchor, index and the PM signal over a PhasePulse. More...
A pulse oscillator with phase modulation: pitch, width, anchor, index and the PM signal over a PhasePulse.
The composition owns a PhaseAccumulator and drives a PhasePulse<> with its phase and step, from the parts in pm.hpp, which a component with cores of its own uses directly. The accumulator holds the phase as a 32-bit count of the cycle, so it gathers no rounding error; each frame's step is the frequency rounded to fs / 2^32. It makes the one conversion from each port to the core's natural units, pitch through math::frequency(). Its ports are process() arguments after the frame count, in the order PORTS declares (common/transport.hpp):
Pitch, width, anchor and index as blocks are used as given, one value per frame. As scalars each moves to its value over RAMP_FRAMES; the first scalar a port is given jumps. A port left off holds and a ramp in progress continues; phase_mod left off is zero.
Phase is linear within each step of a frame: an edge is timed on the segment between two steps' phases, so a pulse born and closed within a step is not seen. Without modulation the core takes the frame as one segment. The step, the offset's change included, is bounded at the core's MAX_STEP in each part; with the reduction, a sine at up to twice the pitch stays inside it at full index at every pitch.
Tune is a parameter: the frequency at zero pitch in cycles per frame, set once by the app from Hz and the target's sample rate, so the component holds no sample rate. TAMING_CORNER is in cycles per frame for the same reason, 1.05 kHz at 48 kHz: an octave under Plaits' corner.
Out-of-range port values are handled by the core; a non-finite pitch or index counts as 0, and a non-finite PM sample holds the last finite one. Output is the core's, nominally [-1, 1], LATENCY frames late, with the DC the width and the modulation carry; an app follows it with a DcBlock. On the default kernel a step overshoots by 8.2 % of its height, so a pulse reaches 1.16. Output does not depend on block size: every ramp is a fixed number of frames.
Definition at line 76 of file pm_pulse.hpp.
#include <pm_pulse.hpp>
Public Types | |
| using | Core = PhasePulse<> |
Public Member Functions | |
| PmPulse () | |
| No Tune and no PM until set; every scalar port ramps over RAMP_FRAMES. | |
| void | set_tune (float cycles_per_frame) |
| Parameter: the frequency at zero pitch. | |
| template<class... Ports> | |
| void | process (float *out, uint16_t frames, Ports... ports) |
| One block, the ports in PORTS' order, any trailing ones left off. | |
| void | reset () |
| Phase and offset to zero, the PM signal's history cleared, every ramp at its target, corrections dropped. | |
| float | frequency () const |
| The frequency of the last frame, cycles per frame, as the accumulator took it. | |
| float | phase () const |
| The accumulator's phase after the last frame, before the offset. | |
Static Public Member Functions | |
| static float | index_cycles (float index, float octaves_above_corner) |
| The PM depth in cycles for an index and a pitch. | |
Static Public Attributes | |
| static constexpr uint8_t | LATENCY = Core::LATENCY |
| static constexpr float | MAX_FREQUENCY = PM_MAX_FREQUENCY |
| static constexpr float | MAX_INDEX = PM_MAX_INDEX |
| static constexpr float | TAMING_CORNER = PM_TAMING_CORNER |
| static constexpr float | TAMING_PER_OCTAVE = PM_TAMING_PER_OCTAVE |
| static constexpr uint16_t | RAMP_FRAMES = 64 |
| static constexpr uint8_t | SUBSTEPS = PM_SUBSTEPS |
| static constexpr uint8_t | PM_LATENCY = sbl::dsp::PM_LATENCY |
| static constexpr transport::Port | PORTS [] |
| The ports, in the order process() takes them. | |
| static constexpr transport::Parameter< PmPulse > | PARAMETERS [] |
| The parameters, for tools. | |
| using sbl::dsp::PmPulse::Core = PhasePulse<> |
the core, on the default kernel
Definition at line 78 of file pm_pulse.hpp.
|
inline |
No Tune and no PM until set; every scalar port ramps over RAMP_FRAMES.
Definition at line 90 of file pm_pulse.hpp.
References RAMP_FRAMES.
Referenced by process().
|
inlinestatic |
The PM depth in cycles for an index and a pitch.
| index | The index port's value; bipolar, the sign kept |
| octaves_above_corner | The pitch in octaves above TAMING_CORNER; below it there is no reduction |
Definition at line 103 of file pm_pulse.hpp.
References sbl::dsp::pm_depth(), and sbl::dsp::pm_taming().
Referenced by process().
|
inline |
Parameter: the frequency at zero pitch.
| cycles_per_frame | Tune in cycles per frame; non-finite or negative counts as 0 |
Definition at line 113 of file pm_pulse.hpp.
References sbl::math::finite_or(), sbl::dsp::math::octaves_from_ratio(), and TAMING_CORNER.
|
inline |
One block, the ports in PORTS' order, any trailing ones left off.
| Ports | A block or an arithmetic scalar for each of pitch, width, anchor and index; a block for phase_mod |
| [out] | out | Output buffer, frames long |
| frames | Frame count | |
| ports | pitch in octaves over Tune; width in [0, 1]; anchor in [-1, 1]; index, bipolar; phase_mod, the PM signal |
Definition at line 139 of file pm_pulse.hpp.
References sbl::dsp::PhaseAccumulator::advance(), sbl::math::finite_or(), sbl::transport::fits_v, index_cycles(), PmPulse(), sbl::dsp::PmInput::process(), sbl::dsp::Ramp::ramping(), sbl::dsp::PhasePulse< Kernel >::set_anchor(), sbl::dsp::PhaseAccumulator::set_step(), sbl::dsp::PhasePulse< Kernel >::set_width(), SUBSTEPS, and sbl::dsp::Ramp::value().
|
inline |
Phase and offset to zero, the PM signal's history cleared, every ramp at its target, corrections dropped.
Definition at line 179 of file pm_pulse.hpp.
References sbl::dsp::PmInput::reset(), sbl::dsp::PhaseAccumulator::reset(), and sbl::dsp::PhasePulse< Kernel >::reset().
|
inline |
The frequency of the last frame, cycles per frame, as the accumulator took it.
Definition at line 189 of file pm_pulse.hpp.
|
inline |
The accumulator's phase after the last frame, before the offset.
Definition at line 192 of file pm_pulse.hpp.
References sbl::dsp::PhaseAccumulator::phase().
|
staticconstexpr |
frames the output trails
Definition at line 80 of file pm_pulse.hpp.
|
staticconstexpr |
cycles per frame
Definition at line 81 of file pm_pulse.hpp.
|
staticconstexpr |
cycles of offset per unit of PM at index 1
Definition at line 82 of file pm_pulse.hpp.
|
staticconstexpr |
|
staticconstexpr |
as pm_taming()
Definition at line 84 of file pm_pulse.hpp.
|
staticconstexpr |
a scalar port arrives after this many frames
Definition at line 85 of file pm_pulse.hpp.
Referenced by PmPulse().
|
staticconstexpr |
|
staticconstexpr |
frames the PM signal trails
Definition at line 87 of file pm_pulse.hpp.
|
staticconstexpr |
The ports, in the order process() takes them.
Definition at line 120 of file pm_pulse.hpp.
|
staticconstexpr |
The parameters, for tools.
Definition at line 125 of file pm_pulse.hpp.