2 * Carla JACK API for external applications
3 * Copyright (C) 2016-2019 Filipe Coelho <falktx@falktx.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #ifndef CARLA_LIBJACK_API_H_INCLUDED
19 #define CARLA_LIBJACK_API_H_INCLUDED
21 #include "CarlaLibJackHints.h"
22 #include "../jackbridge/JackBridge.hpp"
28 typedef uint32_t jack_port_type_id_t
;
29 typedef void*(*JackThreadCallback
)(void* arg
);
31 // --------------------------------------------------------------------------------------------------------------------
34 CARLA_API
void jack_get_version(int*, int*, int*, int*);
35 CARLA_API
const char* jack_get_version_string(void);
36 CARLA_API jack_client_t
* jack_client_open(const char*, jack_options_t
, jack_status_t
*, ...);
37 CARLA_API jack_client_t
* jack_client_new(const char*);
38 CARLA_API
int jack_client_close(jack_client_t
*);
39 CARLA_API
int jack_client_name_size(void);
40 CARLA_API
char* jack_get_client_name(jack_client_t
*);
41 CARLA_API
char* jack_get_uuid_for_client_name(jack_client_t
*, const char*);
42 CARLA_API
char* jack_get_client_name_by_uuid(jack_client_t
*, const char*);
43 CARLA_API
int jack_internal_client_new(const char*, const char*, const char*);
44 CARLA_API
void jack_internal_client_close(const char*);
45 CARLA_API
int jack_activate(jack_client_t
*);
46 CARLA_API
int jack_deactivate(jack_client_t
*);
47 CARLA_API
int jack_get_client_pid(const char*);
48 CARLA_API pthread_t
jack_client_thread_id(jack_client_t
*);
49 CARLA_API
int jack_is_realtime(jack_client_t
*);
50 CARLA_API jack_nframes_t
jack_thread_wait(jack_client_t
*, int);
51 CARLA_API jack_nframes_t
jack_cycle_wait(jack_client_t
*);
52 CARLA_API
void jack_cycle_signal(jack_client_t
*, int);
53 CARLA_API
int jack_set_process_thread(jack_client_t
*, JackThreadCallback
, void*);
54 CARLA_API
int jack_set_thread_init_callback(jack_client_t
*, JackThreadInitCallback
, void*);
55 CARLA_API
void jack_on_shutdown(jack_client_t
*, JackShutdownCallback
, void*);
56 CARLA_API
void jack_on_info_shutdown(jack_client_t
*, JackInfoShutdownCallback
, void*);
57 CARLA_API
int jack_set_process_callback(jack_client_t
*, JackProcessCallback
, void*);
58 CARLA_API
int jack_set_freewheel_callback(jack_client_t
*, JackFreewheelCallback
, void*);
59 CARLA_API
int jack_set_buffer_size_callback(jack_client_t
*, JackBufferSizeCallback
, void*);
60 CARLA_API
int jack_set_sample_rate_callback(jack_client_t
*, JackSampleRateCallback
, void*);
61 CARLA_API
int jack_set_client_registration_callback(jack_client_t
*, JackClientRegistrationCallback
, void*);
62 CARLA_API
int jack_set_port_registration_callback(jack_client_t
*, JackPortRegistrationCallback
, void*);
63 CARLA_API
int jack_set_port_connect_callback(jack_client_t
*, JackPortConnectCallback
, void*);
64 CARLA_API
int jack_set_port_rename_callback(jack_client_t
*, JackPortRenameCallback
, void*);
65 CARLA_API
int jack_set_graph_order_callback(jack_client_t
*, JackGraphOrderCallback
, void*);
66 CARLA_API
int jack_set_xrun_callback(jack_client_t
*, JackXRunCallback
, void*);
67 CARLA_API
int jack_set_latency_callback(jack_client_t
*, JackLatencyCallback
, void*);
68 CARLA_API
int jack_set_freewheel(jack_client_t
*, int);
69 CARLA_API
int jack_set_buffer_size(jack_client_t
*, jack_nframes_t
);
70 CARLA_API jack_nframes_t
jack_get_sample_rate(jack_client_t
*);
71 CARLA_API jack_nframes_t
jack_get_buffer_size(jack_client_t
*);
72 CARLA_API
int jack_engine_takeover_timebase(jack_client_t
*);
73 CARLA_API
float jack_cpu_load(jack_client_t
*);
74 CARLA_API jack_port_t
* jack_port_register(jack_client_t
*, const char*, const char*, unsigned long, unsigned long);
75 CARLA_API
int jack_port_unregister(jack_client_t
*, jack_port_t
*);
76 CARLA_API
void* jack_port_get_buffer(jack_port_t
*, jack_nframes_t
);
77 CARLA_API jack_uuid_t
jack_port_uuid(const jack_port_t
*);
78 CARLA_API
const char* jack_port_name(const jack_port_t
*);
79 CARLA_API
const char* jack_port_short_name(const jack_port_t
*);
80 CARLA_API
int jack_port_flags(const jack_port_t
*);
81 CARLA_API
const char* jack_port_type(const jack_port_t
*);
82 CARLA_API jack_port_type_id_t
jack_port_type_id(const jack_port_t
*);
83 CARLA_API
int jack_port_is_mine(const jack_client_t
*, const jack_port_t
*);
84 CARLA_API
int jack_port_connected(const jack_port_t
*);
85 CARLA_API
int jack_port_connected_to(const jack_port_t
*, const char*);
86 CARLA_API
const char** jack_port_get_connections(const jack_port_t
*);
87 CARLA_API
const char** jack_port_get_all_connections(const jack_client_t
*, const jack_port_t
*);
88 CARLA_API
int jack_port_tie(jack_port_t
*, jack_port_t
*);
89 CARLA_API
int jack_port_untie(jack_port_t
*);
90 CARLA_API
int jack_port_set_name(jack_port_t
*, const char*);
91 CARLA_API
int jack_port_rename(jack_client_t
*, jack_port_t
*, const char*);
92 CARLA_API
int jack_port_set_alias(jack_port_t
*, const char*);
93 CARLA_API
int jack_port_unset_alias(jack_port_t
*, const char*);
94 CARLA_API
int jack_port_get_aliases(const jack_port_t
*, char* const aliases
[2]);
95 CARLA_API
int jack_port_request_monitor(jack_port_t
*, int);
96 CARLA_API
int jack_port_request_monitor_by_name(jack_client_t
*, const char*, int);
97 CARLA_API
int jack_port_ensure_monitor(jack_port_t
*, int);
98 CARLA_API
int jack_port_monitoring_input(jack_port_t
*);
99 CARLA_API
int jack_connect(jack_client_t
*, const char*, const char*);
100 CARLA_API
int jack_disconnect(jack_client_t
*, const char*, const char*);
101 CARLA_API
int jack_port_disconnect(jack_client_t
*, jack_port_t
*);
102 CARLA_API
int jack_port_name_size(void);
103 CARLA_API
int jack_port_type_size(void);
104 CARLA_API
size_t jack_port_type_get_buffer_size(jack_client_t
*, const char*);
105 CARLA_API
void jack_port_set_latency(jack_port_t
*, jack_nframes_t
);
106 CARLA_API
void jack_port_get_latency_range(jack_port_t
*, jack_latency_callback_mode_t
, jack_latency_range_t
*);
107 CARLA_API
void jack_port_set_latency_range(jack_port_t
*, jack_latency_callback_mode_t
, jack_latency_range_t
*);
108 CARLA_API
int jack_recompute_total_latencies(jack_client_t
*);
109 CARLA_API jack_nframes_t
jack_port_get_latency(jack_port_t
*);
110 CARLA_API jack_nframes_t
jack_port_get_total_latency(jack_client_t
*, jack_port_t
*);
111 CARLA_API
int jack_recompute_total_latency(jack_client_t
*, jack_port_t
*);
112 CARLA_API
const char** jack_get_ports(jack_client_t
*, const char*, const char*, unsigned long);
113 CARLA_API jack_port_t
* jack_port_by_name(jack_client_t
*, const char*);
114 CARLA_API jack_port_t
* jack_port_by_id(jack_client_t
*, jack_port_id_t
);
115 CARLA_API jack_nframes_t
jack_frames_since_cycle_start(const jack_client_t
*);
116 CARLA_API jack_nframes_t
jack_frame_time(const jack_client_t
*);
117 CARLA_API jack_nframes_t
jack_last_frame_time(const jack_client_t
*);
118 CARLA_API
int jack_get_cycle_times(const jack_client_t
*, jack_nframes_t
*, jack_time_t
*, jack_time_t
*, float*);
119 CARLA_API jack_time_t
jack_frames_to_time(const jack_client_t
*, jack_nframes_t
);
120 CARLA_API jack_nframes_t
jack_time_to_frames(const jack_client_t
*, jack_time_t
);
121 CARLA_API jack_time_t
jack_get_time(void);
122 CARLA_API
void jack_free(void*);
124 CARLA_API
extern void(*jack_error_callback
)(const char*msg
);
125 CARLA_API
void jack_set_error_function(void (*func
)(const char*));
127 CARLA_API
extern void (*jack_info_callback
)(const char*msg
);
128 CARLA_API
void jack_set_info_function(void (*func
)(const char*));
130 // --------------------------------------------------------------------------------------------------------------------
133 CARLA_API
int jack_set_property(jack_client_t
*, jack_uuid_t
, const char*, const char*, const char*);
134 CARLA_API
int jack_get_property(jack_uuid_t
, const char*, char**, char**);
135 CARLA_API
void jack_free_description(jack_description_t
*, int);
136 CARLA_API
int jack_get_properties(jack_uuid_t
, jack_description_t
*);
137 CARLA_API
int jack_get_all_properties(jack_description_t
**);
138 CARLA_API
int jack_remove_property(jack_client_t
*, jack_uuid_t
, const char*);
139 CARLA_API
int jack_remove_properties(jack_client_t
*, jack_uuid_t
);
140 CARLA_API
int jack_remove_all_properties(jack_client_t
*);
141 CARLA_API
int jack_set_property_change_callback(jack_client_t
*, JackPropertyChangeCallback
, void*);
143 // extern const char* JACK_METADATA_PRETTY_NAME;
144 // extern const char* JACK_METADATA_HARDWARE;
145 // extern const char* JACK_METADATA_CONNECTED;
146 // extern const char* JACK_METADATA_PORT_GROUP;
147 // extern const char* JACK_METADATA_ICON_SMALL;
148 // extern const char* JACK_METADATA_ICON_LARGE;
150 // --------------------------------------------------------------------------------------------------------------------
153 CARLA_API
uint32_t jack_midi_get_event_count(void*);
154 CARLA_API
int jack_midi_event_get(jack_midi_event_t
*, void*, uint32_t);
155 CARLA_API
void jack_midi_clear_buffer(void*);
156 CARLA_API
void jack_midi_reset_buffer(void*);
157 CARLA_API
size_t jack_midi_max_event_size(void*);
158 CARLA_API jack_midi_data_t
* jack_midi_event_reserve(void*, jack_nframes_t
, size_t);
159 CARLA_API
int jack_midi_event_write(void*, jack_nframes_t
, const jack_midi_data_t
*, size_t);
160 CARLA_API
uint32_t jack_midi_get_lost_event_count(void*);
162 // --------------------------------------------------------------------------------------------------------------------
165 CARLA_API
int jack_client_real_time_priority(jack_client_t
*);
166 CARLA_API
int jack_client_max_real_time_priority(jack_client_t
*);
167 CARLA_API
int jack_acquire_real_time_scheduling(pthread_t
, int );
168 CARLA_API
int jack_client_create_thread(jack_client_t
*, pthread_t
*, int, int, void*(*start_routine
)(void*), void*);
169 CARLA_API
int jack_drop_real_time_scheduling(pthread_t
);
170 CARLA_API
int jack_client_stop_thread(jack_client_t
*, pthread_t
);
171 CARLA_API
int jack_client_kill_thread(jack_client_t
*, pthread_t
);
173 typedef int (*jack_thread_creator_t
)(pthread_t
*, const pthread_attr_t
*, void* (*function
)(void*), void* arg
);
174 CARLA_API
void jack_set_thread_creator(jack_thread_creator_t
);
176 // --------------------------------------------------------------------------------------------------------------------
179 CARLA_API
int jack_set_session_callback(jack_client_t
*, JackSessionCallback
, void*);
180 CARLA_API
int jack_session_reply(jack_client_t
*, jack_session_event_t
*);
181 CARLA_API
void jack_session_event_free(jack_session_event_t
*);
182 CARLA_API
char* jack_client_get_uuid(jack_client_t
*);
183 CARLA_API jack_session_command_t
* jack_session_notify( jack_client_t
*, const char*, jack_session_event_type_t
, const char*);
184 CARLA_API
void jack_session_commands_free(jack_session_command_t
*);
185 CARLA_API
int jack_reserve_client_name(jack_client_t
*, const char*, const char*);
186 CARLA_API
int jack_client_has_session_callback(jack_client_t
*, const char*);
188 // --------------------------------------------------------------------------------------------------------------------
191 CARLA_API
float jack_get_max_delayed_usecs(jack_client_t
*);
192 CARLA_API
float jack_get_xrun_delayed_usecs(jack_client_t
*);
193 CARLA_API
void jack_reset_max_delayed_usecs(jack_client_t
*);
195 // --------------------------------------------------------------------------------------------------------------------
198 CARLA_API
int jack_release_timebase(jack_client_t
*);
199 CARLA_API
int jack_set_sync_callback(jack_client_t
*, JackSyncCallback
, void*);
200 CARLA_API
int jack_set_sync_timeout(jack_client_t
*, jack_time_t
);
201 CARLA_API
int jack_set_timebase_callback(jack_client_t
*, int, JackTimebaseCallback
, void*);
202 CARLA_API
int jack_transport_locate(jack_client_t
*, jack_nframes_t
);
203 CARLA_API jack_transport_state_t
jack_transport_query(const jack_client_t
*, jack_position_t
*);
204 CARLA_API jack_nframes_t
jack_get_current_transport_frame(const jack_client_t
*);
205 CARLA_API
int jack_transport_reposition(jack_client_t
*, const jack_position_t
*);
206 CARLA_API
void jack_transport_start(jack_client_t
*);
207 CARLA_API
void jack_transport_stop(jack_client_t
*);
208 CARLA_API
void jack_get_transport_info(jack_client_t
*, void*);
209 CARLA_API
void jack_set_transport_info(jack_client_t
*, void*);
211 // --------------------------------------------------------------------------------------------------------------------
214 #define JACK_UUID_SIZE 36
215 #define JACK_UUID_STRING_SIZE (JACK_UUID_SIZE+1) /* includes trailing null */
216 #define JACK_UUID_EMPTY_INITIALIZER 0
218 CARLA_API jack_uuid_t
jack_client_uuid_generate(void);
219 CARLA_API jack_uuid_t
jack_port_uuid_generate(uint32_t port_id
);
220 CARLA_API
uint32_t jack_uuid_to_index(jack_uuid_t
);
222 CARLA_API
int jack_uuid_compare(jack_uuid_t
, jack_uuid_t
);
223 CARLA_API
void jack_uuid_copy(jack_uuid_t
* dst
, jack_uuid_t src
);
224 CARLA_API
void jack_uuid_clear(jack_uuid_t
*);
225 CARLA_API
int jack_uuid_parse(const char*buf
, jack_uuid_t
*);
226 CARLA_API
void jack_uuid_unparse(jack_uuid_t
, char buf
[JACK_UUID_STRING_SIZE
]);
227 CARLA_API
int jack_uuid_empty(jack_uuid_t
);
229 // --------------------------------------------------------------------------------------------------------------------