|
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/gui/dsp/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 = zrythm::dsp::Position |
| using | PortIdentifier = zrythm::dsp::PortIdentifier |
| using | PortFlow = zrythm::dsp::PortFlow |
Public Types inherited from zrythm::dsp::ITransport | |
| enum class | PlayState { RollRequested , Rolling , PauseRequested , Paused } |
Public Types inherited from IPortOwner | |
| using | TrackUuid = dsp::PortIdentifier::TrackUuid |
| using | PluginUuid = dsp::PortIdentifier::PluginUuid |
| using | PortUuid = dsp::PortIdentifier::PortUuid |
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) |
| PositionProxy * | getPlayheadPosition () const |
| PositionProxy * | getCuePosition () const |
| PositionProxy * | getLoopStartPosition () const |
| PositionProxy * | getLoopEndPosition () const |
| PositionProxy * | getPunchInPosition () const |
| PositionProxy * | getPunchOutPosition () const |
| Q_INVOKABLE void | moveBackward () |
| Q_INVOKABLE void | moveForward () |
| bool | is_in_active_project () const override |
| void | set_port_metadata_from_owner (dsp::PortIdentifier &id, PortRange &range) const override |
| Function that will be called by the Port to update the identifier's relevant members based on this port owner. | |
| utils::Utf8String | get_full_designation_for_port (const dsp::PortIdentifier &id) const override |
| Q_INVOKABLE bool | isRolling () const |
| Q_INVOKABLE bool | isPaused () const |
| bool | is_looping () const |
| bool | is_recording () const |
| void | init_loaded (Project *project, const TempoTrack *tempo_track) |
| Initialize loaded transport. | |
| void | prepare_audio_regions_for_stretch (std::optional< ArrangerObjectSpan > sel_var) |
| Prepares audio regions for stretching (sets the Region.before_length). | |
| void | stretch_regions (std::optional< 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 | set_metronome_enabled (bool enabled) |
| Sets whether metronome is enabled or not. | |
| void | add_to_playhead (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_playhead_pos_rt_safe (Position pos) |
| Setter for playhead Position. | |
| void | set_playhead_to_bar (int bar) |
| void | set_play_state_rt_safe (PlayState state) |
| void | get_playhead_pos (Position *pos) |
| Getter for playhead Position. | |
| Position | get_playhead_position () const override |
| nframes_t | is_loop_point_met (const signed_frame_t g_start_frames, const nframes_t nframes) const 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;. | |
| 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 (const Position &target, bool panic, bool set_cue_point, bool fire_events) |
| 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. | |
| void | position_add_frames (Position &pos, signed_frame_t frames) const override |
| Adds frames to the given position similar to Position::add_frames, except that it adjusts the new Position if the loop end point was crossed. | |
| 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. | |
| std::pair< Position, Position > | get_loop_range_positions () const override |
| Returns the loop range positions. | |
| PlayState | get_play_state () const override |
| 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) |
| bool | get_loop_enabled () const override |
| void | recalculate_total_bars (std::optional< 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. | |
| void | init_after_cloning (const Transport &other, ObjectCloneType clone_type) override |
| Initializes the cloned object. | |
| Q_INVOKABLE QString | getPlayheadPositionString (const TempoTrack *tempo_track) const |
Public Member Functions inherited from ICloneable< Transport > | |
| std::unique_ptr< Transport > | clone_unique (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const |
| std::shared_ptr< Transport > | clone_shared (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const |
| Transport * | clone_raw_ptr (ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const |
| Transport * | clone_qobject (QObject *parent, ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const |
| QScopedPointer< Transport > | clone_unique_qobject (QObject *parent, ObjectCloneType clone_type=ObjectCloneType::Snapshot, Args &&... args) const |
Public Member Functions inherited from IPortOwner | |
| virtual void | on_control_change_event (const PortUuid &port_uuid, const dsp::PortIdentifier &id, float val) |
| Will be called when a control port's value changes. | |
| virtual void | on_midi_activity (const dsp::PortIdentifier &id) |
| Called during processing if the MIDI port contains new MIDI events. | |
| virtual bool | should_sum_data_from_backend () const |
| Whether during processing, the port should sum the data from its backend buffers coming in. | |
| virtual bool | should_bounce_to_master (utils::audio::BounceStep step) const |
| Whether the port should add its data to the master output when bouncing. | |
| virtual bool | are_events_on_midi_channel_approved (midi_byte_t channel) const |
| Returns whether MIDI events on this channel on an input port should be processed (not ignored). | |
Static Public Member Functions | |
| static const char * | preroll_count_to_str (PrerollCountBars bars) |
| static int | preroll_count_bars_enum_to_int (PrerollCountBars bars) |
| static void | get_playhead_pos_static (Transport *self, Position *pos) |
Data Fields | |
| int | total_bars_ = 0 |
| Total bars in the song. | |
| PositionProxy * | playhead_pos_ = nullptr |
| Playhead position. | |
| 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. | |
| bool | loop_ = false |
| Looping or not. | |
| bool | punch_mode_ = false |
| Whether punch in/out mode is enabled. | |
| bool | recording_ = false |
| Whether MIDI/audio recording is enabled (recording toggle in transport bar). | |
| bool | metronome_enabled_ = false |
| Metronome enabled or not. | |
| signed_frame_t | 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 |
| Position | playhead_before_pause_ |
| Position of the playhead before pausing. | |
| std::unique_ptr< MidiPort > | roll_ |
| Roll/play MIDI port. | |
| std::unique_ptr< MidiPort > | stop_ |
| Stop MIDI port. | |
| std::unique_ptr< MidiPort > | backward_ |
| Backward MIDI port. | |
| std::unique_ptr< MidiPort > | forward_ |
| Forward MIDI port. | |
| std::unique_ptr< MidiPort > | loop_toggle_ |
| Loop toggle MIDI port. | |
| std::unique_ptr< 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. | |
Data Fields inherited from ICloneable< Transport > | |
| friend | Derived |
Properties | |
| QML_ELEMENT bool | loopEnabled |
| bool | recordEnabled |
| PlayState | playState |
| PositionProxy * | playheadPosition |
| PositionProxy * | cuePosition |
| PositionProxy * | loopStartPosition |
| PositionProxy * | loopEndPosition |
| PositionProxy * | punchInPosition |
| PositionProxy * | punchOutPosition |
Friends | |
| 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 Transport::PortFlow = zrythm::dsp::PortFlow |
Definition at line 133 of file transport.h.
Definition at line 132 of file transport.h.
Definition at line 131 of file transport.h.
|
strong |
Corrseponts to "transport-display" in the gsettings.
Definition at line 81 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 94 of file transport.h.
|
overridevirtual |
Reimplemented from IPortOwner.
|
inlineoverridevirtual |
Implements zrythm::dsp::ITransport.
Definition at line 457 of file transport.h.
Returns the loop range positions.
Implements zrythm::dsp::ITransport.
|
inlineoverridevirtual |
Implements zrythm::dsp::ITransport.
Definition at line 426 of file transport.h.
Definition at line 304 of file transport.h.
|
inlineoverridevirtual |
Implements zrythm::dsp::ITransport.
Definition at line 309 of file transport.h.
|
overridevirtual |
Initializes the cloned object.
| ZrythmException | If the object could not be cloned. |
Implements ICloneable< Transport >.
| void Transport::init_loaded | ( | Project * | project, |
| const TempoTrack * | tempo_track ) |
Initialize loaded transport.
| engine | Owner engine, if any. |
| tempo_track | Tempo track, used to initialize the caches. Only needed on the active project transport. |
|
overridevirtual |
Implements IPortOwner.
|
inlineoverridevirtual |
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 314 of file transport.h.
|
inline |
Definition at line 208 of file transport.h.
|
inline |
Definition at line 210 of file transport.h.
|
inline |
Definition at line 203 of file transport.h.
|
inline |
Definition at line 198 of file transport.h.
| void Transport::move_playhead | ( | const Position & | target, |
| bool | panic, | ||
| bool | set_cue_point, | ||
| bool | fire_events ) |
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 | Position to set to. |
| panic | Send MIDI panic or not FIXME unused. |
| set_cue_point | Also set the cue point at this position. |
|
overridevirtual |
Adds frames to the given position similar to Position::add_frames, except that it adjusts the new Position if the loop end point was crossed.
Implements zrythm::dsp::ITransport.
| void Transport::prepare_audio_regions_for_stretch | ( | std::optional< 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 174 of file transport.h.
|
inlinestatic |
Definition at line 169 of file transport.h.
| void Transport::recalculate_total_bars | ( | std::optional< 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.
| Q_INVOKABLE void 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 Transport::requestRoll | ( | bool | with_wait | ) |
Request playback.
Must only be called in-between engine processing calls.
| with_wait | Wait for lock before requesting. |
| void 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. |
|
overridevirtual |
Function that will be called by the Port to update the identifier's relevant members based on this port owner.
| id | The identifier to update. |
Implements IPortOwner.
| void 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 Transport::stretch_regions | ( | std::optional< 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 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 528 of file transport.h.
|
friend |
Definition at line 506 of file transport.h.
| std::unique_ptr<MidiPort> Transport::backward_ |
Backward MIDI port.
Definition at line 657 of file transport.h.
| signed_frame_t Transport::countin_frames_remaining_ = 0 |
Metronome countin frames remaining.
Definition at line 628 of file transport.h.
| PositionProxy* Transport::cue_pos_ = nullptr |
Cue point position.
Definition at line 569 of file transport.h.
| std::unique_ptr<MidiPort> Transport::forward_ |
Forward MIDI port.
Definition at line 660 of file transport.h.
| bool Transport::has_range_ = false |
Whether range should be displayed or not.
Definition at line 595 of file transport.h.
| RtTimePoint Transport::last_manual_playhead_change_ = 0 |
Last timestamp the playhead position was changed manually.
Definition at line 672 of file transport.h.
| bool Transport::loop_ = false |
Looping or not.
Definition at line 612 of file transport.h.
| PositionProxy* Transport::loop_end_pos_ = nullptr |
Loop end position.
Definition at line 575 of file transport.h.
| PositionProxy* Transport::loop_start_pos_ = nullptr |
Loop start position.
Definition at line 572 of file transport.h.
| std::unique_ptr<MidiPort> Transport::loop_toggle_ |
Loop toggle MIDI port.
Definition at line 663 of file transport.h.
| bool Transport::metronome_enabled_ = false |
Metronome enabled or not.
Definition at line 622 of file transport.h.
| PlayState Transport::play_state_ = {} |
Play state.
Definition at line 669 of file transport.h.
| Position Transport::playhead_before_pause_ |
Position of the playhead before pausing.
Used by UndoableAction.
Definition at line 640 of file transport.h.
| PositionProxy* Transport::playhead_pos_ = nullptr |
Playhead position.
Definition at line 566 of file transport.h.
| nframes_t Transport::position_ = 0 |
| signed_frame_t Transport::preroll_frames_remaining_ = 0 |
Recording preroll frames remaining.
Definition at line 625 of file transport.h.
| Project* Transport::project_ = nullptr |
Pointer to owner, if any.
Definition at line 675 of file transport.h.
| PositionProxy* Transport::punch_in_pos_ = nullptr |
Punch in position.
Definition at line 578 of file transport.h.
| bool Transport::punch_mode_ = false |
Whether punch in/out mode is enabled.
Definition at line 615 of file transport.h.
| PositionProxy* Transport::punch_out_pos_ = nullptr |
Punch out position.
Definition at line 581 of file transport.h.
| Position 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 591 of file transport.h.
| Position Transport::range_2_ |
Definition at line 592 of file transport.h.
| std::unique_ptr<MidiPort> Transport::rec_toggle_ |
Rec toggle MIDI port.
Definition at line 666 of file transport.h.
| bool Transport::recording_ = false |
Whether MIDI/audio recording is enabled (recording toggle in transport bar).
Definition at line 619 of file transport.h.
| RecordingMode Transport::recording_mode_ = (RecordingMode) 0 |
Definition at line 633 of file transport.h.
| std::unique_ptr<MidiPort> Transport::roll_ |
Roll/play MIDI port.
Any event received on this port will request a roll.
Definition at line 647 of file transport.h.
| int Transport::sixteenths_per_bar_ = 0 |
Definition at line 603 of file transport.h.
| int Transport::sixteenths_per_beat_ = 0 |
Definition at line 602 of file transport.h.
| bool Transport::start_playback_on_midi_input_ = false |
Whether to start playback on MIDI input.
Definition at line 631 of file transport.h.
| std::unique_ptr<MidiPort> Transport::stop_ |
Stop MIDI port.
Any event received on this port will request a stop/pause.
Definition at line 654 of file transport.h.
| int Transport::ticks_per_bar_ = 0 |
Definition at line 601 of file transport.h.
| int Transport::ticks_per_beat_ = 0 |
Definition at line 600 of file transport.h.
| int Transport::total_bars_ = 0 |
Total bars in the song.
Definition at line 563 of file transport.h.
|
read |
Definition at line 67 of file transport.h.
|
readwrite |
Definition at line 57 of file transport.h.
|
read |
Definition at line 70 of file transport.h.
|
read |
Definition at line 68 of file transport.h.
|
read |
Definition at line 66 of file transport.h.
|
readwrite |
Definition at line 63 of file transport.h.
|
read |
Definition at line 71 of file transport.h.
|
read |
Definition at line 72 of file transport.h.
|
readwrite |
Definition at line 60 of file transport.h.