Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

configureMIDI

Configure MIDI connections between audio object and MIDI controller

Syntax

configureMIDI(audioObject)
configureMIDI(audioObject,propertyName)
configureMIDI(audioObject,propertyName,controlNumber)
configureMIDI(audioObject,propertyName,controlNumber,'DeviceName',deviceNameValue)

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.ParametricEqualizer;
    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 Operate MIDI control to synchronize box.

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

    To disconnect the property and control currently displayed on your configureMIDI UI, click Reset Control at any time.

  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.ParametricEqualizer;
    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 Operate MIDI control to synchronize box.

  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.ParametricEqualizer;
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.ParametricEqualizer.

parametricEQPlugin = audiopluginexample.ParametricEqualizer;

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 =

        1003


device =

nanoKONTROL2

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.ParametricEqualizer.

parametricEQPlugin = audiopluginexample.ParametricEqualizer;

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 =

        1003


device =

nanoKONTROL2

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 System 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 System 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 dsp.SpectrumAnalyzer, dsp.TimeScope, or dsp.ArrayPlot, the drawnow command is not required.

Introduced in R2016a

Was this topic helpful?