Collection of tools useful for audio production
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.

156 lines
7.0KB

  1. /*
  2. * Carla bridge code
  3. * Copyright (C) 2012 Filipe Coelho <falktx@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * 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 COPYING file
  16. */
  17. #ifndef CARLA_BRIDGE_OSC_H
  18. #define CARLA_BRIDGE_OSC_H
  19. #include "carla_bridge.h"
  20. #include "carla_osc_includes.h"
  21. #define CARLA_BRIDGE_OSC_HANDLE_ARGS const int argc, const lo_arg* const* const argv, const char* const types
  22. #define CARLA_BRIDGE_OSC_CHECK_OSC_TYPES(/* argc, types, */ argcToCompare, typesToCompare) \
  23. /* check argument count */ \
  24. if (argc != argcToCompare) \
  25. { \
  26. qCritical("CarlaBridgeOsc::%s() - argument count mismatch: %i != %i", __FUNCTION__, argc, argcToCompare); \
  27. return 1; \
  28. } \
  29. if (argc > 0) \
  30. { \
  31. /* check for nullness */ \
  32. if (! (types && typesToCompare)) \
  33. { \
  34. qCritical("CarlaBridgeOsc::%s() - argument types are null", __FUNCTION__); \
  35. return 1; \
  36. } \
  37. /* check argument types */ \
  38. if (strcmp(types, typesToCompare) != 0) \
  39. { \
  40. qCritical("CarlaBridgeOsc::%s() - argument types mismatch: '%s' != '%s'", __FUNCTION__, types, typesToCompare); \
  41. return 1; \
  42. } \
  43. }
  44. CARLA_BRIDGE_START_NAMESPACE
  45. class CarlaBridgeOsc
  46. {
  47. public:
  48. CarlaBridgeOsc(CarlaBridgeClient* const client, const char* const name);
  49. ~CarlaBridgeOsc();
  50. bool init(const char* const url);
  51. void close();
  52. const CarlaOscData* getControllerData() const
  53. {
  54. return &m_controlData;
  55. }
  56. void sendOscConfigure(const char* const key, const char* const value)
  57. {
  58. osc_send_configure(&m_controlData, key, value);
  59. }
  60. void sendOscControl(int32_t index, float value)
  61. {
  62. osc_send_control(&m_controlData, index, value);
  63. }
  64. void sendOscUpdate()
  65. {
  66. osc_send_update(&m_controlData, m_serverPath);
  67. }
  68. void sendOscExiting()
  69. {
  70. osc_send_exiting(&m_controlData);
  71. }
  72. void sendOscLv2TransferAtom(const char* const type, const char* const value)
  73. {
  74. osc_send_lv2_transfer_atom(&m_controlData, type, value);
  75. }
  76. void sendOscLv2TransferEvent(const char* const type, const char* const value)
  77. {
  78. osc_send_lv2_transfer_event(&m_controlData, type, value);
  79. }
  80. private:
  81. CarlaBridgeClient* const client;
  82. const char* m_serverPath;
  83. lo_server_thread m_serverThread;
  84. CarlaOscData m_controlData;
  85. char* m_name;
  86. size_t m_nameSize;
  87. // -------------------------------------------------------------------
  88. static int osc_message_handler(const char* const path, const char* const types, lo_arg** const argv, const int argc, const lo_message msg, void* const user_data)
  89. {
  90. CarlaBridgeOsc* const _this_ = (CarlaBridgeOsc*)user_data;
  91. if (! _this_->client)
  92. return 1;
  93. return _this_->handleMessage(path, argc, argv, types, msg);
  94. }
  95. int handleMessage(const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg);
  96. int handle_configure(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  97. int handle_control(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  98. int handle_program(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  99. int handle_midi_program(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  100. int handle_midi(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  101. int handle_show();
  102. int handle_hide();
  103. int handle_quit();
  104. #ifdef BRIDGE_LV2
  105. int handle_lv2_transfer_atom(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  106. int handle_lv2_transfer_event(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  107. #endif
  108. };
  109. #ifdef BUILD_BRIDGE_PLUGIN
  110. void osc_send_bridge_ains_peak(int index, double value);
  111. void osc_send_bridge_aouts_peak(int index, double value);
  112. void osc_send_bridge_audio_count(int ins, int outs, int total);
  113. void osc_send_bridge_midi_count(int ins, int outs, int total);
  114. void osc_send_bridge_param_count(int ins, int outs, int total);
  115. void osc_send_bridge_program_count(int count);
  116. void osc_send_bridge_midi_program_count(int count);
  117. void osc_send_bridge_plugin_info(int category, int hints, const char* name, const char* label, const char* maker, const char* copyright, long uniqueId);
  118. void osc_send_bridge_param_info(int index, const char* name, const char* unit);
  119. void osc_send_bridge_param_data(int index, int type, int rindex, int hints, int midi_channel, int midi_cc);
  120. void osc_send_bridge_param_ranges(int index, double def, double min, double max, double step, double step_small, double step_large);
  121. void osc_send_bridge_program_info(int index, const char* name);
  122. void osc_send_bridge_midi_program_info(int index, int bank, int program, const char* label);
  123. void osc_send_bridge_custom_data(const char* stype, const char* key, const char* value);
  124. void osc_send_bridge_chunk_data(const char* string_data);
  125. void osc_send_bridge_update();
  126. #endif
  127. CARLA_BRIDGE_END_NAMESPACE
  128. #endif // CARLA_BRIDGE_OSC_H