|
Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
The Transport class represents the transport controls and state for an audio engine. More...
#include <src/engine/session/transport.h>


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... | |
| using | Position = dsp::Position |
| using | PortFlow = dsp::PortFlow |
| Public Types inherited from zrythm::dsp::ITransport | |
| enum class | PlayState { RollRequested , Rolling , PauseRequested , Paused } |
Public Member Functions | |
| Transport (Project *parent=nullptr) | |
| void | setLoopEnabled (bool enabled) |
| Q_SIGNAL void | loopEnabledChanged (bool enabled) |
| void | setRecordEnabled (bool enabled) |
| Q_SIGNAL void | recordEnabledChanged (bool enabled) |
| PlayState | getPlayState () const |
| void | setPlayState (PlayState state) |
| Q_SIGNAL void | playStateChanged (PlayState state) |
| dsp::PlayheadQmlWrapper * | getPlayhead () const |
| PositionProxy * | getCuePosition () const |
| PositionProxy * | getLoopStartPosition () const |
| PositionProxy * | getLoopEndPosition () const |
| PositionProxy * | getPunchInPosition () const |
| PositionProxy * | getPunchOutPosition () const |
| dsp::Metronome * | metronome () const |
| Q_INVOKABLE void | moveBackward () |
| Q_INVOKABLE void | moveForward () |
| signed_frame_t | get_playhead_position_in_audio_thread () const noexcept override |
| Get the playhead position. | |
| nframes_t | is_loop_point_met_in_audio_thread (const unsigned_frame_t g_start_frames, const nframes_t nframes) const noexcept override |
| 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;. | |
| std::pair< unsigned_frame_t, unsigned_frame_t > | get_loop_range_positions () const noexcept override |
| Returns the loop range positions in samples. | |
| std::pair< unsigned_frame_t, unsigned_frame_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. | |
| unsigned_frame_t | recording_preroll_frames_remaining () const noexcept override |
| Frames remaining to preroll (playing back some time earlier before actually recording/rolling). | |
| unsigned_frame_t | metronome_countin_frames_remaining () const noexcept override |
| Frames remaining for metronome countin. | |
| utils::Utf8String | get_full_designation_for_port (const dsp::Port &port) const |
| Q_INVOKABLE bool | isRolling () const |
| Q_INVOKABLE bool | isPaused () const |
| bool | is_looping () const |
| bool | is_recording () const |
| void | init_loaded (Project *project) |
| Initialize loaded transport. | |
| void | prepare_audio_regions_for_stretch (std::optional< structure::arrangement::ArrangerObjectSpan > sel_var) |
| Prepares audio regions for stretching (sets the Region.before_length). | |
| void | stretch_regions (std::optional< structure::arrangement::ArrangerObjectSpan > sel_var, bool with_fixed_ratio, double time_ratio, bool force) |
| Stretches regions. | |
| void | set_punch_mode_enabled (bool enabled) |
| void | set_start_playback_on_midi_input (bool enabled) |
| void | set_recording_mode (RecordingMode mode) |
| void | add_to_playhead_in_audio_thread (signed_frame_t nframes) |
| Moves the playhead by the time corresponding to given samples, taking into account the loop end point. | |
| Q_INVOKABLE void | requestPause (bool with_wait) |
| Request pause. | |
| Q_INVOKABLE void | requestRoll (bool with_wait) |
| Request playback. | |
| void | set_play_state_rt_safe (PlayState state) |
| Position | get_playhead_position_in_gui_thread () const |
| void | move_backward (bool with_wait) |
| Move to the previous snap point on the timeline. | |
| void | move_forward (bool with_wait) |
| Move to the next snap point on the timeline. | |
| bool | can_user_move_playhead () const |
| Returns whether the user can currently move the playhead (eg, via the UI or via scripts). | |
| void | move_playhead (double target_ticks, bool set_cue_point) |
| Moves playhead to given pos. | |
| void | set_loop (bool enabled, bool with_wait) |
| Enables or disables loop. | |
| void | goto_start_marker () |
| Moves the playhead to the start Marker. | |
| void | goto_end_marker () |
| Moves the playhead to the end Marker. | |
| void | goto_prev_marker () |
| Moves the playhead to the prev Marker. | |
| void | goto_next_marker () |
| Moves the playhead to the next Marker. | |
| void | update_positions (bool update_from_ticks) |
| Updates the frames in all transport positions. | |
| double | get_ppqn () const |
| Returns the PPQN (Parts/Ticks Per Quarter Note). | |
| std::pair< Position, Position > | get_range_positions () const |
| Returns the selected range positions. | |
| void | set_has_range (bool has_range) |
| Sets if the project has range and updates UI. | |
| void | set_range (bool range1, const Position *start_pos, const Position *pos, bool snap) |
| Set the range1 or range2 position. | |
| void | set_loop_range (bool start, const Position *start_pos, const Position *pos, bool snap) |
| Set the loop range. | |
| bool | position_is_inside_punch_range (Position pos) |
| void | recalculate_total_bars (std::optional< structure::arrangement::ArrangerObjectSpan > objects=std::nullopt) |
| Recalculates the total bars based on the last object's position. | |
| void | update_total_bars (int total_bars, bool fire_events) |
| Updates the total bars. | |
| void | update_caches (int beats_per_bar, int beat_unit) |
| void | set_recording (bool record, bool with_wait) |
| Sets recording on/off. | |
| Public Member Functions inherited from zrythm::dsp::ITransport | |
| signed_frame_t | get_playhead_position_after_adding_frames_in_audio_thread (const signed_frame_t current_playhead_position, const signed_frame_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 |
Static Public Member Functions | |
| static const char * | preroll_count_to_str (PrerollCountBars bars) |
| static int | preroll_count_bars_enum_to_int (PrerollCountBars bars) |
Data Fields | |
| int | total_bars_ = 0 |
| Total bars in the song. | |
| dsp::Playhead | playhead_ |
| Playhead position. | |
| utils::QObjectUniquePtr< dsp::PlayheadQmlWrapper > | playhead_adapter_ |
| utils::QObjectUniquePtr< dsp::Metronome > | metronome_ |
| The metronome. | |
| PositionProxy * | cue_pos_ = nullptr |
| Cue point position. | |
| PositionProxy * | loop_start_pos_ = nullptr |
| Loop start position. | |
| PositionProxy * | loop_end_pos_ = nullptr |
| Loop end position. | |
| PositionProxy * | punch_in_pos_ = nullptr |
| Punch in position. | |
| PositionProxy * | punch_out_pos_ = nullptr |
| Punch out position. | |
| Position | range_1_ |
| Selected range. | |
| Position | range_2_ |
| bool | has_range_ = false |
| Whether range should be displayed or not. | |
| int | ticks_per_beat_ = 0 |
| int | ticks_per_bar_ = 0 |
| int | sixteenths_per_beat_ = 0 |
| int | sixteenths_per_bar_ = 0 |
| nframes_t | position_ = 0 |
| Transport position in frames. | |
| std::atomic_bool | loop_ = false |
| Looping or not. | |
| std::atomic_bool | punch_mode_ = false |
| Whether punch in/out mode is enabled. | |
| std::atomic_bool | recording_ = false |
| Whether MIDI/audio recording is enabled (recording toggle in transport bar). | |
| signed_frame_t | recording_preroll_frames_remaining_ = 0 |
| Recording preroll frames remaining. | |
| signed_frame_t | countin_frames_remaining_ = 0 |
| Metronome countin frames remaining. | |
| bool | start_playback_on_midi_input_ = false |
| Whether to start playback on MIDI input. | |
| RecordingMode | recording_mode_ = (RecordingMode) 0 |
| double | playhead_before_pause_ {} |
| Position of the playhead before pausing, in ticks. | |
| std::unique_ptr< dsp::MidiPort > | roll_ |
| Roll/play MIDI port. | |
| std::unique_ptr< dsp::MidiPort > | stop_ |
| Stop MIDI port. | |
| std::unique_ptr< dsp::MidiPort > | backward_ |
| Backward MIDI port. | |
| std::unique_ptr< dsp::MidiPort > | forward_ |
| Forward MIDI port. | |
| std::unique_ptr< dsp::MidiPort > | loop_toggle_ |
| Loop toggle MIDI port. | |
| std::unique_ptr< dsp::MidiPort > | rec_toggle_ |
| Rec toggle MIDI port. | |
| PlayState | play_state_ = {} |
| Play state. | |
| RtTimePoint | last_manual_playhead_change_ = 0 |
| Last timestamp the playhead position was changed manually. | |
| Project * | project_ = nullptr |
| Pointer to owner, if any. | |
Properties | |
| QML_ELEMENT bool | loopEnabled |
| bool | recordEnabled |
| PlayState | playState |
| zrythm::dsp::PlayheadQmlWrapper * | playhead |
| PositionProxy * | cuePosition |
| PositionProxy * | loopStartPosition |
| PositionProxy * | loopEndPosition |
| PositionProxy * | punchInPosition |
| PositionProxy * | punchOutPosition |
| zrythm::dsp::Metronome * | metronome |
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) |
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 49 of file transport.h.
| using zrythm::engine::session::Transport::PortFlow = dsp::PortFlow |
Definition at line 123 of file transport.h.
| using zrythm::engine::session::Transport::Position = dsp::Position |
Definition at line 122 of file transport.h.
|
strong |
Corrseponts to "transport-display" in the gsettings.
Definition at line 72 of file transport.h.
|
strong |
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.
Definition at line 85 of file transport.h.
|
inlineoverridevirtualnoexcept |
Returns the loop range positions in samples.
Implements zrythm::dsp::ITransport.
Definition at line 189 of file transport.h.
|
inlineoverridevirtualnoexcept |
Implements zrythm::dsp::ITransport.
Definition at line 201 of file transport.h.
|
inlineoverridevirtualnoexcept |
Get the playhead position.
Implements zrythm::dsp::ITransport.
Definition at line 166 of file transport.h.
|
inlineoverridevirtualnoexcept |
Returns the punch recording range positions in samples.
Implements zrythm::dsp::ITransport.
Definition at line 195 of file transport.h.
| void zrythm::engine::session::Transport::init_loaded | ( | Project * | project | ) |
Initialize loaded transport.
| engine | Owner engine, if any. |
| tempo_track | Tempo track, used to initialize the caches. Only needed on the active project transport. |
|
inlineoverridevirtualnoexcept |
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;.
Implements zrythm::dsp::ITransport.
Definition at line 172 of file transport.h.
|
inline |
Definition at line 250 of file transport.h.
|
inline |
Definition at line 252 of file transport.h.
|
inline |
Definition at line 245 of file transport.h.
|
inline |
Definition at line 240 of file transport.h.
|
inlineoverridevirtualnoexcept |
Implements zrythm::dsp::ITransport.
Definition at line 203 of file transport.h.
|
inline |
Definition at line 154 of file transport.h.
|
inlineoverridevirtualnoexcept |
Frames remaining for metronome countin.
Implements zrythm::dsp::ITransport.
Definition at line 210 of file transport.h.
| void zrythm::engine::session::Transport::move_playhead | ( | double | 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.
| target_ticks | Position to set to. |
| set_cue_point | Also set the cue point at this position. |
| void zrythm::engine::session::Transport::prepare_audio_regions_for_stretch | ( | std::optional< structure::arrangement::ArrangerObjectSpan > | sel_var | ) |
Prepares audio regions for stretching (sets the Region.before_length).
| selections | If nullptr, all audio regions are used. If non-nullptr, only the regions in the selections are used. |
|
inlinestatic |
Definition at line 222 of file transport.h.
|
inlinestatic |
Definition at line 217 of file transport.h.
|
inlineoverridevirtualnoexcept |
Implements zrythm::dsp::ITransport.
Definition at line 204 of file transport.h.
| void zrythm::engine::session::Transport::recalculate_total_bars | ( | std::optional< structure::arrangement::ArrangerObjectSpan > | objects = std::nullopt | ) |
Recalculates the total bars based on the last object's position.
| sel | If given, only these objects will be checked, otherwise every object in the project will be checked. |
FIXME: use signals to update the total bars.
|
inlineoverridevirtualnoexcept |
Returns whether recording is enabled.
Implements zrythm::dsp::ITransport.
Definition at line 205 of file transport.h.
|
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 206 of file transport.h.
| Q_INVOKABLE void zrythm::engine::session::Transport::requestPause | ( | bool | with_wait | ) |
Request pause.
Must only be called in-between engine processing calls.
| with_wait | Wait for lock before requesting. |
| Q_INVOKABLE void zrythm::engine::session::Transport::requestRoll | ( | bool | with_wait | ) |
Request playback.
Must only be called in-between engine processing calls.
| with_wait | Wait for lock before requesting. |
| void zrythm::engine::session::Transport::set_loop_range | ( | bool | start, |
| const Position * | start_pos, | ||
| const Position * | pos, | ||
| bool | snap ) |
Set the loop range.
| start | True to set start pos, false to set end pos. |
| void zrythm::engine::session::Transport::set_range | ( | bool | range1, |
| const Position * | start_pos, | ||
| const Position * | pos, | ||
| bool | snap ) |
Set the range1 or range2 position.
| range1 | True to set range1, false to set range2. |
| void zrythm::engine::session::Transport::stretch_regions | ( | std::optional< structure::arrangement::ArrangerObjectSpan > | sel_var, |
| bool | with_fixed_ratio, | ||
| double | time_ratio, | ||
| bool | force ) |
Stretches regions.
| selections | If nullptr, all regions are used. If non-nullptr, only the regions in the selections are used. |
| with_fixed_ratio | Stretch all regions with a fixed ratio. If this is off, the current region length and Region.before_length will be used to calculate the ratio. |
| force | Force stretching, regardless of musical mode. |
| ZrythmException | if stretching fails. |
| void zrythm::engine::session::Transport::update_positions | ( | bool | update_from_ticks | ) |
Updates the frames in all transport positions.
| update_from_ticks | Whether to update the positions based on ticks (true) or frames (false). |
|
friend |
Definition at line 516 of file transport.h.
|
friend |
Definition at line 494 of file transport.h.
| std::unique_ptr<dsp::MidiPort> zrythm::engine::session::Transport::backward_ |
Backward MIDI port.
Definition at line 646 of file transport.h.
| signed_frame_t zrythm::engine::session::Transport::countin_frames_remaining_ = 0 |
Metronome countin frames remaining.
Definition at line 617 of file transport.h.
| PositionProxy* zrythm::engine::session::Transport::cue_pos_ = nullptr |
Cue point position.
Definition at line 561 of file transport.h.
| std::unique_ptr<dsp::MidiPort> zrythm::engine::session::Transport::forward_ |
Forward MIDI port.
Definition at line 649 of file transport.h.
| bool zrythm::engine::session::Transport::has_range_ = false |
Whether range should be displayed or not.
Definition at line 587 of file transport.h.
| RtTimePoint zrythm::engine::session::Transport::last_manual_playhead_change_ = 0 |
Last timestamp the playhead position was changed manually.
Definition at line 661 of file transport.h.
| std::atomic_bool zrythm::engine::session::Transport::loop_ = false |
Looping or not.
Definition at line 604 of file transport.h.
| PositionProxy* zrythm::engine::session::Transport::loop_end_pos_ = nullptr |
Loop end position.
Definition at line 567 of file transport.h.
| PositionProxy* zrythm::engine::session::Transport::loop_start_pos_ = nullptr |
Loop start position.
Definition at line 564 of file transport.h.
| std::unique_ptr<dsp::MidiPort> zrythm::engine::session::Transport::loop_toggle_ |
Loop toggle MIDI port.
Definition at line 652 of file transport.h.
| utils::QObjectUniquePtr<dsp::Metronome> zrythm::engine::session::Transport::metronome_ |
The metronome.
Definition at line 558 of file transport.h.
| PlayState zrythm::engine::session::Transport::play_state_ = {} |
Play state.
Definition at line 658 of file transport.h.
| dsp::Playhead zrythm::engine::session::Transport::playhead_ |
Playhead position.
Definition at line 554 of file transport.h.
| utils::QObjectUniquePtr<dsp::PlayheadQmlWrapper> zrythm::engine::session::Transport::playhead_adapter_ |
Definition at line 555 of file transport.h.
| double zrythm::engine::session::Transport::playhead_before_pause_ {} |
Position of the playhead before pausing, in ticks.
Used by UndoableAction.
Definition at line 629 of file transport.h.
| nframes_t zrythm::engine::session::Transport::position_ = 0 |
| Project* zrythm::engine::session::Transport::project_ = nullptr |
Pointer to owner, if any.
Definition at line 664 of file transport.h.
| PositionProxy* zrythm::engine::session::Transport::punch_in_pos_ = nullptr |
Punch in position.
Definition at line 570 of file transport.h.
| std::atomic_bool zrythm::engine::session::Transport::punch_mode_ = false |
Whether punch in/out mode is enabled.
Definition at line 607 of file transport.h.
| PositionProxy* zrythm::engine::session::Transport::punch_out_pos_ = nullptr |
Punch out position.
Definition at line 573 of file transport.h.
| Position zrythm::engine::session::Transport::range_1_ |
Selected range.
This is 2 points instead of start/end because the 2nd point can be dragged past the 1st point so the order gets swapped.
Should be compared each time to see which one is first.
Definition at line 583 of file transport.h.
| Position zrythm::engine::session::Transport::range_2_ |
Definition at line 584 of file transport.h.
| std::unique_ptr<dsp::MidiPort> zrythm::engine::session::Transport::rec_toggle_ |
Rec toggle MIDI port.
Definition at line 655 of file transport.h.
| std::atomic_bool zrythm::engine::session::Transport::recording_ = false |
Whether MIDI/audio recording is enabled (recording toggle in transport bar).
Definition at line 611 of file transport.h.
| RecordingMode zrythm::engine::session::Transport::recording_mode_ = (RecordingMode) 0 |
Definition at line 622 of file transport.h.
| signed_frame_t zrythm::engine::session::Transport::recording_preroll_frames_remaining_ = 0 |
Recording preroll frames remaining.
Definition at line 614 of file transport.h.
| std::unique_ptr<dsp::MidiPort> zrythm::engine::session::Transport::roll_ |
Roll/play MIDI port.
Any event received on this port will request a roll.
Definition at line 636 of file transport.h.
| int zrythm::engine::session::Transport::sixteenths_per_bar_ = 0 |
Definition at line 595 of file transport.h.
| int zrythm::engine::session::Transport::sixteenths_per_beat_ = 0 |
Definition at line 594 of file transport.h.
| bool zrythm::engine::session::Transport::start_playback_on_midi_input_ = false |
Whether to start playback on MIDI input.
Definition at line 620 of file transport.h.
| std::unique_ptr<dsp::MidiPort> zrythm::engine::session::Transport::stop_ |
Stop MIDI port.
Any event received on this port will request a stop/pause.
Definition at line 643 of file transport.h.
| int zrythm::engine::session::Transport::ticks_per_bar_ = 0 |
Definition at line 593 of file transport.h.
| int zrythm::engine::session::Transport::ticks_per_beat_ = 0 |
Definition at line 592 of file transport.h.
| int zrythm::engine::session::Transport::total_bars_ = 0 |
Total bars in the song.
Definition at line 551 of file transport.h.
|
read |
Definition at line 57 of file transport.h.
|
readwrite |
Definition at line 53 of file transport.h.
|
read |
Definition at line 59 of file transport.h.
|
read |
Definition at line 58 of file transport.h.
|
read |
Definition at line 62 of file transport.h.
|
read |
Definition at line 56 of file transport.h.
|
readwrite |
Definition at line 55 of file transport.h.
|
read |
Definition at line 60 of file transport.h.
|
read |
Definition at line 61 of file transport.h.
|
readwrite |
Definition at line 54 of file transport.h.