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.


Send values to MIDI controls to synchronize

The midisync function will be removed from DSP System Toolbox™ in a future release. Existing instances of the function continue to run. For new code, use the midisync function from Audio System Toolbox™ instead.





midisync(h) sends the initial values specified by midicontrols. h is created by the MIDI controls associated with the midicontrols object, h. You can use midisync with bidirectional MIDI devices that can both send and receive messages, and move a control in response to a received message. For example, when a midicontrols object is first created, it is often helpful to move the MIDI control to match the initial value of the object. Many MIDI devices are not bidirectional, and calling midisync with a unidirectional device has no effect. midisync cannot tell whether a value is successfully sent to a device or even whether the device is bidirectional. Therefore, no errors or warnings are generated if sending a value fails.


midisync(h,Values) sends Values to the MIDI controls associated with the midicontrols object, h. Values must follow the same rules as InitialValue arguments of midicontrols.


collapse all

midisync(h, get(slider, 'Value'))

When you move either control, the other control tracks it. The resulting value appears on the command prompt.

function trivialmidigui(controlnum,DEVICENAME)
    slider = uicontrol('Style','slider');
    mc = midicontrols(controlnum,'MIDIDevice',DEVICENAME);
    midicallback(mc, @mccb);
    function slidercb(slider,~)
        val = get(slider,'Value');
        midisync(mc, val);

    function mccb(mc)
        val = midiread(mc);

Input Arguments

collapse all

h is an object that listens to the controls on a MIDI device.

Values must either be an array the same size as ControlNumbers from midicontrols or a scalar. If you do not specify Values, the default value is whatever the InitialValues is from midicontrols. Typically, values must normally be in the range [0 1]. However, if you specify ‘rawmidi' as OutputMode of midicontrols, the Values range is between 0 and 127.

Example: 0.3 or [0 0.3 0.6]

Data Types: double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Introduced in R2013b

Was this topic helpful?