Skip to content

Transport

#include "crosspad/transport/Transport.hpp"

Generated from crosspad/transport/Transport.hpp in crosspad-core. Edit the header’s doxygen comments to change this page.

One transport for the whole instrument.

Recipes that use it: Tempo and transport

void transportClaim(ITransportTarget *target, bool stopPrevious=true)

Take the transport.

The previous holder is stopped first, if it is running: one transport means one thing sounding, and a claim is how an app says “PLAY now means me”. A claim by the target that already holds it leaves the transport as it is.

stopPrevious false hands over without stopping, for two targets that drive the same playback Arrange’s song and the seq view of one of its tracks, which plays that song too.

A claim outlives the app’s screen on purpose: leaving the Sequencer does not stop the pattern.

Used in Tempo and transport.

Declared in crosspad/transport/Transport.hpp:119.

void transportRelease(ITransportTarget *target)

Give it back, if target is the one holding it.

Does not stop anything: a target that wants silence stops itself first.

Used in Tempo and transport.

Declared in crosspad/transport/Transport.hpp:123.

ITransportTarget * transportTarget()

Used in Tempo and transport.

Declared in crosspad/transport/Transport.hpp:125.

void transportPlay()

Declared in crosspad/transport/Transport.hpp:129.

void transportStop()

Declared in crosspad/transport/Transport.hpp:130.

void transportRecord()

Declared in crosspad/transport/Transport.hpp:131.

void transportOverdub()

Declared in crosspad/transport/Transport.hpp:132.

TransportState transportState()

Stopped with no target, so a bar can paint before anything has claimed.

Declared in crosspad/transport/Transport.hpp:135.

uint8_t transportCaps()

Declared in crosspad/transport/Transport.hpp:136.

const char * transportName()

Declared in crosspad/transport/Transport.hpp:137.

float transportBpm()

0 with no target, or where the target has no tempo of its own.

Declared in crosspad/transport/Transport.hpp:139.

TransportPos transportPosition()

Declared in crosspad/transport/Transport.hpp:140.

void transportLocate(int bars)

Where the next PLAY starts, bars on (or back).

A no-op unless the target is stopped and says kTransportCanLocate.

Declared in crosspad/transport/Transport.hpp:143.

float transportTempo()

The tempo everything plays at now. 0 before a sequencer is published.

Used in Tempo and transport.

Declared in crosspad/transport/Transport.hpp:159.

void transportSetTempo(float bpm)

Set it, clamped to the limits: the sequencer and its click at once, so a turn is heard while it is made except under a song that is playing, whose audio cannot follow; then only transportCommitTempo() moves it.

Used in Tempo and transport.

Declared in crosspad/transport/Transport.hpp:163.

void transportCommitTempo()

The edit is done: the tempo of transportSetTempo()‘s last call reaches the open song too (re-measured and saved by its worker, which stops a song that is playing), and the clock if a song held it back.

Used in Tempo and transport.

Declared in crosspad/transport/Transport.hpp:167.

bool transportTempoFromHost()

True while a host’s MIDI clock drives the tempo: an edit would be undone at its next tick, so a control offering one should say so instead.

Used in Tempo and transport.

Declared in crosspad/transport/Transport.hpp:170.

void transportSetTempoFromHost(bool host)

The platform’s MIDI clock, each time the source of its tempo changes.

Declared in crosspad/transport/Transport.hpp:172.

bool transportClick()

The metronome: the click of the clock the tempo lives on, heard whenever something plays on it a pattern, a song with its seq.

One switch, the player’s; no transport command flips it. A count-in counts either way. False before a sequencer is published.

Declared in crosspad/transport/Transport.hpp:178.

void transportSetClick(bool on)

Declared in crosspad/transport/Transport.hpp:179.

What the instrument is doing.

One enum for the bar to paint from, however many state machines sit behind the claim.

Used in Tempo and transport.

ValueValueDescription
Stopped0
Playing
Recording
Overdubbing
WaitingArmed and waiting: a sync point, a count-in, or the first note.

Declared in crosspad/transport/Transport.hpp:33.

Where the transport is.

1-based bar and beat; cent is hundredths of a beat, not MIDI ticks the bar prints two digits and a resolution nobody can read is a resolution worth not inventing.

FieldTypeDescription
baruint16_t
beatuint8_t
centuint8_t

Declared in crosspad/transport/Transport.hpp:45.

What a transport command reaches.

Implemented by whatever an app wants PLAY to start the pattern sequencer, the audio song, the looper, a take. The bar never learns which.

Used in Tempo and transport.

Members

MemberDescription
play
stop
recordDefault to nothing rather than to play: a target that cannot record should do nothing when asked, and say so through caps().
overdub
stateWhat is happening, asked whenever the bar repaints.
caps
nameFor the bar’s label, e.g. “PATTERN”, “SONG”, “LOOP”. Never null.
bpmThe tempo the target runs at, or 0 when it has none of its own (a take, a one-shot) the bar then leaves its BPM field blank rather than printing a number nobody set.
positionWhere the transport is, for the bar’s readout.
locateMove where the next PLAY starts by bars, back for a negative count.

Methods

virtual void play() = 0

Used in Tempo and transport.

virtual void stop() = 0

Used in Tempo and transport.

virtual void record()

Default to nothing rather than to play: a target that cannot record should do nothing when asked, and say so through caps().

virtual void overdub()
virtual TransportState state() const =0

What is happening, asked whenever the bar repaints.

Must be cheap and safe to call from the UI thread.

Used in Tempo and transport.

virtual uint8_t caps() const
virtual const char * name() const

For the bar’s label, e.g. “PATTERN”, “SONG”, “LOOP”. Never null.

Used in Tempo and transport.

virtual float bpm() const

The tempo the target runs at, or 0 when it has none of its own (a take, a one-shot) the bar then leaves its BPM field blank rather than printing a number nobody set.

Used in Tempo and transport.

virtual TransportPos position() const

Where the transport is, for the bar’s readout.

Bars and beats are 1-based, the way a musician counts them; TransportPos::cent is hundredths of a beat, which is what fits the two digits the design gives the field.

virtual void locate(int bars)

Move where the next PLAY starts by bars, back for a negative count.

Called only while stopped and only with kTransportCanLocate in caps(); a target that has no position of its own leaves it out.

Declared in crosspad/transport/Transport.hpp:67.

DeclarationDescription
constexpr uint8_t kTransportCanPlayWhich of the four commands a target can honour.
constexpr uint8_t kTransportCanStop
constexpr uint8_t kTransportCanRecord
constexpr uint8_t kTransportCanOverdub
constexpr uint8_t kTransportCanLocateWhere the next PLAY starts can be moved by bars (ITransportTarget::locate): the bar’s position readout is a control then, not only a readout.
constexpr float kTransportTempoMinTempos the transport accepts, in BPM: the sequencer’s own limits.
constexpr float kTransportTempoMax