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.

154 lines
6.9KB

  1. /*
  2. * Carla Engine OSC
  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_ENGINE_OSC_HPP
  18. #define CARLA_ENGINE_OSC_HPP
  19. #ifdef BUILD_BRIDGE
  20. # error Bad use of file! This should never be used in bridge builds
  21. #endif
  22. #include "carla_backend.hpp"
  23. #include "carla_osc_utils.hpp"
  24. #define CARLA_ENGINE_OSC_HANDLE_ARGS1 CarlaPlugin* const plugin
  25. #define CARLA_ENGINE_OSC_HANDLE_ARGS2 CarlaPlugin* const plugin, const int argc, const lo_arg* const* const argv, const char* const types
  26. #define CARLA_ENGINE_OSC_CHECK_OSC_TYPES(/* argc, types, */ argcToCompare, typesToCompare) \
  27. /* check argument count */ \
  28. if (argc != argcToCompare) \
  29. { \
  30. qCritical("CarlaEngineOsc::%s() - argument count mismatch: %i != %i", __FUNCTION__, argc, argcToCompare); \
  31. return 1; \
  32. } \
  33. if (argc > 0) \
  34. { \
  35. /* check for nullness */ \
  36. if (! (types && typesToCompare)) \
  37. { \
  38. qCritical("CarlaEngineOsc::%s() - argument types are null", __FUNCTION__); \
  39. return 1; \
  40. } \
  41. /* check argument types */ \
  42. if (strcmp(types, typesToCompare) != 0) \
  43. { \
  44. qCritical("CarlaEngineOsc::%s() - argument types mismatch: '%s' != '%s'", __FUNCTION__, types, typesToCompare); \
  45. return 1; \
  46. } \
  47. }
  48. CARLA_BACKEND_START_NAMESPACE
  49. #if 0
  50. } // Fix editor indentation
  51. #endif
  52. class CarlaEngineOsc
  53. {
  54. public:
  55. CarlaEngineOsc(CarlaEngine* const engine);
  56. ~CarlaEngineOsc();
  57. void init(const char* const name);
  58. bool idle();
  59. void close();
  60. // -------------------------------------------------------------------
  61. bool isControlRegistered() const
  62. {
  63. return bool(m_controlData.target);
  64. }
  65. const CarlaOscData* getControlData() const
  66. {
  67. return &m_controlData;
  68. }
  69. const char* getServerPathTCP() const
  70. {
  71. return (const char*)m_serverPathTCP;
  72. }
  73. const char* getServerPathUDP() const
  74. {
  75. return (const char*)m_serverPathUDP;
  76. }
  77. // -------------------------------------------------------------------
  78. private:
  79. CarlaEngine* const engine;
  80. lo_server m_serverTCP;
  81. lo_server m_serverUDP;
  82. CarlaString m_serverPathTCP;
  83. CarlaString m_serverPathUDP;
  84. CarlaOscData m_controlData; // for carla-control
  85. char* m_name;
  86. size_t m_nameSize;
  87. // -------------------------------------------------------------------
  88. int handleMessage(const char* const path, const int argc, const lo_arg* const* const argv, const char* const types, const lo_message msg);
  89. int handleMsgRegister(const int argc, const lo_arg* const* const argv, const char* const types, const lo_address source);
  90. int handleMsgUnregister();
  91. int handleMsgUpdate(CARLA_ENGINE_OSC_HANDLE_ARGS2, const lo_address source);
  92. int handleMsgConfigure(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  93. int handleMsgControl(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  94. int handleMsgProgram(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  95. int handleMsgMidi(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  96. int handleMsgExiting(CARLA_ENGINE_OSC_HANDLE_ARGS1);
  97. int handleMsgSetActive(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  98. int handleMsgSetDryWet(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  99. int handleMsgSetVolume(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  100. int handleMsgSetBalanceLeft(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  101. int handleMsgSetBalanceRight(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  102. int handleMsgSetParameterValue(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  103. int handleMsgSetParameterMidiCC(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  104. int handleMsgSetParameterMidiChannel(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  105. int handleMsgSetProgram(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  106. int handleMsgSetMidiProgram(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  107. int handleMsgNoteOn(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  108. int handleMsgNoteOff(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  109. #ifdef WANT_LV2
  110. int handleMsgLv2AtomTransfer(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  111. int handleMsgLv2EventTransfer(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  112. #endif
  113. int handleMsgBridgeSetInPeak(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  114. int handleMsgBridgeSetOutPeak(CARLA_ENGINE_OSC_HANDLE_ARGS2);
  115. // -------------------------------------------------------------------
  116. 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 userData)
  117. {
  118. CARLA_ASSERT(userData);
  119. CarlaEngineOsc* const _this_ = (CarlaEngineOsc*)userData;
  120. return _this_->handleMessage(path, argc, argv, types, msg);
  121. }
  122. };
  123. CARLA_BACKEND_END_NAMESPACE
  124. #endif // CARLA_ENGINE_OSC_HPP