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.

234 lines
13KB

  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. CARLA_API void jack_get_version(int*, int*, int*, int*);
  28. CARLA_API const char* jack_get_version_string(void);
  29. CARLA_API jack_client_t* jack_client_open(const char*, jack_options_t, jack_status_t*, ...);
  30. CARLA_API jack_client_t* jack_client_new(const char*);
  31. CARLA_API int jack_client_close(jack_client_t*);
  32. CARLA_API int jack_client_name_size(void);
  33. CARLA_API char* jack_get_client_name(jack_client_t*);
  34. CARLA_API char* jack_get_uuid_for_client_name(jack_client_t*, const char*);
  35. CARLA_API char* jack_get_client_name_by_uuid(jack_client_t*, const char*);
  36. CARLA_API int jack_internal_client_new(const char*, const char*, const char*);
  37. CARLA_API void jack_internal_client_close(const char*);
  38. CARLA_API int jack_activate(jack_client_t*);
  39. CARLA_API int jack_deactivate(jack_client_t*);
  40. CARLA_API int jack_get_client_pid(const char*);
  41. CARLA_API pthread_t jack_client_thread_id(jack_client_t*);
  42. CARLA_API int jack_is_realtime(jack_client_t*);
  43. CARLA_API jack_nframes_t jack_thread_wait(jack_client_t*, int);
  44. CARLA_API jack_nframes_t jack_cycle_wait(jack_client_t*);
  45. CARLA_API void jack_cycle_signal(jack_client_t*, int);
  46. CARLA_API int jack_set_process_thread(jack_client_t*, JackThreadCallback, void*);
  47. CARLA_API int jack_set_thread_init_callback(jack_client_t*, JackThreadInitCallback, void*);
  48. CARLA_API void jack_on_shutdown(jack_client_t*, JackShutdownCallback, void*);
  49. CARLA_API void jack_on_info_shutdown(jack_client_t*, JackInfoShutdownCallback, void*);
  50. CARLA_API int jack_set_process_callback(jack_client_t*, JackProcessCallback, void*);
  51. CARLA_API int jack_set_freewheel_callback(jack_client_t*, JackFreewheelCallback, void*);
  52. CARLA_API int jack_set_buffer_size_callback(jack_client_t*, JackBufferSizeCallback, void*);
  53. CARLA_API int jack_set_sample_rate_callback(jack_client_t*, JackSampleRateCallback, void*);
  54. CARLA_API int jack_set_client_registration_callback(jack_client_t*, JackClientRegistrationCallback, void*);
  55. CARLA_API int jack_set_port_registration_callback(jack_client_t*, JackPortRegistrationCallback, void*);
  56. CARLA_API int jack_set_port_connect_callback(jack_client_t*, JackPortConnectCallback, void*);
  57. CARLA_API int jack_set_port_rename_callback(jack_client_t*, JackPortRenameCallback, void*);
  58. CARLA_API int jack_set_graph_order_callback(jack_client_t*, JackGraphOrderCallback, void*);
  59. CARLA_API int jack_set_xrun_callback(jack_client_t*, JackXRunCallback, void*);
  60. CARLA_API int jack_set_latency_callback(jack_client_t*, JackLatencyCallback, void*);
  61. CARLA_API int jack_set_freewheel(jack_client_t*, int);
  62. CARLA_API int jack_set_buffer_size(jack_client_t*, jack_nframes_t);
  63. CARLA_API jack_nframes_t jack_get_sample_rate(jack_client_t*);
  64. CARLA_API jack_nframes_t jack_get_buffer_size(jack_client_t*);
  65. CARLA_API int jack_engine_takeover_timebase(jack_client_t*);
  66. CARLA_API float jack_cpu_load(jack_client_t*);
  67. CARLA_API jack_port_t* jack_port_register(jack_client_t*, const char*, const char*, unsigned long, unsigned long);
  68. CARLA_API int jack_port_unregister(jack_client_t*, jack_port_t*);
  69. CARLA_API void* jack_port_get_buffer(jack_port_t*, jack_nframes_t);
  70. CARLA_API jack_uuid_t jack_port_uuid(const jack_port_t*);
  71. CARLA_API const char* jack_port_name(const jack_port_t*);
  72. CARLA_API const char* jack_port_short_name(const jack_port_t*);
  73. CARLA_API int jack_port_flags(const jack_port_t*);
  74. CARLA_API const char* jack_port_type(const jack_port_t*);
  75. CARLA_API jack_port_type_id_t jack_port_type_id(const jack_port_t*);
  76. CARLA_API int jack_port_is_mine(const jack_client_t*, const jack_port_t*);
  77. CARLA_API int jack_port_connected(const jack_port_t*);
  78. CARLA_API int jack_port_connected_to(const jack_port_t*, const char*);
  79. CARLA_API const char** jack_port_get_connections(const jack_port_t*);
  80. CARLA_API const char** jack_port_get_all_connections(const jack_client_t*, const jack_port_t*);
  81. CARLA_API int jack_port_tie(jack_port_t*, jack_port_t*);
  82. CARLA_API int jack_port_untie(jack_port_t*);
  83. CARLA_API int jack_port_set_name(jack_port_t*, const char*);
  84. CARLA_API int jack_port_rename(jack_client_t*, jack_port_t*, const char*);
  85. CARLA_API int jack_port_set_alias(jack_port_t*, const char*);
  86. CARLA_API int jack_port_unset_alias(jack_port_t*, const char*);
  87. CARLA_API int jack_port_get_aliases(const jack_port_t*, char* const aliases[2]);
  88. CARLA_API int jack_port_request_monitor(jack_port_t*, int);
  89. CARLA_API int jack_port_request_monitor_by_name(jack_client_t*, const char*, int);
  90. CARLA_API int jack_port_ensure_monitor(jack_port_t*, int);
  91. CARLA_API int jack_port_monitoring_input(jack_port_t*);
  92. CARLA_API int jack_connect(jack_client_t*, const char*, const char*);
  93. CARLA_API int jack_disconnect(jack_client_t*, const char*, const char*);
  94. CARLA_API int jack_port_disconnect(jack_client_t*, jack_port_t*);
  95. CARLA_API int jack_port_name_size(void);
  96. CARLA_API int jack_port_type_size(void);
  97. CARLA_API size_t jack_port_type_get_buffer_size(jack_client_t*, const char*);
  98. CARLA_API void jack_port_set_latency(jack_port_t*, jack_nframes_t);
  99. CARLA_API void jack_port_get_latency_range(jack_port_t*, jack_latency_callback_mode_t, jack_latency_range_t*);
  100. CARLA_API void jack_port_set_latency_range(jack_port_t*, jack_latency_callback_mode_t, jack_latency_range_t*);
  101. CARLA_API int jack_recompute_total_latencies(jack_client_t*);
  102. CARLA_API jack_nframes_t jack_port_get_latency(jack_port_t*);
  103. CARLA_API jack_nframes_t jack_port_get_total_latency(jack_client_t*, jack_port_t*);
  104. CARLA_API int jack_recompute_total_latency(jack_client_t*, jack_port_t*);
  105. CARLA_API const char** jack_get_ports(jack_client_t*, const char*, const char*, unsigned long);
  106. CARLA_API jack_port_t* jack_port_by_name(jack_client_t*, const char*);
  107. CARLA_API jack_port_t* jack_port_by_id(jack_client_t*, jack_port_id_t);
  108. CARLA_API jack_nframes_t jack_frames_since_cycle_start(const jack_client_t*);
  109. CARLA_API jack_nframes_t jack_frame_time(const jack_client_t*);
  110. CARLA_API jack_nframes_t jack_last_frame_time(const jack_client_t*);
  111. CARLA_API int jack_get_cycle_times(const jack_client_t*, jack_nframes_t*, jack_time_t*, jack_time_t*, float*);
  112. CARLA_API jack_time_t jack_frames_to_time(const jack_client_t*, jack_nframes_t);
  113. CARLA_API jack_nframes_t jack_time_to_frames(const jack_client_t*, jack_time_t);
  114. CARLA_API jack_time_t jack_get_time(void);
  115. CARLA_API void jack_free(void*);
  116. CARLA_API extern void(*jack_error_callback)(const char*msg);
  117. CARLA_API void jack_set_error_function(void (*func)(const char*));
  118. CARLA_API extern void (*jack_info_callback)(const char*msg);
  119. CARLA_API void jack_set_info_function(void (*func)(const char*));
  120. // --------------------------------------------------------------------------------------------------------------------
  121. // medadata.h
  122. CARLA_API int jack_set_property(jack_client_t*, jack_uuid_t, const char*, const char*, const char*);
  123. CARLA_API int jack_get_property(jack_uuid_t, const char*, char**, char**);
  124. CARLA_API void jack_free_description(jack_description_t*, int);
  125. CARLA_API int jack_get_properties(jack_uuid_t, jack_description_t*);
  126. CARLA_API int jack_get_all_properties(jack_description_t**);
  127. CARLA_API int jack_remove_property(jack_client_t*, jack_uuid_t, const char*);
  128. CARLA_API int jack_remove_properties(jack_client_t*, jack_uuid_t);
  129. CARLA_API int jack_remove_all_properties(jack_client_t*);
  130. CARLA_API 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. CARLA_API uint32_t jack_midi_get_event_count(void*);
  140. CARLA_API int jack_midi_event_get(jack_midi_event_t*, void*, uint32_t);
  141. CARLA_API void jack_midi_clear_buffer(void*);
  142. CARLA_API void jack_midi_reset_buffer(void*);
  143. CARLA_API size_t jack_midi_max_event_size(void*);
  144. CARLA_API jack_midi_data_t* jack_midi_event_reserve(void*, jack_nframes_t, size_t);
  145. CARLA_API int jack_midi_event_write(void*, jack_nframes_t, const jack_midi_data_t*, size_t);
  146. CARLA_API uint32_t jack_midi_get_lost_event_count(void*);
  147. // --------------------------------------------------------------------------------------------------------------------
  148. // thread.h
  149. CARLA_API int jack_client_real_time_priority(jack_client_t*);
  150. CARLA_API int jack_client_max_real_time_priority(jack_client_t*);
  151. CARLA_API int jack_acquire_real_time_scheduling(pthread_t, int );
  152. CARLA_API int jack_client_create_thread(jack_client_t*, pthread_t*, int, int, void*(*start_routine)(void*), void*);
  153. CARLA_API int jack_drop_real_time_scheduling(pthread_t);
  154. CARLA_API int jack_client_stop_thread(jack_client_t*, pthread_t);
  155. CARLA_API 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. CARLA_API void jack_set_thread_creator(jack_thread_creator_t);
  158. // --------------------------------------------------------------------------------------------------------------------
  159. // session.h
  160. CARLA_API int jack_set_session_callback(jack_client_t*, JackSessionCallback, void*);
  161. CARLA_API int jack_session_reply(jack_client_t*, jack_session_event_t*);
  162. CARLA_API void jack_session_event_free(jack_session_event_t*);
  163. CARLA_API char* jack_client_get_uuid(jack_client_t*);
  164. CARLA_API jack_session_command_t* jack_session_notify( jack_client_t*, const char*, jack_session_event_type_t, const char*);
  165. CARLA_API void jack_session_commands_free(jack_session_command_t*);
  166. CARLA_API int jack_reserve_client_name(jack_client_t*, const char*, const char*);
  167. CARLA_API int jack_client_has_session_callback(jack_client_t*, const char*);
  168. // --------------------------------------------------------------------------------------------------------------------
  169. // statistics.h
  170. CARLA_API float jack_get_max_delayed_usecs(jack_client_t*);
  171. CARLA_API float jack_get_xrun_delayed_usecs(jack_client_t*);
  172. CARLA_API void jack_reset_max_delayed_usecs(jack_client_t*);
  173. // --------------------------------------------------------------------------------------------------------------------
  174. // transport.h
  175. CARLA_API int jack_release_timebase(jack_client_t*);
  176. CARLA_API int jack_set_sync_callback(jack_client_t*, JackSyncCallback, void*);
  177. CARLA_API int jack_set_sync_timeout(jack_client_t*, jack_time_t);
  178. CARLA_API int jack_set_timebase_callback(jack_client_t*, int, JackTimebaseCallback, void*);
  179. CARLA_API int jack_transport_locate(jack_client_t*, jack_nframes_t);
  180. CARLA_API jack_transport_state_t jack_transport_query(const jack_client_t*, jack_position_t*);
  181. CARLA_API jack_nframes_t jack_get_current_transport_frame(const jack_client_t*);
  182. CARLA_API int jack_transport_reposition(jack_client_t*, const jack_position_t*);
  183. CARLA_API void jack_transport_start(jack_client_t*);
  184. CARLA_API void jack_transport_stop(jack_client_t*);
  185. CARLA_API void jack_get_transport_info(jack_client_t*, void*);
  186. CARLA_API 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. CARLA_API jack_uuid_t jack_client_uuid_generate(void);
  193. CARLA_API jack_uuid_t jack_port_uuid_generate(uint32_t port_id);
  194. CARLA_API uint32_t jack_uuid_to_index(jack_uuid_t);
  195. CARLA_API int jack_uuid_compare(jack_uuid_t, jack_uuid_t);
  196. CARLA_API void jack_uuid_copy(jack_uuid_t* dst, jack_uuid_t src);
  197. CARLA_API void jack_uuid_clear(jack_uuid_t*);
  198. CARLA_API int jack_uuid_parse(const char*buf, jack_uuid_t*);
  199. CARLA_API void jack_uuid_unparse(jack_uuid_t, char buf[JACK_UUID_STRING_SIZE]);
  200. CARLA_API int jack_uuid_empty(jack_uuid_t);
  201. // --------------------------------------------------------------------------------------------------------------------
  202. }
  203. #endif