transport.h
Musical time.
#include <sonore/transport.h>- 2types
- 5other declarations
- Guides: Getting started, MIDI and MPE
On this page
Design notes
The host tells us the tempo, the position and whether it is playing on every block. A tempo-synced delay, an LFO locked to eighth notes, a gate that restarts on the bar: all of it needs this, and a plugin that ignores it is limited to knob-in-milliseconds designs.
TransportInfo is filled by the format wrapper before process() and handed to the DSP; NoteLength converts a musical division into seconds at the current tempo, which is the calculation every synced effect gets slightly wrong when it writes its own.
Types 2
What the host knows about musical time at the start of this block.
An LFO that stays locked to the host's timeline.
Free-running phase drifts: stop and restart playback, or loop a bar, and a plain oscillator is wherever it happened to be. This derives phase from the transport's beat position instead, so the same bar always sounds the same, which is the entire reason a producer syncs a modulation in the first place. When the host isn't playing (or reports no beats) it free-runs, so the plugin still moves while auditioning.
Functions 4
- fn
inline double noteLengthInBeats(int denominator, NoteFlavour flavour = NoteFlavour::Straight)Musical note lengths in beats. A quarter note is 1 beat by definition, so everything else scales from there. Kept as free functions rather than a table so a generated plugin can ask for "1/16 dotted" without a lookup it has to get right.transport.h:111 - fn
inline double noteLengthInSeconds(const TransportInfo& t, int denominator, NoteFlavour flavour = NoteFlavour::Straight)Seconds for a musical division at the transport's tempo.transport.h:123 - fn
inline double noteLengthInSamples(const TransportInfo& t, double sampleRate, int denominator, NoteFlavour flavour = NoteFlavour::Straight)Samples for a musical division: what a delay line actually needs.transport.h:129 - fn
inline double noteRateInHz(const TransportInfo& t, int denominator, NoteFlavour flavour = NoteFlavour::Straight)Hertz for a division: what an LFO actually needs.transport.h:135
Enums 1
- enum
enum class NoteFlavourA musical division.transport.h:99Straightis the plain note,Dottedis 1.5x,Tripletis 2/3: the three every synced control offers.