Class MidiLearnService
- Namespace
- PluginUI
- Assembly
- PluginUI.dll
In-memory IMidiLearnService: feed it the MIDI controllers received by your application with ProcessController(int, int, double); the learning parameter gets assigned, assigned parameters follow the controller.
public sealed class MidiLearnService : IMidiLearnService
- Inheritance
-
MidiLearnService
- Implements
- Inherited Members
Examples
var midiLearn = new MidiLearnService();
host.MidiLearn = midiLearn;
// From your MIDI input (marshal to the UI thread with host.Post):
host.Post(() => midiLearn.ProcessController(channel, controller, value / 127.0));
Properties
Assignments
Current assignments.
public IReadOnlyDictionary<IParameter, (int Channel, int Controller)> Assignments { get; }
Property Value
LearningParameter
Parameter currently learning, or null.
public IParameter? LearningParameter { get; }
Property Value
Methods
Assign(IParameter, int, int)
Assigns a controller to a parameter (replacing other parameters assigned to the same controller).
public void Assign(IParameter parameter, int channel, int controller)
Parameters
parameterIParameterThe parameter.
channelintMIDI channel, 0-based (0..15).
controllerintController number (0..127).
Exceptions
- ArgumentOutOfRangeException
The channel or the controller is out of range.
BeginLearn(IParameter)
Starts learning for a parameter (cancels any other learn in progress).
public void BeginLearn(IParameter parameter)
Parameters
parameterIParameterThe parameter to assign to the next MIDI controller moved.
CancelLearn()
Cancels the learn in progress, if any.
public void CancelLearn()
Describe(int, int)
Text of an assignment, e.g. "CC 74 · Ch 1".
public static string Describe(int channel, int controller)
Parameters
channelintMIDI channel, 0-based (negative: any channel, not shown).
controllerintController number (0..127, or 128/129 for aftertouch and pitch bend).
Returns
- string
The description.
Remarks
Controller 128 is shown as "Aftertouch" and 129 as "Pitch Bend" (VST3 extended controller numbers).
Forget(IParameter)
Removes the MIDI assignment of a parameter.
public void Forget(IParameter parameter)
Parameters
parameterIParameterA parameter.
GetAssignment(IParameter)
Short description of the assignment (e.g. "CC 74 · Ch 1"), or null if the parameter has none.
public string? GetAssignment(IParameter parameter)
Parameters
parameterIParameterA parameter.
Returns
- string
The assignment text, or
null.
IsLearning(IParameter)
true while parameter waits for a MIDI controller.
public bool IsLearning(IParameter parameter)
Parameters
parameterIParameterA parameter.
Returns
- bool
trueif learning for this parameter.
ProcessController(int, int, double)
Handles a received MIDI controller (UI thread): completes a learn in progress, or moves the parameter assigned to it (as a complete edit gesture).
public bool ProcessController(int channel, int controller, double value)
Parameters
channelintMIDI channel, 0-based.
controllerintController number.
valuedoubleController value normalized to [0, 1].
Returns
- bool
trueif the controller was used.
Events
Changed
Raised when a learn starts, ends, or an assignment changes.
public event Action? Changed