Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

api.hpp 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. * Carla JACK API for external applications
  3. * Copyright (C) 2016-2019 Filipe Coelho <falktx@falktx.com>
  4. *
  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.
  9. *
  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.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_LIBJACK_API_H_INCLUDED
  18. #define CARLA_LIBJACK_API_H_INCLUDED
  19. #include "CarlaLibJackHints.h"
  20. #include "jackbridge/JackBridge.hpp"
  21. #include <pthread.h>
  22. extern "C" {
  23. typedef uint32_t jack_port_type_id_t;
  24. typedef void*(*JackThreadCallback)(void* arg);
  25. // --------------------------------------------------------------------------------------------------------------------
  26. // jack.h
  27. void jack_get_version(int*, int*, int*, int*);
  28. const char* jack_get_version_string(void);
  29. jack_client_t* jack_client_open(const char*, jack_options_t, jack_status_t*, ...);
  30. jack_client_t* jack_client_new(const char*);
  31. int jack_client_close(jack_client_t*);
  32. int jack_client_name_size(void);
  33. char* jack_get_client_name(jack_client_t*);
  34. char* jack_get_uuid_for_client_name(jack_client_t*, const char*);
  35. char* jack_get_client_name_by_uuid(jack_client_t*, const char*);
  36. int jack_internal_client_new(const char*, const char*, const char*);
  37. void jack_internal_client_close(const char*);
  38. int jack_activate(jack_client_t*);
  39. int jack_deactivate(jack_client_t*);
  40. int jack_get_client_pid(const char*);
  41. pthread_t jack_client_thread_id(jack_client_t*);
  42. int jack_is_realtime(jack_client_t*);
  43. jack_nframes_t jack_thread_wait(jack_client_t*, int);
  44. jack_nframes_t jack_cycle_wait(jack_client_t*);
  45. void jack_cycle_signal(jack_client_t*, int);
  46. int jack_set_process_thread(jack_client_t*, JackThreadCallback, void*);
  47. int jack_set_thread_init_callback(jack_client_t*, JackThreadInitCallback, void*);
  48. void jack_on_shutdown(jack_client_t*, JackShutdownCallback, void*);
  49. void jack_on_info_shutdown(jack_client_t*, JackInfoShutdownCallback, void*);
  50. int jack_set_process_callback(jack_client_t*, JackProcessCallback, void*);
  51. int jack_set_freewheel_callback(jack_client_t*, JackFreewheelCallback, void*);
  52. int jack_set_buffer_size_callback(jack_client_t*, JackBufferSizeCallback, void*);
  53. int jack_set_sample_rate_callback(jack_client_t*, JackSampleRateCallback, void*);
  54. int jack_set_client_registration_callback(jack_client_t*, JackClientRegistrationCallback, void*);
  55. int jack_set_port_registration_callback(jack_client_t*, JackPortRegistrationCallback, void*);
  56. int jack_set_port_connect_callback(jack_client_t*, JackPortConnectCallback, void*);
  57. int jack_set_port_rename_callback(jack_client_t*, JackPortRenameCallback, void*);
  58. int jack_set_graph_order_callback(jack_client_t*, JackGraphOrderCallback, void*);
  59. int jack_set_xrun_callback(jack_client_t*, JackXRunCallback, void*);
  60. int jack_set_latency_callback(jack_client_t*, JackLatencyCallback, void*);
  61. int jack_set_freewheel(jack_client_t*, int);
  62. int jack_set_buffer_size(jack_client_t*, jack_nframes_t);
  63. jack_nframes_t jack_get_sample_rate(jack_client_t*);
  64. jack_nframes_t jack_get_buffer_size(jack_client_t*);
  65. int jack_engine_takeover_timebase(jack_client_t*);
  66. float jack_cpu_load(jack_client_t*);
  67. jack_port_t* jack_port_register(jack_client_t*, const char*, const char*, unsigned long, unsigned long);
  68. int jack_port_unregister(jack_client_t*, jack_port_t*);
  69. void* jack_port_get_buffer(jack_port_t*, jack_nframes_t);
  70. jack_uuid_t jack_port_uuid(const jack_port_t*);
  71. const char* jack_port_name(const jack_port_t*);
  72. const char* jack_port_short_name(const jack_port_t*);
  73. int jack_port_flags(const jack_port_t*);
  74. const char* jack_port_type(const jack_port_t*);
  75. jack_port_type_id_t jack_port_type_id(const jack_port_t*);
  76. int jack_port_is_mine(const jack_client_t*, const jack_port_t*);
  77. int jack_port_connected(const jack_port_t*);
  78. int jack_port_connected_to(const jack_port_t*, const char*);
  79. const char** jack_port_get_connections(const jack_port_t*);
  80. const char** jack_port_get_all_connections(const jack_client_t*, const jack_port_t*);
  81. int jack_port_tie(jack_port_t*, jack_port_t*);
  82. int jack_port_untie(jack_port_t*);
  83. int jack_port_set_name(jack_port_t*, const char*);
  84. int jack_port_rename(jack_client_t*, jack_port_t*, const char*);
  85. int jack_port_set_alias(jack_port_t*, const char*);
  86. int jack_port_unset_alias(jack_port_t*, const char*);
  87. int jack_port_get_aliases(const jack_port_t*, char* const aliases[2]);
  88. int jack_port_request_monitor(jack_port_t*, int);
  89. int jack_port_request_monitor_by_name(jack_client_t*, const char*, int);
  90. int jack_port_ensure_monitor(jack_port_t*, int);
  91. int jack_port_monitoring_input(jack_port_t*);
  92. int jack_connect(jack_client_t*, const char*, const char*);
  93. int jack_disconnect(jack_client_t*, const char*, const char*);
  94. int jack_port_disconnect(jack_client_t*, jack_port_t*);
  95. int jack_port_name_size(void);
  96. int jack_port_type_size(void);
  97. size_t jack_port_type_get_buffer_size(jack_client_t*, const char*);
  98. void jack_port_set_latency(jack_port_t*, jack_nframes_t);
  99. void jack_port_get_latency_range(jack_port_t*, jack_latency_callback_mode_t, jack_latency_range_t*);
  100. void jack_port_set_latency_range(jack_port_t*, jack_latency_callback_mode_t, jack_latency_range_t*);
  101. int jack_recompute_total_latencies(jack_client_t*);
  102. jack_nframes_t jack_port_get_latency(jack_port_t*);
  103. jack_nframes_t jack_port_get_total_latency(jack_client_t*, jack_port_t*);
  104. int jack_recompute_total_latency(jack_client_t*, jack_port_t*);
  105. const char** jack_get_ports(jack_client_t*, const char*, const char*, unsigned long);
  106. jack_port_t* jack_port_by_name(jack_client_t*, const char*);
  107. jack_port_t* jack_port_by_id(jack_client_t*, jack_port_id_t);
  108. jack_nframes_t jack_frames_since_cycle_start(const jack_client_t*);
  109. jack_nframes_t jack_frame_time(const jack_client_t*);
  110. jack_nframes_t jack_last_frame_time(const jack_client_t*);
  111. int jack_get_cycle_times(const jack_client_t*, jack_nframes_t*, jack_time_t*, jack_time_t*, float*);
  112. jack_time_t jack_frames_to_time(const jack_client_t*, jack_nframes_t);
  113. jack_nframes_t jack_time_to_frames(const jack_client_t*, jack_time_t);
  114. jack_time_t jack_get_time(void);
  115. void jack_free(void*);
  116. extern void(*jack_error_callback)(const char*msg);
  117. void jack_set_error_function(void (*func)(const char*));
  118. extern void (*jack_info_callback)(const char*msg);
  119. void jack_set_info_function(void (*func)(const char*));
  120. // --------------------------------------------------------------------------------------------------------------------
  121. // medadata.h
  122. int jack_set_property(jack_client_t*, jack_uuid_t, const char*, const char*, const char*);
  123. int jack_get_property(jack_uuid_t, const char*, char**, char**);
  124. void jack_free_description(jack_description_t*, int);
  125. int jack_get_properties(jack_uuid_t, jack_description_t*);
  126. int jack_get_all_properties(jack_description_t**);
  127. int jack_remove_property(jack_client_t*, jack_uuid_t, const char*);
  128. int jack_remove_properties(jack_client_t*, jack_uuid_t);
  129. int jack_remove_all_properties(jack_client_t*);
  130. int jack_set_property_change_callback(jack_client_t*, JackPropertyChangeCallback, void*);
  131. // extern const char* JACK_METADATA_PRETTY_NAME;
  132. // extern const char* JACK_METADATA_HARDWARE;
  133. // extern const char* JACK_METADATA_CONNECTED;
  134. // extern const char* JACK_METADATA_PORT_GROUP;
  135. // extern const char* JACK_METADATA_ICON_SMALL;
  136. // extern const char* JACK_METADATA_ICON_LARGE;
  137. // --------------------------------------------------------------------------------------------------------------------
  138. // midiport.h
  139. uint32_t jack_midi_get_event_count(void*);
  140. int jack_midi_event_get(jack_midi_event_t*, void*, uint32_t);
  141. void jack_midi_clear_buffer(void*);
  142. void jack_midi_reset_buffer(void*);
  143. size_t jack_midi_max_event_size(void*);
  144. jack_midi_data_t* jack_midi_event_reserve(void*, jack_nframes_t, size_t);
  145. int jack_midi_event_write(void*, jack_nframes_t, const jack_midi_data_t*, size_t);
  146. uint32_t jack_midi_get_lost_event_count(void*);
  147. // --------------------------------------------------------------------------------------------------------------------
  148. // thread.h
  149. int jack_client_real_time_priority(jack_client_t*);
  150. int jack_client_max_real_time_priority(jack_client_t*);
  151. int jack_acquire_real_time_scheduling(pthread_t, int );
  152. int jack_client_create_thread(jack_client_t*, pthread_t*, int, int, void*(*start_routine)(void*), void*);
  153. int jack_drop_real_time_scheduling(pthread_t);
  154. int jack_client_stop_thread(jack_client_t*, pthread_t);
  155. int jack_client_kill_thread(jack_client_t*, pthread_t);
  156. typedef int (*jack_thread_creator_t)(pthread_t*, const pthread_attr_t*, void* (*function)(void*), void* arg);
  157. void jack_set_thread_creator(jack_thread_creator_t);
  158. // --------------------------------------------------------------------------------------------------------------------
  159. // session.h
  160. int jack_set_session_callback(jack_client_t*, JackSessionCallback, void*);
  161. int jack_session_reply(jack_client_t*, jack_session_event_t*);
  162. void jack_session_event_free(jack_session_event_t*);
  163. char* jack_client_get_uuid(jack_client_t*);
  164. jack_session_command_t* jack_session_notify( jack_client_t*, const char*, jack_session_event_type_t, const char*);
  165. void jack_session_commands_free(jack_session_command_t*);
  166. int jack_reserve_client_name(jack_client_t*, const char*, const char*);
  167. int jack_client_has_session_callback(jack_client_t*, const char*);
  168. // --------------------------------------------------------------------------------------------------------------------
  169. // statistics.h
  170. float jack_get_max_delayed_usecs(jack_client_t*);
  171. float jack_get_xrun_delayed_usecs(jack_client_t*);
  172. void jack_reset_max_delayed_usecs(jack_client_t*);
  173. // --------------------------------------------------------------------------------------------------------------------
  174. // transport.h
  175. int jack_release_timebase(jack_client_t*);
  176. int jack_set_sync_callback(jack_client_t*, JackSyncCallback, void*);
  177. int jack_set_sync_timeout(jack_client_t*, jack_time_t);
  178. int jack_set_timebase_callback(jack_client_t*, int, JackTimebaseCallback, void*);
  179. int jack_transport_locate(jack_client_t*, jack_nframes_t);
  180. jack_transport_state_t jack_transport_query(const jack_client_t*, jack_position_t*);
  181. jack_nframes_t jack_get_current_transport_frame(const jack_client_t*);
  182. int jack_transport_reposition(jack_client_t*, const jack_position_t*);
  183. void jack_transport_start(jack_client_t*);
  184. void jack_transport_stop(jack_client_t*);
  185. void jack_get_transport_info(jack_client_t*, void*);
  186. void jack_set_transport_info(jack_client_t*, void*);
  187. // --------------------------------------------------------------------------------------------------------------------
  188. // uuid.h
  189. #define JACK_UUID_SIZE 36
  190. #define JACK_UUID_STRING_SIZE (JACK_UUID_SIZE+1) /* includes trailing null */
  191. // #define JACK_UUID_EMPTY_INITIALIZER 0
  192. jack_uuid_t jack_client_uuid_generate();
  193. jack_uuid_t jack_port_uuid_generate(uint32_t port_id);
  194. uint32_t jack_uuid_to_index(jack_uuid_t);
  195. int jack_uuid_compare(jack_uuid_t, jack_uuid_t);
  196. void jack_uuid_copy(jack_uuid_t* dst, jack_uuid_t src);
  197. void jack_uuid_clear(jack_uuid_t*);
  198. int jack_uuid_parse(const char*buf, jack_uuid_t*);
  199. void jack_uuid_unparse(jack_uuid_t, char buf[JACK_UUID_STRING_SIZE]);
  200. int jack_uuid_empty(jack_uuid_t);
  201. // --------------------------------------------------------------------------------------------------------------------
  202. }
  203. #endif