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.

151 lines
6.9KB

  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 sendOscLv2EventTransfer(const char* const type, const char* const key, const char* const value)
  73. {
  74. osc_send_lv2_event_transfer(&m_controlData, type, key, value);
  75. }
  76. private:
  77. CarlaBridgeClient* const client;
  78. const char* m_serverPath;
  79. lo_server_thread m_serverThread;
  80. CarlaOscData m_controlData;
  81. char* m_name;
  82. size_t m_nameSize;
  83. // -------------------------------------------------------------------
  84. 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)
  85. {
  86. CarlaBridgeOsc* const _this_ = (CarlaBridgeOsc*)user_data;
  87. if (! _this_->client)
  88. return 1;
  89. return _this_->handleMessage(path, argc, argv, types, msg);
  90. }
  91. int handleMessage(const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg);
  92. int handle_configure(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  93. int handle_control(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  94. int handle_program(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  95. int handle_midi_program(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  96. int handle_midi(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  97. int handle_show();
  98. int handle_hide();
  99. int handle_quit();
  100. #ifdef BRIDGE_LV2
  101. int handle_lv2_atom_transfer(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  102. int handle_lv2_event_transfer(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  103. #endif
  104. };
  105. #ifdef BUILD_BRIDGE_PLUGIN
  106. void osc_send_bridge_ains_peak(int index, double value);
  107. void osc_send_bridge_aouts_peak(int index, double value);
  108. void osc_send_bridge_audio_count(int ins, int outs, int total);
  109. void osc_send_bridge_midi_count(int ins, int outs, int total);
  110. void osc_send_bridge_param_count(int ins, int outs, int total);
  111. void osc_send_bridge_program_count(int count);
  112. void osc_send_bridge_midi_program_count(int count);
  113. void osc_send_bridge_plugin_info(int category, int hints, const char* name, const char* label, const char* maker, const char* copyright, long uniqueId);
  114. void osc_send_bridge_param_info(int index, const char* name, const char* unit);
  115. void osc_send_bridge_param_data(int index, int type, int rindex, int hints, int midi_channel, int midi_cc);
  116. void osc_send_bridge_param_ranges(int index, double def, double min, double max, double step, double step_small, double step_large);
  117. void osc_send_bridge_program_info(int index, const char* name);
  118. void osc_send_bridge_midi_program_info(int index, int bank, int program, const char* label);
  119. void osc_send_bridge_custom_data(const char* stype, const char* key, const char* value);
  120. void osc_send_bridge_chunk_data(const char* string_data);
  121. void osc_send_bridge_update();
  122. #endif
  123. CARLA_BRIDGE_END_NAMESPACE
  124. #endif // CARLA_BRIDGE_OSC_H