Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::dsp::Transport Class Reference

The Transport class represents the transport controls and state for an audio engine. More...

#include <src/dsp/transport.h>

Inheritance diagram for zrythm::dsp::Transport:
Collaboration diagram for zrythm::dsp::Transport:

Data Structures

struct  ConfigProvider
class  TransportSnapshot

Public Types

enum class  Display { BBT , Time }
 Corrseponts to "transport-display" in the gsettings. More...
enum class  RecordingMode { OverwriteEvents , MergeEvents , Takes , TakesMuted }
 Recording mode for MIDI and audio. More...
Public Types inherited from zrythm::dsp::ITransport
enum class  PlayState : std::uint8_t { RollRequested , Rolling , PauseRequested , Paused }

Public Member Functions

 Transport (const dsp::TempoMap &tempo_map, const dsp::SnapGrid &snap_grid, ConfigProvider config_provider, QObject *parent=nullptr)
bool loopEnabled () const
void setLoopEnabled (bool enabled)
Q_SIGNAL void loopEnabledChanged (bool enabled)
bool recordEnabled () const
void setRecordEnabled (bool enabled)
Q_SIGNAL void recordEnabledChanged (bool enabled)
bool punchEnabled () const
void setPunchEnabled (bool enabled)
Q_SIGNAL void punchEnabledChanged (bool enabled)
PlayState getPlayState () const
void setPlayState (PlayState state)
Q_SIGNAL void playStateChanged (PlayState state)
dsp::PlayheadQmlWrapperplayhead () const
dsp::AtomicPositionQmlAdaptercuePosition () const
dsp::AtomicPositionQmlAdapterloopStartPosition () const
dsp::AtomicPositionQmlAdapterloopEndPosition () const
dsp::AtomicPositionQmlAdapterpunchInPosition () const
dsp::AtomicPositionQmlAdapterpunchOutPosition () const
Q_INVOKABLE void moveBackward ()
Q_INVOKABLE void moveForward ()
Q_INVOKABLE void requestPause ()
 Request pause.
Q_INVOKABLE void requestRoll ()
 Request playback.
units::sample_t get_playhead_position_in_audio_thread () const noexcept override
 Get the playhead position.
std::pair< units::sample_t, units::sample_t > get_loop_range_positions () const noexcept override
 Returns the loop range positions in samples.
std::pair< units::sample_t, units::sample_t > get_punch_range_positions () const noexcept override
 Returns the punch recording range positions in samples.
PlayState get_play_state () const noexcept override
bool loop_enabled () const noexcept override
bool punch_enabled () const noexcept override
bool recording_enabled () const noexcept override
 Returns whether recording is enabled.
units::sample_t recording_preroll_frames_remaining () const noexcept override
 Frames remaining to preroll (playing back some time earlier before actually recording/rolling).
units::sample_t metronome_countin_frames_remaining () const noexcept override
 Frames remaining for metronome countin.
Q_INVOKABLE bool isRolling () const
Q_INVOKABLE bool isPaused () const
void add_to_playhead_in_audio_thread (units::sample_t nframes)
 Moves the playhead by the time corresponding to given samples, taking into account the loop end point.
void set_play_state_rt_safe (PlayState state)
void move_playhead (units::precise_tick_t target_ticks, bool set_cue_point)
 Moves playhead to given pos.
void goto_prev_or_next_marker (bool prev, RangeOf< units::precise_tick_t > auto &&extra_markers)
 Moves the playhead to the previous or next marker.
void set_loop_range (bool start, units::precise_tick_t start_pos, units::precise_tick_t pos, bool snap)
 Set the loop range.
bool position_is_inside_punch_range (units::sample_t pos)
auto playhead_ticks_before_pause () const
void consume_metronome_countin_samples (units::sample_t samples)
 For engine use only.
void consume_recording_preroll_samples (units::sample_t samples)
 For engine use only.
auto get_snapshot () const
Public Member Functions inherited from zrythm::dsp::ITransport
units::sample_t get_playhead_position_after_adding_frames_in_audio_thread (const units::sample_t current_playhead_position, const units::sample_t frames_to_add) const noexcept
 Gets the playhead position, similarly to get_playhead_position(), except that it adjusts the new position if the loop end point was crossed.
bool has_recording_preroll_frames_remaining () const noexcept
units::sample_t is_loop_point_met_in_audio_thread (units::sample_t g_start_frames, units::sample_t nframes) const noexcept
 Returns the number of processable frames until and excluding the loop end point as a positive number (>= 1) if the loop point was met between g_start_frames and (g_start_frames + nframes), otherwise returns 0;.

Properties

QML_ELEMENT bool loopEnabled
bool recordEnabled
bool punchEnabled
PlayState playState
zrythm::dsp::PlayheadQmlWrapperplayhead
zrythm::dsp::AtomicPositionQmlAdaptercuePosition
zrythm::dsp::AtomicPositionQmlAdapterloopStartPosition
zrythm::dsp::AtomicPositionQmlAdapterloopEndPosition
zrythm::dsp::AtomicPositionQmlAdapterpunchInPosition
zrythm::dsp::AtomicPositionQmlAdapterpunchOutPosition

Friends

void init_from (Transport &obj, const Transport &other, utils::ObjectCloneType clone_type)
void to_json (nlohmann::json &j, const Transport &transport)
void from_json (const nlohmann::json &j, Transport &transport)

Detailed Description

The Transport class represents the transport controls and state for an audio engine.

It manages playback, recording, and other transport-related functionality.

Definition at line 44 of file transport.h.

Member Enumeration Documentation

◆ Display

Corrseponts to "transport-display" in the gsettings.

Definition at line 73 of file transport.h.

◆ RecordingMode

Recording mode for MIDI and audio.

In all cases, only objects created during the current recording cycle can be changed. Previous objects shall not be touched.

Enumerator
OverwriteEvents 

Overwrite events in first recorded region.

In the case of MIDI, this will remove existing MIDI notes during recording.

In the case of audio, this will act exactly the same as RECORDING_MODE_TAKES_MUTED.

MergeEvents 

Merge events in existing region.

In the case of MIDI, this will append MIDI notes.

In the case of audio, this will act exactly the same as RECORDING_MODE_TAKES.

Takes 

Events get put in new lanes each time recording starts/resumes (eg, when looping or entering/leaving the punch range).

TakesMuted 

Same as RECORDING_MODE_TAKES, except previous takes (since recording started) are muted.

Definition at line 86 of file transport.h.

Member Function Documentation

◆ consume_metronome_countin_samples()

void zrythm::dsp::Transport::consume_metronome_countin_samples ( units::sample_t samples)
inline

For engine use only.

Parameters
samplesSamples to consume.

Definition at line 449 of file transport.h.

◆ consume_recording_preroll_samples()

void zrythm::dsp::Transport::consume_recording_preroll_samples ( units::sample_t samples)
inline

For engine use only.

Parameters
samplesSamples to consume.

Definition at line 460 of file transport.h.

◆ cuePosition()

dsp::AtomicPositionQmlAdapter * zrythm::dsp::Transport::cuePosition ( ) const
inline

Definition at line 260 of file transport.h.

◆ get_loop_range_positions()

std::pair< units::sample_t, units::sample_t > zrythm::dsp::Transport::get_loop_range_positions ( ) const
inlineoverridevirtualnoexcept

Returns the loop range positions in samples.

Implements zrythm::dsp::ITransport.

Definition at line 307 of file transport.h.

◆ get_play_state()

PlayState zrythm::dsp::Transport::get_play_state ( ) const
inlineoverridevirtualnoexcept

Implements zrythm::dsp::ITransport.

Definition at line 320 of file transport.h.

◆ get_playhead_position_in_audio_thread()

units::sample_t zrythm::dsp::Transport::get_playhead_position_in_audio_thread ( ) const
inlineoverridevirtualnoexcept

Get the playhead position.

Returns
The position in samples.

Implements zrythm::dsp::ITransport.

Definition at line 301 of file transport.h.

◆ get_punch_range_positions()

std::pair< units::sample_t, units::sample_t > zrythm::dsp::Transport::get_punch_range_positions ( ) const
inlineoverridevirtualnoexcept

Returns the punch recording range positions in samples.

Implements zrythm::dsp::ITransport.

Definition at line 314 of file transport.h.

◆ get_snapshot()

auto zrythm::dsp::Transport::get_snapshot ( ) const
inline

Definition at line 466 of file transport.h.

◆ goto_prev_or_next_marker()

void zrythm::dsp::Transport::goto_prev_or_next_marker ( bool prev,
RangeOf< units::precise_tick_t > auto && extra_markers )
inline

Moves the playhead to the previous or next marker.

Parameters
prevTrue for previous, false for next.

Definition at line 372 of file transport.h.

◆ isPaused()

Q_INVOKABLE bool zrythm::dsp::Transport::isPaused ( ) const
inline

Definition at line 341 of file transport.h.

◆ isRolling()

Q_INVOKABLE bool zrythm::dsp::Transport::isRolling ( ) const
inline

Definition at line 336 of file transport.h.

◆ loop_enabled()

bool zrythm::dsp::Transport::loop_enabled ( ) const
inlineoverridevirtualnoexcept

Implements zrythm::dsp::ITransport.

Definition at line 322 of file transport.h.

◆ loopEnabled()

bool zrythm::dsp::Transport::loopEnabled ( ) const
inline

Definition at line 240 of file transport.h.

◆ loopEndPosition()

dsp::AtomicPositionQmlAdapter * zrythm::dsp::Transport::loopEndPosition ( ) const
inline

Definition at line 268 of file transport.h.

◆ loopStartPosition()

dsp::AtomicPositionQmlAdapter * zrythm::dsp::Transport::loopStartPosition ( ) const
inline

Definition at line 264 of file transport.h.

◆ metronome_countin_frames_remaining()

units::sample_t zrythm::dsp::Transport::metronome_countin_frames_remaining ( ) const
inlineoverridevirtualnoexcept

Frames remaining for metronome countin.

Note
Count-in happens while the playhead is not moving.

Implements zrythm::dsp::ITransport.

Definition at line 329 of file transport.h.

◆ move_playhead()

void zrythm::dsp::Transport::move_playhead ( units::precise_tick_t target_ticks,
bool set_cue_point )

Moves playhead to given pos.

This is only for moves other than while playing and for looping while playing.

Should not be used during exporting.

Parameters
target_ticksPosition to set to.
set_cue_pointAlso set the cue point at this position.

◆ playhead()

dsp::PlayheadQmlWrapper * zrythm::dsp::Transport::playhead ( ) const
inline

Definition at line 256 of file transport.h.

◆ playhead_ticks_before_pause()

auto zrythm::dsp::Transport::playhead_ticks_before_pause ( ) const
inline

Definition at line 439 of file transport.h.

◆ punch_enabled()

bool zrythm::dsp::Transport::punch_enabled ( ) const
inlineoverridevirtualnoexcept

Implements zrythm::dsp::ITransport.

Definition at line 323 of file transport.h.

◆ punchEnabled()

bool zrythm::dsp::Transport::punchEnabled ( ) const
inline

Definition at line 248 of file transport.h.

◆ punchInPosition()

dsp::AtomicPositionQmlAdapter * zrythm::dsp::Transport::punchInPosition ( ) const
inline

Definition at line 272 of file transport.h.

◆ punchOutPosition()

dsp::AtomicPositionQmlAdapter * zrythm::dsp::Transport::punchOutPosition ( ) const
inline

Definition at line 276 of file transport.h.

◆ recordEnabled()

bool zrythm::dsp::Transport::recordEnabled ( ) const
inline

Definition at line 244 of file transport.h.

◆ recording_enabled()

bool zrythm::dsp::Transport::recording_enabled ( ) const
inlineoverridevirtualnoexcept

Returns whether recording is enabled.

Implements zrythm::dsp::ITransport.

Definition at line 324 of file transport.h.

◆ recording_preroll_frames_remaining()

units::sample_t zrythm::dsp::Transport::recording_preroll_frames_remaining ( ) const
inlineoverridevirtualnoexcept

Frames remaining to preroll (playing back some time earlier before actually recording/rolling).

Preroll is a number of frames earlier to start at before the punch in position during recording.

Implements zrythm::dsp::ITransport.

Definition at line 325 of file transport.h.

◆ set_loop_range()

void zrythm::dsp::Transport::set_loop_range ( bool start,
units::precise_tick_t start_pos,
units::precise_tick_t pos,
bool snap )

Set the loop range.

Parameters
startTrue to set start pos, false to set end pos.

Property Documentation

◆ cuePosition

zrythm::dsp::AtomicPositionQmlAdapter * zrythm::dsp::Transport::cuePosition
read

Definition at line 53 of file transport.h.

◆ loopEnabled

QML_ELEMENT bool zrythm::dsp::Transport::loopEnabled
readwrite

Definition at line 48 of file transport.h.

◆ loopEndPosition

zrythm::dsp::AtomicPositionQmlAdapter * zrythm::dsp::Transport::loopEndPosition
read

Definition at line 55 of file transport.h.

◆ loopStartPosition

zrythm::dsp::AtomicPositionQmlAdapter * zrythm::dsp::Transport::loopStartPosition
read

Definition at line 54 of file transport.h.

◆ playhead

zrythm::dsp::PlayheadQmlWrapper * zrythm::dsp::Transport::playhead
read

Definition at line 52 of file transport.h.

◆ playState

PlayState zrythm::dsp::Transport::playState
readwrite

Definition at line 51 of file transport.h.

◆ punchEnabled

bool zrythm::dsp::Transport::punchEnabled
readwrite

Definition at line 50 of file transport.h.

◆ punchInPosition

zrythm::dsp::AtomicPositionQmlAdapter * zrythm::dsp::Transport::punchInPosition
read

Definition at line 57 of file transport.h.

◆ punchOutPosition

zrythm::dsp::AtomicPositionQmlAdapter * zrythm::dsp::Transport::punchOutPosition
read

Definition at line 59 of file transport.h.

◆ recordEnabled

bool zrythm::dsp::Transport::recordEnabled
readwrite

Definition at line 49 of file transport.h.


The documentation for this class was generated from the following file: