Main Content

configureMIDI

Configure MIDI connections between audio object and MIDI controller

Description

example

configureMIDI(audioObject) opens a MIDI configuration user interface (UI). Use the UI to synchronize parameters of the plugin, audioObject, to MIDI controls on your default MIDI device. You can also generate MATLAB® code corresponding to the MIDI configuration developed using the configureMIDI UI.

To set your default device, type this syntax in the command line:

setpref midi DefaultDevice deviceNameValue

deviceNameValue is the MIDI device name, assigned by the device manufacturer or host operating system. Use midiid to get the device name corresponding to your MIDI device.

example

configureMIDI(audioObject,propertyName) makes the property, propertyName, respond to any control on the default MIDI device.

example

configureMIDI(audioObject,propertyName,controlNumber) makes the property respond to the MIDI control specified by controlNumber.

example

configureMIDI(audioObject,propertyName,controlNumber,'DeviceName',deviceNameValue) makes the property respond to the MIDI control specified by controlNumber on the device specified by deviceNameValue.

Examples

collapse all

  1. Open the MIDI configuration UI for a parametric equalizer plugin object.

    parametricEQPlugin = audiopluginexample.ParametricEqualizerWithUDP;
    configureMIDI(parametricEQPlugin)
  2. In the UI, select a property to synchronize with your default MIDI device.

  3. On your MIDI device, operate the control that you want to synchronize to the selected plugin property. The control appears in the MIDI Control column in the row of the corresponding property.

  4. Repeat steps 2 and 3 as needed to synchronize multiple properties to multiple MIDI controls.

    To disconnect the property and control currently selected on your configureMIDI UI, click Reset Connection.

  5. Click OK.

    The specified MIDI controls and properties and now synchronized.

Generate MATLAB code corresponding to the MIDI configuration developed using the configureMIDI UI. You can embed the MATLAB code in your simulation so that you do not need to reopen the UI to restore your chosen MIDI connections.

  1. Open the MIDI configuration UI for a parametric equalizer plugin object.

    parametricEQPlugin = audiopluginexample.ParametricEqualizerWithUDP;
    configureMIDI(parametricEQPlugin)
  2. In the UI, select a property to synchronize with your default MIDI device.

  3. On your MIDI device, operate the control that you want to synchronize to the selected plugin property. The control appears in the MIDI Control column in the row of the corresponding property.

  4. Select the Generate MATLAB Code check box.

  5. Click OK. The generated MATLAB code corresponds to the MIDI configuration that you developed.

Make a plugin property respond to any control on your default MIDI device.

parametricEQPlugin = audiopluginexample.ParametricEqualizerWithUDP;
configureMIDI(parametricEQPlugin,'CenterFrequency1');

Make a plugin property respond to a specific MIDI control on your default MIDI device.

Create an object of the audio plugin example audiopluginexample.ParametricEqualizerWithUDP.

parametricEQPlugin = audiopluginexample.ParametricEqualizerWithUDP;

Use midiid to identify a MIDI control to synchronize with your property.

[controlNumber,device] = midiid
Move the control you wish to identify; type ^C to abort.
Waiting for control message... done

controlNumber =

        1083


device =

    'BCF2000'

Use configureMIDI to synchronize your chosen MIDI control, specified by controlNumber, with a property.

configureMIDI(parametricEQPlugin,'CenterFrequency1',controlNumber);

Make a plugin property respond to any control on your default MIDI device.

Create an object of the audio plugin example, audiopluginexample.ParametricEqualizerWithUDP.

parametricEQPlugin = audiopluginexample.ParametricEqualizerWithUDP;

Use midiid to identify a specific MIDI control on a specific MIDI device.

[controlNumber,device] = midiid
Move the control you wish to identify; type ^C to abort.
Waiting for control message... done

controlNumber =

        1087


device =

    'BCF2000'

Use configureMIDI to synchronize a property with your chosen MIDI control, specified by controlNumber, on your chosen MIDI device, specified by device.

configureMIDI(parametricEQPlugin,'CenterFrequency1',controlNumber,'DeviceName',device)

Input Arguments

collapse all

Audio plugin or compatible System object™, specified as an object that inherits from the audioPlugin class or an object of a compatible Audio Toolbox™ System object.

Name of the object property, specified as a character vector. Enter the property name exactly as it is defined in the property section of your audio plugin or Audio Toolbox System object.

MIDI device control number, specified as an integer. The value is assigned to the control by the device manufacturer. It is used for identification purposes.

MIDI device name, assigned by the device manufacturer or host operating system, specified as a character vector. If you do not specify a MIDI device name, the default MIDI device is used.

Limitations

For MIDI connections established by configureMIDI, moving a MIDI control sends a callback to update the associated property values. To synchronize your MIDI device in an audio stream loop, you might need to use the drawnow command for the callback to process immediately. For efficiency, use the drawnow limitrate syntax.

For example, to synchronize your MIDI device and audio object, uncomment the drawnow limitrate command from this code:

fileReader = dsp.AudioFileReader('Filename','RockDrums-44p1-stereo-11secs.mp3');
deviceWriter = audioDeviceWriter;
dRC = compressor;

configureMIDI(compressor,'Threshold')

while ~isDone(fileReader)
    input = fileReader();
    output = dRC(input);
    deviceWriter(output);
%     drawnow limitrate;
end

release(fileReader);
release(deviceWriter);

If your audio stream loop includes visualizing data on a scope, such as spectrumAnalyzer, timescope, or dsp.ArrayPlot, the drawnow command is not required.

Version History

Introduced in R2016a

expand all