10#ifndef __AUDIO_TRANSPORT_H__
11#define __AUDIO_TRANSPORT_H__
30#define TIME_SIGNATURE_SCHEMA_VERSION 1
31#define TRANSPORT_SCHEMA_VERSION 1
33#define TRANSPORT (AUDIO_ENGINE->transport)
34#define TRANSPORT_DEFAULT_TOTAL_BARS 128
36#define PLAYHEAD (&TRANSPORT->playhead_pos)
38#define TRANSPORT_IS_ROLLING \
39 (TRANSPORT->play_state == PlayState::PLAYSTATE_ROLLING)
40#define TRANSPORT_IS_PAUSED \
41 (TRANSPORT->play_state == PlayState::PLAYSTATE_PAUSED)
42#define TRANSPORT_IS_LOOPING (TRANSPORT->loop)
43#define TRANSPORT_IS_RECORDING (TRANSPORT->recording)
45enum class PrerollCountBars
47 PREROLL_COUNT_BARS_NONE,
48 PREROLL_COUNT_BARS_ONE,
49 PREROLL_COUNT_BARS_TWO,
50 PREROLL_COUNT_BARS_FOUR,
53static const char * preroll_count_bars_str[] = {
60static inline const char *
61transport_preroll_count_to_str (PrerollCountBars bars)
63 return preroll_count_bars_str[
static_cast<int> (bars)];
67transport_preroll_count_bars_enum_to_int (PrerollCountBars bars)
71 case PrerollCountBars::PREROLL_COUNT_BARS_NONE:
73 case PrerollCountBars::PREROLL_COUNT_BARS_ONE:
75 case PrerollCountBars::PREROLL_COUNT_BARS_TWO:
77 case PrerollCountBars::PREROLL_COUNT_BARS_FOUR:
85 PLAYSTATE_ROLL_REQUESTED,
87 PLAYSTATE_PAUSE_REQUESTED,
97 TRANSPORT_DISPLAY_BBT,
98 TRANSPORT_DISPLAY_TIME,
194 int sixteenths_per_beat;
195 int sixteenths_per_bar;
300 Track * tempo_track);
309transport_is_rolling (
const Transport * self);
343 bool with_fixed_ratio,
349transport_set_punch_mode_enabled (
Transport * self,
bool enabled);
352transport_set_start_playback_on_midi_input (
Transport * self,
bool enabled);
400transport_set_playhead_to_bar (
Transport * self,
int bar);
497transport_frames_add_frames (
573HOT NONNULL WARN_UNUSED_RESULT
static inline nframes_t
574transport_is_loop_point_met (
611transport_update_caches (
Transport * self,
int beats_per_bar,
int beat_unit);
Ports that transfer audio/midi/other signals to one another.
A region in the timeline.
TransportDisplay
Corrseponts to "transport-display" in the gsettings.
void transport_move_backward(Transport *self, bool with_wait)
Move to the previous snap point on the timeline.
bool transport_can_user_move_playhead(const Transport *self)
Returns whether the user can currently move the playhead (eg, via the UI or via scripts).
void transport_add_to_playhead(Transport *self, const signed_frame_t nframes)
Moves the playhead by the time corresponding to given samples, taking into account the loop end point...
void transport_set_loop(Transport *self, bool enabled, bool with_wait)
Enables or disables loop.
void transport_get_loop_range_pos(Transport *self, bool first, Position *pos)
Stores the position of the range in pos.
void transport_update_positions(Transport *self, bool update_from_ticks)
Updates the frames in all transport positions.
void transport_prepare_audio_regions_for_stretch(Transport *self, TimelineSelections *sel)
Prepares audio regions for stretching (sets the Region::before_length).
void transport_set_loop_range(Transport *self, bool start, const Position *start_pos, const Position *pos, bool snap)
Set the loop range.
void transport_set_has_range(Transport *self, bool has_range)
Sets if the project has range and updates UI.
void transport_set_metronome_enabled(Transport *self, const int enabled)
Sets whether metronome is enabled or not.
void transport_get_playhead_pos(Transport *self, Position *pos)
Getter for playhead Position.
TransportRecordingMode
Recording mode for MIDI and audio.
NONNULL Transport * transport_new(AudioEngine *engine)
Initialize transport.
void transport_init_loaded(Transport *self, AudioEngine *engine, Track *tempo_track)
Initialize loaded transport.
void transport_update_total_bars(Transport *self, int total_bars, bool fire_events)
Updates the total bars.
void transport_set_recording(Transport *self, bool record, bool with_wait, bool fire_events)
Sets recording on/off.
void transport_move_playhead(Transport *self, const Position *target, bool panic, bool set_cue_point, bool fire_events)
Moves playhead to given pos.
double transport_get_ppqn(Transport *self)
Returns the PPQN (Parts/Ticks Per Quarter Note).
void transport_move_forward(Transport *self, bool with_wait)
Move to the next snap point on the timeline.
void transport_recalculate_total_bars(Transport *self, ArrangerSelections *sel)
Recalculates the total bars based on the last object's position.
void transport_get_range_pos(Transport *self, bool first, Position *pos)
Stores the position of the range in pos.
void transport_goto_next_marker(Transport *self)
Moves the playhead to the next Marker.
void transport_goto_end_marker(Transport *self)
Moves the playhead to the end Marker.
Transport * transport_clone(const Transport *src)
Clones the transport values.
bool transport_stretch_regions(Transport *self, TimelineSelections *sel, bool with_fixed_ratio, double time_ratio, bool force, GError **error)
Stretches regions.
void transport_set_playhead_pos(Transport *self, Position *pos)
Setter for playhead Position.
void transport_request_pause(Transport *self, bool with_wait)
Request pause.
void transport_request_roll(Transport *self, bool with_wait)
Request playback.
void transport_goto_prev_marker(Transport *self)
Moves the playhead to the prev Marker.
void transport_position_add_frames(const Transport *self, Position *pos, const signed_frame_t frames)
Adds frames to the given position similar to position_add_frames, except that it adjusts the new Posi...
void transport_goto_start_marker(Transport *self)
Moves the playhead to the start Marker.
void transport_set_range(Transport *self, bool range1, const Position *start_pos, const Position *pos, bool snap)
Set the range1 or range2 position.
@ RECORDING_MODE_TAKES_MUTED
Same as RECORDING_MODE_TAKES, except previous takes (since recording started) are muted.
@ RECORDING_MODE_OVERWRITE_EVENTS
Overwrite events in first recorded region.
@ RECORDING_MODE_MERGE_EVENTS
Merge events in existing region.
@ RECORDING_MODE_TAKES
Events get put in new lanes each time recording starts/resumes (eg, when looping or entering/leaving ...
int_fast64_t signed_frame_t
Signed type for frame index.
uint32_t nframes_t
Frame count.
Must ONLY be created via port_new()
A Position is made up of bars.beats.sixteenths.ticks.
signed_frame_t frames
Position in frames (samples).
Selections to be used for the timeline's current selections, copying, undoing, etc.
Track to be inserted into the Project's Tracklist.
Port * forward
Forward MIDI port.
bool punch_mode
Whether punch in/out mode is enabled.
Position range_1
Selected range.
int total_bars
Total bars in the song.
int has_range
Whether range should be displayed or not.
signed_frame_t countin_frames_remaining
Metronome countin frames remaining.
Position loop_end_pos
Loop end position.
Position playhead_before_pause
Position of the playhead before pausing.
Position punch_out_pos
Punch out position.
PlayState play_state
Play state.
Port * backward
Backward MIDI port.
Position playhead_pos
Playhead position.
nframes_t position
Transport position in frames.
signed_frame_t preroll_frames_remaining
Recording preroll frames remaining.
AudioEngine * audio_engine
Pointer to owner audio engine, if any.
Port * rec_toggle
Rec toggle MIDI port.
Position loop_start_pos
Loop start position.
ZixSem paused
This is set when record is toggled and is used to check if a new region should be created.
bool recording
Whether MIDI/audio recording is enabled (recording toggle in transport bar).
Port * roll
Roll/play MIDI port.
Port * stop
Stop MIDI port.
Position punch_in_pos
Punch in position.
bool metronome_enabled
Metronome enabled or not.
gint64 last_manual_playhead_change
Last timestamp the playhead position was changed manually.
bool start_playback_on_midi_input
Whether to start playback on MIDI input.
Port * loop_toggle
Loop toggle MIDI port.
Position cue_pos
Cue point position.