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.

116 lines
5.5KB

  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.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. CARLA_ASSERT(m_server); \
  24. CARLA_ASSERT(m_serverPath); \
  25. /* check argument count */ \
  26. if (argc != argcToCompare) \
  27. { \
  28. qCritical("CarlaBridgeOsc::%s() - argument count mismatch: %i != %i", __FUNCTION__, argc, argcToCompare); \
  29. return 1; \
  30. } \
  31. if (argc > 0) \
  32. { \
  33. /* check for nullness */ \
  34. if (! (types && typesToCompare)) \
  35. { \
  36. qCritical("CarlaBridgeOsc::%s() - argument types are null", __FUNCTION__); \
  37. return 1; \
  38. } \
  39. /* check argument types */ \
  40. if (strcmp(types, typesToCompare) != 0) \
  41. { \
  42. qCritical("CarlaBridgeOsc::%s() - argument types mismatch: '%s' != '%s'", __FUNCTION__, types, typesToCompare); \
  43. return 1; \
  44. } \
  45. }
  46. CARLA_BRIDGE_START_NAMESPACE
  47. /*!
  48. * @defgroup CarlaBridgeOSC Carla Bridge OSC
  49. *
  50. * The Carla Bridge OSC.
  51. * @{
  52. */
  53. class CarlaBridgeOsc
  54. {
  55. public:
  56. CarlaBridgeOsc(CarlaClient* const client, const char* const name);
  57. ~CarlaBridgeOsc();
  58. bool init(const char* const url);
  59. void close();
  60. // -------------------------------------------------------------------
  61. protected:
  62. int handleMessage(const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg);
  63. int handleMsgConfigure(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  64. int handleMsgControl(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  65. int handleMsgProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  66. int handleMsgMidiProgram(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  67. int handleMsgMidi(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  68. int handleMsgShow();
  69. int handleMsgHide();
  70. int handleMsgQuit();
  71. #ifdef BRIDGE_LV2
  72. int handleMsgLv2TransferAtom(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  73. int handleMsgLv2TransferEvent(CARLA_BRIDGE_OSC_HANDLE_ARGS);
  74. #endif
  75. // -------------------------------------------------------------------
  76. private:
  77. CarlaClient* const client;
  78. lo_server m_server;
  79. const char* m_serverPath;
  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. CARLA_ASSERT(user_data);
  87. CarlaBridgeOsc* const _this_ = (CarlaBridgeOsc*)user_data;
  88. return _this_->handleMessage(path, argc, argv, types, msg);
  89. }
  90. friend class CarlaClient;
  91. };
  92. /**@}*/
  93. CARLA_BRIDGE_END_NAMESPACE
  94. #endif // CARLA_BRIDGE_OSC_H