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.

135 lines
6.4KB

  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_osc_includes.h"
  20. #include "carla_bridge.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. namespace CarlaBridge {
  46. class CarlaBridgeOsc
  47. {
  48. public:
  49. CarlaBridgeOsc(CarlaBridgeClient* const client, const char* const name);
  50. ~CarlaBridgeOsc();
  51. void init(const char* const url);
  52. void close();
  53. const CarlaOscData* getServerData() const
  54. {
  55. return &m_serverData;
  56. }
  57. void sendOscUpdate()
  58. {
  59. osc_send_update(&m_serverData, m_serverPath);
  60. }
  61. private:
  62. CarlaBridgeClient* const client;
  63. const char* m_serverPath;
  64. lo_server_thread m_serverThread;
  65. CarlaOscData m_serverData;
  66. const char* m_name;
  67. size_t m_name_len;
  68. // -------------------------------------------------------------------
  69. static void osc_error_handler(const int num, const char* const msg, const char* const path)
  70. {
  71. qCritical("osc_error_handler(%i, %s, %s)", num, msg, path);
  72. }
  73. 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)
  74. {
  75. CarlaBridgeOsc* const _this_ = (CarlaBridgeOsc*)user_data;
  76. if (! _this_->client)
  77. return 1;
  78. return _this_->handleMessage(path, argc, argv, types, msg);
  79. }
  80. int handleMessage(const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg);
  81. int handle_configure(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  82. int handle_control(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  83. int handle_program(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  84. int handle_midi_program(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  85. int handle_midi(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  86. int handle_show();
  87. int handle_hide();
  88. int handle_quit();
  89. int handle_lv2_atom_transfer(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  90. int handle_lv2_event_transfer(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  91. };
  92. #ifdef BUILD_BRIDGE_PLUGIN
  93. void osc_send_bridge_ains_peak(int index, double value);
  94. void osc_send_bridge_aouts_peak(int index, double value);
  95. void osc_send_bridge_audio_count(int ins, int outs, int total);
  96. void osc_send_bridge_midi_count(int ins, int outs, int total);
  97. void osc_send_bridge_param_count(int ins, int outs, int total);
  98. void osc_send_bridge_program_count(int count);
  99. void osc_send_bridge_midi_program_count(int count);
  100. void osc_send_bridge_plugin_info(int category, int hints, const char* name, const char* label, const char* maker, const char* copyright, long uniqueId);
  101. void osc_send_bridge_param_info(int index, const char* name, const char* unit);
  102. void osc_send_bridge_param_data(int index, int type, int rindex, int hints, int midi_channel, int midi_cc);
  103. void osc_send_bridge_param_ranges(int index, double def, double min, double max, double step, double step_small, double step_large);
  104. void osc_send_bridge_program_info(int index, const char* name);
  105. void osc_send_bridge_midi_program_info(int index, int bank, int program, const char* label);
  106. void osc_send_bridge_custom_data(const char* stype, const char* key, const char* value);
  107. void osc_send_bridge_chunk_data(const char* string_data);
  108. void osc_send_bridge_update();
  109. #endif
  110. CARLA_BRIDGE_END_NAMESPACE
  111. #endif // CARLA_BRIDGE_OSC_H