1 //------------------------------------------------------------------------
4 // Category : Interfaces
5 // Filename : pluginterfaces/vst/ivstmidilearn.h
6 // Created by : Steinberg, 11/2018
7 // Description : VST MIDI Learn
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 //-----------------------------------------------------------------------------
19 #include "pluginterfaces/base/funknown.h"
20 #include "pluginterfaces/vst/vsttypes.h"
22 //------------------------------------------------------------------------
26 //------------------------------------------------------------------------
27 /** MIDI Learn interface: Vst::IMidiLearn
28 \ingroup vstIPlug vst3612
30 - [extends IEditController]
34 If this interface is implemented by the edit controller, the host will call this method whenever
35 there is live MIDI-CC input for the plug-in. This way, the plug-in can change its MIDI-CC parameter
36 mapping and inform the host via the IComponentHandler::restartComponent with the
37 kMidiCCAssignmentChanged flag.
38 Use this if you want to implement custom MIDI-Learn functionality in your plug-in.
41 //------------------------------------------------
42 // in MyController class declaration
43 class MyController : public Vst::EditController, public Vst::IMidiLearn
46 //--- IMidiLearn ---------------------------------
47 tresult PLUGIN_API onLiveMIDIControllerInput (int32 busIndex, int16 channel,
48 CtrlNumber midiCC) SMTG_OVERRIDE;
51 OBJ_METHODS (MyController, Vst::EditController)
54 DEF_INTERFACE (Vst::IMidiLearn)
55 END_DEFINE_INTERFACES (Vst::EditController)
59 //------------------------------------------------
60 // in mycontroller.cpp
61 #include "pluginterfaces/vst/ivstmidilearn.h
65 DEF_CLASS_IID (IMidiLearn)
69 //------------------------------------------------------------------------
70 tresult PLUGIN_API MyController::onLiveMIDIControllerInput (int32 busIndex,
71 int16 channel, CtrlNumber midiCC)
73 // if we are not in doMIDILearn (triggered by a UI button for example)
74 // or wrong channel then return
75 if (!doMIDILearn || busIndex != 0 || channel != 0 || midiLearnParamID == InvalidParamID)
78 // adapt our internal MIDICC -> parameterID mapping
79 midiCCMapping[midiCC] = midiLearnParamID;
81 // new mapping then inform the host that our MIDI assignment has changed
82 if (auto componentHandler = getComponentHandler ())
84 componentHandler->restartComponent (kMidiCCAssignmentChanged);
90 class IMidiLearn
: public FUnknown
93 /** Called on live input MIDI-CC change associated to a given bus index and MIDI channel */
94 virtual tresult PLUGIN_API
onLiveMIDIControllerInput (int32 busIndex
, int16 channel
,
95 CtrlNumber midiCC
) = 0;
97 //------------------------------------------------------------------------
98 static const FUID iid
;
101 DECLARE_CLASS_IID (IMidiLearn
, 0x6B2449CC, 0x419740B5, 0xAB3C79DA, 0xC5FE5C86)
104 //------------------------------------------------------------------------
106 } // namespace Steinberg