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.

126 lines
6.1KB

  1. /*
  2. * JackBridge
  3. * Copyright (C) 2013 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 Lesser General Public
  7. * License as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * For a full copy of the license see the LGPL.txt file
  15. */
  16. #ifndef __JACKBRIDGE_H__
  17. #define __JACKBRIDGE_H__
  18. #if defined(_WIN32) && ! defined(__WINE__)
  19. # include <stdint.h>
  20. # include <windows.h>
  21. # define BRIDGE_EXPORT __declspec (dllexport)
  22. #else
  23. # define BRIDGE_EXPORT __attribute__ ((visibility("default")))
  24. #endif
  25. #ifdef JACKBRIDGE_EXPORT
  26. # define GNU_WIN32 // fix jack threads, always use pthread
  27. # include <sys/time.h>
  28. #endif
  29. #include <jack/jack.h>
  30. #include <jack/midiport.h>
  31. #include <jack/transport.h>
  32. #ifdef JACKBRIDGE_EXPORT
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. BRIDGE_EXPORT jack_client_t* jackbridge_client_open(const char* client_name, jack_options_t options, jack_status_t* status, ...);
  37. BRIDGE_EXPORT int jackbridge_client_close(jack_client_t* client);
  38. BRIDGE_EXPORT int jackbridge_client_name_size();
  39. BRIDGE_EXPORT char* jackbridge_get_client_name(jack_client_t* client);
  40. BRIDGE_EXPORT int jackbridge_port_name_size();
  41. BRIDGE_EXPORT int jackbridge_recompute_total_latencies(jack_client_t* client);
  42. BRIDGE_EXPORT void jackbridge_port_get_latency_range(jack_port_t* port, jack_latency_callback_mode_t mode, jack_latency_range_t* range);
  43. BRIDGE_EXPORT void jackbridge_port_set_latency_range(jack_port_t* port, jack_latency_callback_mode_t mode, jack_latency_range_t* range);
  44. BRIDGE_EXPORT int jackbridge_activate(jack_client_t* client);
  45. BRIDGE_EXPORT int jackbridge_deactivate(jack_client_t* client);
  46. BRIDGE_EXPORT void jackbridge_on_shutdown(jack_client_t* client, JackShutdownCallback shutdown_callback, void* arg);
  47. BRIDGE_EXPORT int jackbridge_set_latency_callback(jack_client_t* client, JackLatencyCallback latency_callback, void* arg);
  48. BRIDGE_EXPORT int jackbridge_set_process_callback(jack_client_t* client, JackProcessCallback process_callback, void* arg);
  49. BRIDGE_EXPORT int jackbridge_set_freewheel_callback(jack_client_t* client, JackFreewheelCallback freewheel_callback, void* arg);
  50. BRIDGE_EXPORT int jackbridge_set_buffer_size_callback(jack_client_t* client, JackBufferSizeCallback bufsize_callback, void* arg);
  51. BRIDGE_EXPORT int jackbridge_set_sample_rate_callback(jack_client_t* client, JackSampleRateCallback srate_callback, void* arg);
  52. BRIDGE_EXPORT jack_nframes_t jackbridge_get_sample_rate(jack_client_t* client);
  53. BRIDGE_EXPORT jack_nframes_t jackbridge_get_buffer_size(jack_client_t* client);
  54. BRIDGE_EXPORT jack_port_t* jackbridge_port_register(jack_client_t* client, const char* port_name, const char* port_type, unsigned long flags, unsigned long buffer_size);
  55. BRIDGE_EXPORT int jackbridge_port_unregister(jack_client_t* client, jack_port_t* port);
  56. BRIDGE_EXPORT void* jackbridge_port_get_buffer(jack_port_t* port, jack_nframes_t nframes);
  57. BRIDGE_EXPORT uint32_t jackbridge_midi_get_event_count(void* port_buffer);
  58. BRIDGE_EXPORT int jackbridge_midi_event_get(jack_midi_event_t* event, void* port_buffer, uint32_t event_index);
  59. BRIDGE_EXPORT void jackbridge_midi_clear_buffer(void* port_buffer);
  60. BRIDGE_EXPORT jack_midi_data_t* jackbridge_midi_event_reserve(void* port_buffer, jack_nframes_t time, size_t data_size);
  61. BRIDGE_EXPORT int jackbridge_midi_event_write(void* port_buffer, jack_nframes_t time, const jack_midi_data_t* data, size_t data_size);
  62. BRIDGE_EXPORT int jackbridge_transport_locate(jack_client_t* client, jack_nframes_t frame);
  63. BRIDGE_EXPORT jack_transport_state_t jackbridge_transport_query(const jack_client_t* client, jack_position_t* pos);
  64. BRIDGE_EXPORT void jackbridge_transport_start(jack_client_t* client);
  65. BRIDGE_EXPORT void jackbridge_transport_stop(jack_client_t* client);
  66. BRIDGE_EXPORT void linux_clock_gettime_rt(struct timespec*);
  67. BRIDGE_EXPORT int linux_sem_post(void*);
  68. BRIDGE_EXPORT int linux_sem_timedwait(void*, struct timespec*);
  69. #ifdef __cplusplus
  70. }
  71. #endif
  72. #else // JACKBRIDGE_EXPORT
  73. #define jackbridge_client_open jack_client_open
  74. #define jackbridge_client_close jack_client_close
  75. #define jackbridge_client_name_size jack_client_name_size
  76. #define jackbridge_get_client_name jack_get_client_name
  77. #define jackbridge_port_name_size jack_port_name_size
  78. #define jackbridge_recompute_total_latencies jack_recompute_total_latencies
  79. #define jackbridge_port_get_latency_range jack_port_get_latency_range
  80. #define jackbridge_port_set_latency_range jack_port_set_latency_range
  81. #define jackbridge_activate jack_activate
  82. #define jackbridge_deactivate jack_deactivate
  83. #define jackbridge_on_shutdown jack_on_shutdown
  84. #define jackbridge_set_latency_callback jack_set_latency_callback
  85. #define jackbridge_set_process_callback jack_set_process_callback
  86. #define jackbridge_set_freewheel_callback jack_set_freewheel_callback
  87. #define jackbridge_set_buffer_size_callback jack_set_buffer_size_callback
  88. #define jackbridge_set_sample_rate_callback jack_set_sample_rate_callback
  89. #define jackbridge_get_sample_rate jack_get_sample_rate
  90. #define jackbridge_get_buffer_size jack_get_buffer_size
  91. #define jackbridge_port_register jack_port_register
  92. #define jackbridge_port_unregister jack_port_unregister
  93. #define jackbridge_port_get_buffer jack_port_get_buffer
  94. #define jackbridge_midi_get_event_count jack_midi_get_event_count
  95. #define jackbridge_midi_event_get jack_midi_event_get
  96. #define jackbridge_midi_clear_buffer jack_midi_clear_buffer
  97. #define jackbridge_midi_event_reserve jack_midi_event_reserve
  98. #define jackbridge_midi_event_write jack_midi_event_write
  99. #define jackbridge_transport_locate jack_transport_locate
  100. #define jackbridge_transport_query jack_transport_query
  101. #define jackbridge_transport_start jack_transport_start
  102. #define jackbridge_transport_stop jack_transport_stop
  103. #define linux_clock_gettime_rt(ts) clock_gettime(CLOCK_REALTIME, ts)
  104. #define linux_sem_post sem_post
  105. #define linux_sem_timedwait sem_timedwait
  106. #endif // JACKBRIDGE_EXPORT
  107. #endif // __JACKBRIDGE_H__