Enumerations | |
| enum class | Division : std::uint8_t { whole = 0 , whole_dotted = 1 , whole_triplet = 2 , half = 3 , half_dotted = 4 , half_triplet = 5 , quarter = 6 , quarter_dotted = 7 , quarter_triplet = 8 , eighth = 9 , eighth_dotted = 10 , eighth_triplet = 11 , sixteenth = 12 , sixteenth_dotted = 13 , sixteenth_triplet = 14 , thirty_second = 15 , thirty_second_dotted = 16 , thirty_second_triplet = 17 , sixty_fourth = 18 , sixty_fourth_dotted = 19 , sixty_fourth_triplet = 20 , count = 21 } |
| Shared serialized musical-division vocabulary. More... | |
Functions | |
| template<typename T> | |
| T | db_to_linear (T db) |
| Amplitude dB → linear gain. 0 dB → 1, −6.0206 dB → 0.5. | |
| template<typename T> | |
| T | linear_to_db (T linear) |
| Linear gain → amplitude dB, floored at kDbFloorAmplitude so silence maps to a finite −200 dB rather than −inf. | |
| template<typename T> | |
| T | midi_to_hz (T note) |
| MIDI note number → Hz (note 69 = 440 Hz). | |
| template<typename T> | |
| T | hz_to_midi (T hz) |
| Hz → MIDI note number. | |
| template<typename T> | |
| T | semitones_to_ratio (T semitones) |
| Semitones → frequency ratio. +12 → 2, −12 → 0.5. | |
| template<typename T> | |
| T | ratio_to_semitones (T ratio) |
| Frequency ratio → semitones. Inverse of semitones_to_ratio. | |
| template<typename T> | |
| T | cents_to_ratio (T cents) |
| Cents → frequency ratio. +100 → 2^(1/12), +1200 → 2. | |
| template<typename T> | |
| T | ratio_to_cents (T ratio) |
| Frequency ratio → cents. Inverse of cents_to_ratio. | |
| template<typename T> | |
| T | volts_to_semitones (T volts) |
| Pitch CV volts → semitones, on the 1 V/octave standard. | |
| template<typename T> | |
| T | semitones_to_volts (T semitones) |
| Semitones → pitch CV volts, on the 1 V/octave standard. | |
| template<typename T> | |
| T | ms_to_samples (T ms, T sample_rate) |
| Milliseconds → samples at sample_rate Hz. | |
| template<typename T> | |
| T | samples_to_ms (T samples, T sample_rate) |
| Samples → milliseconds at sample_rate Hz. | |
| template<typename T> | |
| T | hz_to_period_samples (T hz, T sample_rate) |
| Frequency → its period in samples. A 100 Hz tone at 48 kHz is 480 samples. | |
| template<typename T> | |
| T | period_samples_to_hz (T samples, T sample_rate) |
| A period in samples → its frequency in Hz. | |
| template<typename T> | |
| T | hz_to_cycles_per_sample (T hz, T sample_rate) |
| Hz → normalised frequency in cycles per sample (f / fs) — the unit a phase accumulator increments by. | |
| template<typename T> | |
| T | hz_to_radians_per_sample (T hz, T sample_rate) |
| Hz → radians per sample (2π·f / fs) — the unit a sin/cos oscillator and most filter design formulas want. | |
| template<typename T> | |
| T | ms_to_onepole_coef (T ms, T sample_rate) |
| A time constant in ms → the a in the one-pole smoother y += a·(x − y), i.e. | |
| template<typename T> | |
| T | ms_to_onepole_pole (T ms, T sample_rate) |
| The complementary pole of ms_to_onepole_coef: p = 1 − a = exp(−1/(τ·fs)), the p in y = p·y + (1 − p)·x. | |
| template<typename T> | |
| T | t60_ms_to_tau_ms (T t60_ms) |
| A 60 dB decay time in ms → the one-pole time constant τ in ms that produces it. | |
| template<typename T> | |
| T | taper_log (T u, T lo, T hi) |
| Geometric ("log") taper: maps a normalised knob position u ∈ [0, 1] onto [lo, hi] so equal knob travel is equal RATIO — the right law for anything heard geometrically (frequency, delay time, drive). | |
| template<typename T> | |
| T | untaper_log (T value, T lo, T hi) |
| Inverse of taper_log: a value in [lo, hi] → its knob position in [0, 1]. | |
| template<typename T> | |
| T | taper_linear (T u, T lo, T hi) |
| Linear taper — the arithmetic counterpart of taper_log, present so a parameter table can name its law instead of open-coding a lerp. | |
| template<typename T> | |
| T | untaper_linear (T value, T lo, T hi) |
| Inverse of taper_linear. | |
| template<typename T> | |
| T | taper_log_inverse (T value, T lo, T hi) |
| Compatibility spelling used by the shared modulation toolkit. | |
| template<typename T> | |
| T | t60_to_per_sample_gain (T t60_seconds, T sample_rate) |
| Per-sample gain for a feedback path that decays by 60 dB in t60_seconds. | |
| template<typename T> | |
| T | beats_to_seconds (T beats, T bpm) |
| template<typename T> | |
| T | seconds_to_beats (T seconds, T bpm) |
| constexpr timebase::BeatDivision | to_beat_division (Division division) noexcept |
| Converts the legacy signal spelling to the canonical timebase vocabulary. | |
| constexpr float | division_to_beats (Division division) |
| constexpr float | division_to_beats (int index) |
| float | division_to_seconds (Division division, float bpm) |
| double | division_to_samples (Division division, float bpm, double sample_rate) |
| float | division_to_hz (Division division, float bpm) |
Variables | |
| constexpr double | kDbFloorAmplitude = 1e-10 |
| Amplitude floor used when converting to dB. | |
| constexpr double | kMidiA4 = 69.0 |
| MIDI note number of concert A. Fixed by the MIDI specification. | |
| constexpr double | kA4Hz = 440.0 |
| Frequency of concert A in Hz — the tuning reference for midi_to_hz. | |
| constexpr double | kSemitonesPerOctave = 12.0 |
| Semitones per octave, and cents per semitone. Fixed by 12-TET notation. | |
| constexpr double | kCentsPerSemitone = 100.0 |
| constexpr double | kSemitonesPerVolt = kSemitonesPerOctave |
| Semitones per volt on the 1 V/octave pitch-CV standard. | |
| constexpr int | kDivisionCount = static_cast<int>(Division::count) |
|
strong |
Shared serialized musical-division vocabulary.
Order is ABI/preset state: append before count; never reorder existing entries.
|
inline |
|
inline |
Cents → frequency ratio. +100 → 2^(1/12), +1200 → 2.
|
inline |
Amplitude dB → linear gain. 0 dB → 1, −6.0206 dB → 0.5.
|
constexpr |
|
constexpr |
|
inline |
|
inline |
|
inline |
|
inline |
Hz → normalised frequency in cycles per sample (f / fs) — the unit a phase accumulator increments by.
|
inline |
Hz → MIDI note number.
Non-positive input would be −inf, so it is floored at the dB amplitude floor's frequency analogue: the result saturates rather than returning −inf, keeping a tracker's output finite on silence.
|
inline |
Frequency → its period in samples. A 100 Hz tone at 48 kHz is 480 samples.
|
inline |
Hz → radians per sample (2π·f / fs) — the unit a sin/cos oscillator and most filter design formulas want.
|
inline |
Linear gain → amplitude dB, floored at kDbFloorAmplitude so silence maps to a finite −200 dB rather than −inf.
Takes the magnitude, so a negative gain reports its level rather than NaN.
|
inline |
MIDI note number → Hz (note 69 = 440 Hz).
Fractional notes are meaningful: 69.5 is a quarter-tone above A4.
|
inline |
A time constant in ms → the a in the one-pole smoother y += a·(x − y), i.e.
a = 1 − exp(−1 / (τ·fs)) with τ in seconds. a ∈ (0, 1].
τ is the 63.2 % point — the time for a step response to cover 1 − 1/e of the distance. The other two readings people mean by "the smoothing time" are one multiply away, so state which one you mean and convert:
ms <= 0 returns 1 (instant), which is what a caller asking for zero smoothing means; it never divides by zero.
|
inline |
The complementary pole of ms_to_onepole_coef: p = 1 − a = exp(−1/(τ·fs)), the p in y = p·y + (1 − p)·x.
Same τ convention.
|
inline |
Milliseconds → samples at sample_rate Hz.
Fractional — callers that need an integer delay decide their own rounding, because a delay line that interpolates and one that does not want different answers.
|
inline |
A period in samples → its frequency in Hz.
|
inline |
Frequency ratio → cents. Inverse of cents_to_ratio.
|
inline |
Frequency ratio → semitones. Inverse of semitones_to_ratio.
|
inline |
Samples → milliseconds at sample_rate Hz.
|
inline |
|
inline |
Semitones → frequency ratio. +12 → 2, −12 → 0.5.
|
inline |
Semitones → pitch CV volts, on the 1 V/octave standard.
|
inline |
A 60 dB decay time in ms → the one-pole time constant τ in ms that produces it.
Pair with ms_to_onepole_coef when a spec states a t60 rather than a τ.
|
inline |
Per-sample gain for a feedback path that decays by 60 dB in t60_seconds.
|
inline |
Linear taper — the arithmetic counterpart of taper_log, present so a parameter table can name its law instead of open-coding a lerp.
|
inline |
Geometric ("log") taper: maps a normalised knob position u ∈ [0, 1] onto [lo, hi] so equal knob travel is equal RATIO — the right law for anything heard geometrically (frequency, delay time, drive).
u = 0.5 lands on the geometric mean sqrt(lo·hi), not the arithmetic midpoint.
Requires lo > 0; a taper through zero has no geometric midpoint. Returns lo unchanged if that precondition fails rather than producing a NaN.
|
inline |
Compatibility spelling used by the shared modulation toolkit.
|
constexprnoexcept |
Converts the legacy signal spelling to the canonical timebase vocabulary.
Both enums are persisted, append-only ordinal contracts.
|
inline |
Inverse of taper_linear.
|
inline |
Inverse of taper_log: a value in [lo, hi] → its knob position in [0, 1].
|
inline |
Pitch CV volts → semitones, on the 1 V/octave standard.
|
inlineconstexpr |
Frequency of concert A in Hz — the tuning reference for midi_to_hz.
|
inlineconstexpr |
|
inlineconstexpr |
Amplitude floor used when converting to dB.
Guards log10(0); any value far below the quietest amplitude anyone measures works. [design parameter] default 1e-10 (−200 dBFS), range 1e-15 .. 1e-6.
|
inlineconstexpr |
|
inlineconstexpr |
MIDI note number of concert A. Fixed by the MIDI specification.
|
inlineconstexpr |
Semitones per octave, and cents per semitone. Fixed by 12-TET notation.
|
inlineconstexpr |
Semitones per volt on the 1 V/octave pitch-CV standard.