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.

114 lines
5.2KB

  1. /*
  2. * Carla bridge code
  3. * Copyright (C) 2012 Filipe Coelho <falktx@falktx.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.hpp"
  20. #include "carla_osc_utils.hpp"
  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. /*!
  46. * @defgroup CarlaBridgeOSC Carla Bridge OSC
  47. *
  48. * The Carla Bridge OSC.
  49. * @{
  50. */
  51. class CarlaBridgeOsc
  52. {
  53. public:
  54. CarlaBridgeOsc(CarlaClient* const client, const char* const name);
  55. ~CarlaBridgeOsc();
  56. bool init(const char* const url);
  57. void close();
  58. // -------------------------------------------------------------------
  59. protected:
  60. int handleMessage(const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg);
  61. int handleMsgConfigure(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  62. int handleMsgControl(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  63. int handleMsgProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  64. int handleMsgMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  65. int handleMsgMidi(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  66. int handleMsgShow();
  67. int handleMsgHide();
  68. int handleMsgQuit();
  69. #ifdef BRIDGE_LV2
  70. int handleMsgLv2TransferAtom(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  71. int handleMsgLv2TransferEvent(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  72. #endif
  73. // -------------------------------------------------------------------
  74. private:
  75. CarlaClient* const client;
  76. lo_server m_server;
  77. const char* m_serverPath;
  78. CarlaOscData m_controlData;
  79. char* m_name;
  80. size_t m_nameSize;
  81. // -------------------------------------------------------------------
  82. 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)
  83. {
  84. CARLA_ASSERT(user_data);
  85. CarlaBridgeOsc* const _this_ = (CarlaBridgeOsc*)user_data;
  86. return _this_->handleMessage(path, argc, argv, types, msg);
  87. }
  88. friend class CarlaClient;
  89. };
  90. /**@}*/
  91. CARLA_BRIDGE_END_NAMESPACE
  92. #endif // CARLA_BRIDGE_OSC_H