JACK-AUDIO-CONNECTION-KIT
Data Structures | Typedefs | Enumerations | Enumerator | Functions | Variables
Transport and Timebase control

Data Structures

struct  jack_transport_info_t
 

Typedefs

typedef int(* JackSyncCallback) (jack_transport_state_t state, jack_position_t *pos, void *arg)
 
typedef void(* JackTimebaseCallback) (jack_transport_state_t state, jack_nframes_t nframes, jack_position_t *pos, int new_pos, void *arg)
 

Enumerations

enum  jack_transport_bits_t {
  JackTransportState = 0x1 , JackTransportPosition = 0x2 , JackTransportLoop = 0x4 , JackTransportSMPTE = 0x8 ,
  JackTransportBBT = 0x10
}
 

Functions

int jack_release_timebase (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT
 
int jack_set_sync_callback (jack_client_t *client, JackSyncCallback sync_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT
 
int jack_set_sync_timeout (jack_client_t *client, jack_time_t timeout) JACK_OPTIONAL_WEAK_EXPORT
 
int jack_set_timebase_callback (jack_client_t *client, int conditional, JackTimebaseCallback timebase_callback, void *arg) JACK_OPTIONAL_WEAK_EXPORT
 
int jack_transport_locate (jack_client_t *client, jack_nframes_t frame) JACK_OPTIONAL_WEAK_EXPORT
 
jack_transport_state_t jack_transport_query (const jack_client_t *client, jack_position_t *pos) JACK_OPTIONAL_WEAK_EXPORT
 
jack_nframes_t jack_get_current_transport_frame (const jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT
 
int jack_transport_reposition (jack_client_t *client, const jack_position_t *pos) JACK_OPTIONAL_WEAK_EXPORT
 
void jack_transport_start (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT
 
void jack_transport_stop (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT
 
void jack_get_transport_info (jack_client_t *client, jack_transport_info_t *tinfo) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT
 
void jack_set_transport_info (jack_client_t *client, jack_transport_info_t *tinfo) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT
 

Variables

jack_nframes_t jack_transport_info_t::frame_rate
 
jack_time_t jack_transport_info_t::usecs
 
jack_transport_bits_t jack_transport_info_t::valid
 
jack_transport_state_t jack_transport_info_t::transport_state
 
jack_nframes_t jack_transport_info_t::frame
 
jack_nframes_t jack_transport_info_t::loop_start
 
jack_nframes_t jack_transport_info_t::loop_end
 
long jack_transport_info_t::smpte_offset
 
float jack_transport_info_t::smpte_frame_rate
 
int jack_transport_info_t::bar
 
int jack_transport_info_t::beat
 
int jack_transport_info_t::tick
 
double jack_transport_info_t::bar_start_tick
 
float jack_transport_info_t::beats_per_bar
 
float jack_transport_info_t::beat_type
 
double jack_transport_info_t::ticks_per_beat
 
double jack_transport_info_t::beats_per_minute
 

Server-set fields

these cannot be set from clients; the server sets them

jack_unique_t jack_position_t::unique_1
 
jack_time_t jack_position_t::usecs
 
jack_nframes_t jack_position_t::frame_rate
 

Mandatory fields

jack_nframes_t jack_position_t::frame
 
jack_position_bits_t jack_position_t::valid
 

JackPositionBBT fields

Bar:Beat.Tick-related information.

Applications that support JackPositionBBT are encouraged to also fill the JackBBTFrameOffset

int32_t jack_position_t::bar
 
int32_t jack_position_t::beat
 
int32_t jack_position_t::tick
 
double jack_position_t::bar_start_tick
 
float jack_position_t::beats_per_bar
 
float jack_position_t::beat_type
 
double jack_position_t::ticks_per_beat
 
double jack_position_t::beats_per_minute
 

JackPositionTimecode fields <br>

EXPERIMENTAL: could change

double jack_position_t::frame_time
 
double jack_position_t::next_time
 
jack_nframes_t jack_position_t::bbt_offset
 
float jack_position_t::audio_frames_per_video_frame
 
jack_nframes_t jack_position_t::video_offset
 

JACK Extra transport fields

double jack_position_t::tick_double
 

Other fields

int32_t jack_position_t::padding [5]
 
jack_unique_t jack_position_t::unique_2
 

Detailed Description

Typedef Documentation

◆ JackSyncCallback

typedef int(* JackSyncCallback) (jack_transport_state_t state, jack_position_t *pos, void *arg)

Prototype for the sync_callback defined by slow-sync clients. When the client is active, this callback is invoked just before process() in the same thread. This occurs once after registration, then subsequently whenever some client requests a new position, or the transport enters the JackTransportStarting state. This realtime function must not wait.

The transport state will be:

Parameters
statecurrent transport state.
posnew transport position.
argthe argument supplied by jack_set_sync_callback().
Returns
TRUE (non-zero) when ready to roll.

◆ JackTimebaseCallback

typedef void(* JackTimebaseCallback) (jack_transport_state_t state, jack_nframes_t nframes, jack_position_t *pos, int new_pos, void *arg)

Prototype for the timebase_callback used to provide extended position information. Its output affects all of the following process cycle. This realtime function must not wait.

This function is called immediately after process() in the same thread whenever the transport is rolling, or when any client has requested a new position in the previous cycle. The first cycle after jack_set_timebase_callback() is also treated as a new position, or the first cycle after jack_activate() if the client had been inactive.

The timebase master may not use its pos argument to set pos->frame. To change position, use jack_transport_reposition() or jack_transport_locate(). These functions are realtime-safe, the timebase_callback can call them directly.

Parameters
statecurrent transport state.
nframesnumber of frames in current period.
posaddress of the position structure for the next cycle; pos->frame will be its frame number. If new_pos is FALSE, this structure contains extended position information from the current cycle. If TRUE, it contains whatever was set by the requester. The timebase_callback's task is to update the extended information here.
new_posTRUE (non-zero) for a newly requested pos, or for the first cycle after the timebase_callback is defined.
argthe argument supplied by jack_set_timebase_callback().

Enumeration Type Documentation

◆ jack_transport_bits_t

Optional struct jack_transport_info_t fields.

See also
jack_position_bits_t.
Enumerator
JackTransportState 

Transport state

JackTransportPosition 

Frame number

JackTransportLoop 

Loop boundaries (ignored)

JackTransportSMPTE 

SMPTE (ignored)

JackTransportBBT 

Bar, Beat, Tick

Function Documentation

◆ jack_get_current_transport_frame()

jack_nframes_t jack_get_current_transport_frame ( const jack_client_t client)

Return an estimate of the current transport frame, including any time elapsed since the last transport positional update.

Parameters
clientthe JACK client structure

◆ jack_get_transport_info()

void jack_get_transport_info ( jack_client_t client,
jack_transport_info_t tinfo 
)

Gets the current transport info structure (deprecated).

Parameters
clientthe JACK client structure.
tinfocurrent transport info structure. The "valid" field describes which fields contain valid data.
Deprecated:
This is for compatibility with the earlier transport interface. Use jack_transport_query(), instead.
Precondition
Must be called from the process thread.

◆ jack_release_timebase()

int jack_release_timebase ( jack_client_t client)

Called by the timebase master to release itself from that responsibility.

If the timebase master releases the timebase or leaves the JACK graph for any reason, the JACK engine takes over at the start of the next process cycle. The transport state does not change. If rolling, it continues to play, with frame numbers as the only available position information.

See also
jack_set_timebase_callback
Parameters
clientthe JACK client structure.
Returns
0 on success, otherwise a non-zero error code.

◆ jack_set_sync_callback()

int jack_set_sync_callback ( jack_client_t client,
JackSyncCallback  sync_callback,
void *  arg 
)

Register (or unregister) as a slow-sync client, that cannot respond immediately to transport position changes.

The sync_callback will be invoked at the first available opportunity after its registration is complete. If the client is currently active this will be the following process cycle, otherwise it will be the first cycle after calling jack_activate(). After that, it runs according to the JackSyncCallback rules. Clients that don't set a sync_callback are assumed to be ready immediately any time the transport wants to start.

Parameters
clientthe JACK client structure.
sync_callbackis a realtime function that returns TRUE when the client is ready. Setting sync_callback to NULL declares that this client no longer requires slow-sync processing.
argan argument for the sync_callback function.
Returns
0 on success, otherwise a non-zero error code.

◆ jack_set_sync_timeout()

int jack_set_sync_timeout ( jack_client_t client,
jack_time_t  timeout 
)

Set the timeout value for slow-sync clients.

This timeout prevents unresponsive slow-sync clients from completely halting the transport mechanism. The default is two seconds. When the timeout expires, the transport starts rolling, even if some slow-sync clients are still unready. The sync_callbacks of these clients continue being invoked, giving them a chance to catch up.

See also
jack_set_sync_callback
Parameters
clientthe JACK client structure.
timeoutis delay (in microseconds) before the timeout expires.
Returns
0 on success, otherwise a non-zero error code.

◆ jack_set_timebase_callback()

int jack_set_timebase_callback ( jack_client_t client,
int  conditional,
JackTimebaseCallback  timebase_callback,
void *  arg 
)

Register as timebase master for the JACK subsystem.

The timebase master registers a callback that updates extended position information such as beats or timecode whenever necessary. Without this extended information, there is no need for this function.

There is never more than one master at a time. When a new client takes over, the former timebase_callback is no longer called. Taking over the timebase may be done conditionally, so it fails if there was a master already.

The method may be called whether the client has been activated or not.

Parameters
clientthe JACK client structure.
conditionalnon-zero for a conditional request.
timebase_callbackis a realtime function that returns position information.
argan argument for the timebase_callback function.
Returns
  • 0 on success;
  • EBUSY if a conditional request fails because there was already a timebase master;
  • other non-zero error code.

◆ jack_set_transport_info()

void jack_set_transport_info ( jack_client_t client,
jack_transport_info_t tinfo 
)

Set the transport info structure (deprecated).

Deprecated:
This function still exists for compatibility with the earlier transport interface, but it does nothing. Instead, define a JackTimebaseCallback.

◆ jack_transport_locate()

int jack_transport_locate ( jack_client_t client,
jack_nframes_t  frame 
)

Reposition the transport to a new frame number.

May be called at any time by any client. The new position takes effect in two process cycles. If there are slow-sync clients and the transport is already rolling, it will enter the JackTransportStarting state and begin invoking their sync_callbacks until ready. This function is realtime-safe.

See also
jack_transport_reposition, jack_set_sync_callback
Parameters
clientthe JACK client structure.
frameframe number of new transport position.
Returns
0 if valid request, non-zero otherwise.

◆ jack_transport_query()

jack_transport_state_t jack_transport_query ( const jack_client_t client,
jack_position_t pos 
)

Query the current transport state and position.

This function is realtime-safe, and can be called from any thread. If called from the process thread, pos corresponds to the first frame of the current cycle and the state returned is valid for the entire cycle.

Parameters
clientthe JACK client structure.
pospointer to structure for returning current transport position; pos->valid will show which fields contain valid data. If pos is NULL, do not return position information.
Returns
Current transport state.

◆ jack_transport_reposition()

int jack_transport_reposition ( jack_client_t client,
const jack_position_t pos 
)

Request a new transport position.

May be called at any time by any client. The new position takes effect in two process cycles. If there are slow-sync clients and the transport is already rolling, it will enter the JackTransportStarting state and begin invoking their sync_callbacks until ready. This function is realtime-safe.

See also
jack_transport_locate, jack_set_sync_callback
Parameters
clientthe JACK client structure.
posrequested new transport position. Fill pos->valid to specify which fields should be taken into account. If you mark a set of fields as valid, you are expected to fill them all.
Returns
0 if valid request, EINVAL if position structure rejected.

◆ jack_transport_start()

void jack_transport_start ( jack_client_t client)

Start the JACK transport rolling.

Any client can make this request at any time. It takes effect no sooner than the next process cycle, perhaps later if there are slow-sync clients. This function is realtime-safe.

See also
jack_set_sync_callback
Parameters
clientthe JACK client structure.

◆ jack_transport_stop()

void jack_transport_stop ( jack_client_t client)

Stop the JACK transport.

Any client can make this request at any time. It takes effect on the next process cycle. This function is realtime-safe.

Parameters
clientthe JACK client structure.

Variable Documentation

◆ audio_frames_per_video_frame

float jack_position_t::audio_frames_per_video_frame

number of audio frames per video frame. Should be assumed zero if JackAudioVideoRatio is not set. If JackAudioVideoRatio is set and the value is zero, no video data exists within the JACK graph

◆ bar [1/2]

int32_t jack_position_t::bar

current bar

Should be >0: the first bar is bar '1'.

◆ bar [2/2]

int jack_transport_info_t::bar

◆ bar_start_tick [1/2]

double jack_position_t::bar_start_tick

number of ticks that have elapsed between frame 0 and the first beat of the current measure.

◆ bar_start_tick [2/2]

double jack_transport_info_t::bar_start_tick

◆ bbt_offset

jack_nframes_t jack_position_t::bbt_offset

frame offset for the BBT fields (the given bar, beat, and tick values actually refer to a time frame_offset frames before the start of the cycle), should be assumed to be 0 if JackBBTFrameOffset is not set. If JackBBTFrameOffset is set and this value is zero, the BBT time refers to the first frame of this cycle. If the value is positive, the BBT time refers to a frame that many frames before the start of the cycle.

◆ beat [1/2]

int32_t jack_position_t::beat

current beat-within-bar

Should be >0 and <=beats_per_bar: the first beat is beat '1'.

◆ beat [2/2]

int jack_transport_info_t::beat

◆ beat_type [1/2]

float jack_position_t::beat_type

time signature "denominator"

◆ beat_type [2/2]

float jack_transport_info_t::beat_type

◆ beats_per_bar [1/2]

float jack_position_t::beats_per_bar

time signature "numerator"

◆ beats_per_bar [2/2]

float jack_transport_info_t::beats_per_bar

◆ beats_per_minute [1/2]

double jack_position_t::beats_per_minute

BPM, quantized to block size. This means when the tempo is not constant within this block, the BPM value should adapted to compensate for this. This is different from most fields in this struct, which specify the value at the beginning of the block rather than an average.

◆ beats_per_minute [2/2]

double jack_transport_info_t::beats_per_minute

◆ frame [1/2]

jack_nframes_t jack_position_t::frame

frame number, always present/required.

This is the frame number on the transport timeline, which is not the same as what jack_frame_time returns.

◆ frame [2/2]

jack_nframes_t jack_transport_info_t::frame

◆ frame_rate [1/2]

jack_nframes_t jack_position_t::frame_rate

current frame rate, in frames per second

◆ frame_rate [2/2]

jack_nframes_t jack_transport_info_t::frame_rate

current frame rate (per second)

◆ frame_time

double jack_position_t::frame_time

current time in seconds

◆ loop_end

jack_nframes_t jack_transport_info_t::loop_end

◆ loop_start

jack_nframes_t jack_transport_info_t::loop_start

◆ next_time

double jack_position_t::next_time

next sequential frame_time (unless repositioned)

◆ padding

int32_t jack_position_t::padding[5]

◆ smpte_frame_rate

float jack_transport_info_t::smpte_frame_rate

29.97, 30, 24 etc.

◆ smpte_offset

long jack_transport_info_t::smpte_offset

SMPTE offset (from frame 0)

◆ tick [1/2]

int32_t jack_position_t::tick

current tick-within-beat

Should be >= 0 and < ticks_per_beat: the first tick is tick '0'.

◆ tick [2/2]

int jack_transport_info_t::tick

◆ tick_double

double jack_position_t::tick_double

current tick-within-beat in double resolution. Should be assumed zero if JackTickDouble is not set. Since older versions of JACK do not expose this variable, the macro JACK_TICK_DOUBLE is provided, which can be used as build-time detection.

◆ ticks_per_beat [1/2]

double jack_position_t::ticks_per_beat

number of ticks within a beat.

Usually a moderately large integer with many denominators, such as 1920.0

◆ ticks_per_beat [2/2]

double jack_transport_info_t::ticks_per_beat

◆ transport_state

jack_transport_state_t jack_transport_info_t::transport_state

◆ unique_1

jack_unique_t jack_position_t::unique_1

unique ID

◆ unique_2

jack_unique_t jack_position_t::unique_2

unique ID

◆ usecs [1/2]

jack_time_t jack_position_t::usecs

microsecond timestamp that is guaranteed to be monotonic, but not neccessarily linear.

The absolute value is implementation-dependent (i.e. it could be wall-clock, time since jack started, uptime, etc).

◆ usecs [2/2]

jack_time_t jack_transport_info_t::usecs

monotonic, free-rolling

◆ valid [1/2]

jack_position_bits_t jack_position_t::valid

which other fields are valid, as a bitmask constructed from values in jack_position_bits_t

◆ valid [2/2]

jack_transport_bits_t jack_transport_info_t::valid

which fields are legal to read

◆ video_offset

jack_nframes_t jack_position_t::video_offset

audio frame at which the first video frame in this cycle occurs. Should be assumed to be 0 if JackVideoFrameOffset is not set. If JackVideoFrameOffset is set, but the value is zero, there is no video frame within this cycle.