Audio plugin host https://kx.studio/carla
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.

ivstmidilearn.h 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //------------------------------------------------------------------------
  2. // Project : VST SDK
  3. //
  4. // Category : Interfaces
  5. // Filename : pluginterfaces/vst/ivstmidilearn.h
  6. // Created by : Steinberg, 11/2018
  7. // Description : VST MIDI Learn
  8. //
  9. //-----------------------------------------------------------------------------
  10. // This file is part of a Steinberg SDK. It is subject to the license terms
  11. // in the LICENSE file found in the top-level directory of this distribution
  12. // and at www.steinberg.net/sdklicenses.
  13. // No part of the SDK, including this file, may be copied, modified, propagated,
  14. // or distributed except according to the terms contained in the LICENSE file.
  15. //-----------------------------------------------------------------------------
  16. #pragma once
  17. #include "pluginterfaces/base/funknown.h"
  18. #include "pluginterfaces/vst/vsttypes.h"
  19. //------------------------------------------------------------------------
  20. namespace Steinberg {
  21. namespace Vst {
  22. //------------------------------------------------------------------------
  23. /** MIDI Learn interface: Vst::IMidiLearn
  24. \ingroup vstIPlug vst3612
  25. - [plug imp]
  26. - [extends IEditController]
  27. - [released: 3.6.12]
  28. - [optional]
  29. If this interface is implemented by the edit controller, the host will call this method whenever
  30. there is live MIDI-CC input for the plug-in. This way, the plug-in can change its MIDI-CC parameter
  31. mapping and inform the host via the IComponentHandler::restartComponent with the
  32. kMidiCCAssignmentChanged flag.
  33. Use this if you want to implement custom MIDI-Learn functionality in your plug-in.
  34. \code{.cpp}
  35. //------------------------------------------------
  36. // in MyController class declaration
  37. class MyController : public Vst::EditController, public Vst::IMidiLearn
  38. {
  39. // ...
  40. //--- IMidiLearn ---------------------------------
  41. tresult PLUGIN_API onLiveMIDIControllerInput (int32 busIndex, int16 channel,
  42. CtrlNumber midiCC) SMTG_OVERRIDE;
  43. // ...
  44. OBJ_METHODS (MyController, Vst::EditController)
  45. DEFINE_INTERFACES
  46. // ...
  47. DEF_INTERFACE (Vst::IMidiLearn)
  48. END_DEFINE_INTERFACES (Vst::EditController)
  49. //...
  50. }
  51. //------------------------------------------------
  52. // in mycontroller.cpp
  53. #include "pluginterfaces/vst/ivstmidilearn.h
  54. namespace Steinberg {
  55. namespace Vst {
  56. DEF_CLASS_IID (IMidiLearn)
  57. }
  58. }
  59. //------------------------------------------------------------------------
  60. tresult PLUGIN_API MyController::onLiveMIDIControllerInput (int32 busIndex,
  61. int16 channel, CtrlNumber midiCC)
  62. {
  63. // if we are not in doMIDILearn (triggered by a UI button for example)
  64. // or wrong channel then return
  65. if (!doMIDILearn || busIndex != 0 || channel != 0 || midiLearnParamID == InvalidParamID)
  66. return kResultFalse;
  67. // adapt our internal MIDICC -> parameterID mapping
  68. midiCCMapping[midiCC] = midiLearnParamID;
  69. // new mapping then inform the host that our MIDI assignment has changed
  70. if (auto componentHandler = getComponentHandler ())
  71. {
  72. componentHandler->restartComponent (kMidiCCAssignmentChanged);
  73. }
  74. return kResultTrue;
  75. }
  76. \endcode
  77. */
  78. class IMidiLearn : public FUnknown
  79. {
  80. public:
  81. /** Called on live input MIDI-CC change associated to a given bus index and MIDI channel */
  82. virtual tresult PLUGIN_API onLiveMIDIControllerInput (int32 busIndex, int16 channel,
  83. CtrlNumber midiCC) = 0;
  84. //------------------------------------------------------------------------
  85. static const FUID iid;
  86. };
  87. DECLARE_CLASS_IID (IMidiLearn, 0x6B2449CC, 0x419740B5, 0xAB3C79DA, 0xC5FE5C86)
  88. //------------------------------------------------------------------------
  89. } // namespace Vst
  90. } // namespace Steinberg