|
Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
Manages tempo and time signature events for a DAW timeline. More...
#include <src/dsp/tempo_map.h>
Data Structures | |
| struct | TempoEvent |
| Tempo event definition. More... | |
| struct | TimeSignatureEvent |
| Time signature event definition. More... | |
| struct | MusicalPosition |
| Musical position representation. More... | |
Public Types | |
| enum class | CurveType : std::uint8_t { Constant , Linear } |
| Tempo curve type (constant or linear ramp). More... | |
Public Member Functions | |
| FixedPpqTempoMap (units::precise_sample_rate_t sampleRate) | |
| Construct a new FixedPpqTempoMap object. | |
| void | set_sample_rate (units::precise_sample_rate_t sampleRate) |
| Set the sample rate. | |
| void | add_tempo_event (units::tick_t tick, double bpm, CurveType curve) |
| Add a tempo event. | |
| void | remove_tempo_event (units::tick_t tick) |
| Remove a tempo event at the specified tick. | |
| void | add_time_signature_event (units::tick_t tick, int numerator, int denominator) |
| Add a time signature event. | |
| void | remove_time_signature_event (units::tick_t tick) |
| Remove a time signature event at the specified tick. | |
| auto | tick_to_seconds (units::precise_tick_t tick) const -> units::precise_second_t |
| Convert fractional ticks to seconds. | |
| units::precise_sample_t | tick_to_samples (units::precise_tick_t tick) const |
| Convert fractional ticks to samples. | |
| units::sample_t | tick_to_samples_rounded (units::precise_tick_t tick) const |
| units::precise_tick_t | seconds_to_tick (units::precise_second_t seconds) const |
| Convert seconds to fractional ticks. | |
| units::precise_tick_t | samples_to_tick (units::precise_sample_t samples) const |
| Convert samples to fractional ticks. | |
| TimeSignatureEvent | time_signature_at_tick (units::tick_t tick) const |
| Get the time signature event active at the given tick. | |
| double | tempo_at_tick (units::tick_t tick) const |
| Get the tempo event active at the given tick. | |
| MusicalPosition | tick_to_musical_position (units::tick_t tick) const |
| Convert ticks to musical position (bar:beat:sixteenth:tick). | |
| MusicalPosition | samples_to_musical_position (units::sample_t samples) const |
| units::tick_t | musical_position_to_tick (const MusicalPosition &pos) const |
| Convert musical position to ticks. | |
| double | get_sample_rate () const |
| Get current sample rate. | |
| void | set_default_bpm (double bpm) |
| void | set_default_time_signature (int numerator, int denominator) |
Static Public Member Functions | |
| static consteval int | get_ppq () |
| Get pulses per quarter note. | |
Friends | |
| class | TempoMapWrapper |
| void | to_json (nlohmann::json &j, const FixedPpqTempoMap &tempo_map) |
| void | from_json (const nlohmann::json &j, FixedPpqTempoMap &tempo_map) |
Manages tempo and time signature events for a DAW timeline.
The FixedPpqTempoMap class handles:
All tempo events are stored in musical time (ticks) and automatically adjust to time signature changes. A precondition for this is that tempo events are only added after all time signature events are added.
| PPQ | Pulses (ticks) per quarter note |
Definition at line 41 of file tempo_map.h.
|
strong |
Tempo curve type (constant or linear ramp).
| Enumerator | |
|---|---|
| Constant | Constant tempo. |
| Linear | Linear tempo ramp. |
Definition at line 47 of file tempo_map.h.
|
inlineexplicit |
Construct a new FixedPpqTempoMap object.
| sampleRate | Sample rate in Hz |
Definition at line 115 of file tempo_map.h.
|
inline |
Add a tempo event.
| tick | Position in ticks |
| bpm | Tempo in BPM |
| curve | Curve type |
| std::invalid_argument | for invalid BPM or tick values |
Definition at line 137 of file tempo_map.h.
|
inline |
Add a time signature event.
| tick | Position in ticks |
| numerator | Beats per bar |
| denominator | Beat unit (2,4,8,16). |
For the beat unit:
| std::invalid_argument | for invalid parameters |
Definition at line 195 of file tempo_map.h.
|
inlinestaticconsteval |
Get pulses per quarter note.
Definition at line 624 of file tempo_map.h.
|
inline |
Get current sample rate.
Definition at line 627 of file tempo_map.h.
|
inline |
Convert musical position to ticks.
| pos | Musical position |
| std::invalid_argument | for invalid position |
Definition at line 562 of file tempo_map.h.
|
inline |
Remove a tempo event at the specified tick.
Definition at line 164 of file tempo_map.h.
|
inline |
Remove a time signature event at the specified tick.
Definition at line 225 of file tempo_map.h.
|
inline |
Definition at line 545 of file tempo_map.h.
|
inline |
Convert samples to fractional ticks.
Definition at line 390 of file tempo_map.h.
|
inline |
Convert seconds to fractional ticks.
Definition at line 323 of file tempo_map.h.
|
inline |
Definition at line 632 of file tempo_map.h.
|
inline |
Definition at line 633 of file tempo_map.h.
|
inline |
Set the sample rate.
Definition at line 121 of file tempo_map.h.
|
inline |
Get the tempo event active at the given tick.
| tick | Position in ticks |
Definition at line 424 of file tempo_map.h.
|
inline |
Convert ticks to musical position (bar:beat:sixteenth:tick).
| tick | Position in ticks |
Definition at line 462 of file tempo_map.h.
|
inline |
Convert fractional ticks to samples.
Definition at line 312 of file tempo_map.h.
|
inline |
Definition at line 317 of file tempo_map.h.
|
inline |
Convert fractional ticks to seconds.
Definition at line 242 of file tempo_map.h.
|
inline |
Get the time signature event active at the given tick.
| tick | Position in ticks |
Definition at line 401 of file tempo_map.h.
|
friend |
Definition at line 745 of file tempo_map.h.
|
friend |
Definition at line 43 of file tempo_map.h.
|
friend |
Definition at line 740 of file tempo_map.h.