Table of Contents

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

IReadOnlyDictionary<IParameter, (int Channel, int Controller)>

LearningParameter

Parameter currently learning, or null.

public IParameter? LearningParameter { get; }

Property Value

IParameter

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

parameter IParameter

The parameter.

channel int

MIDI channel, 0-based (0..15).

controller int

Controller 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

parameter IParameter

The 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

channel int

MIDI channel, 0-based (negative: any channel, not shown).

controller int

Controller 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

parameter IParameter

A 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

parameter IParameter

A parameter.

Returns

string

The assignment text, or null.

IsLearning(IParameter)

true while parameter waits for a MIDI controller.

public bool IsLearning(IParameter parameter)

Parameters

parameter IParameter

A parameter.

Returns

bool

true if 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

channel int

MIDI channel, 0-based.

controller int

Controller number.

value double

Controller value normalized to [0, 1].

Returns

bool

true if the controller was used.

Events

Changed

Raised when a learn starts, ends, or an assignment changes.

public event Action? Changed

Event Type

Action