Quantcast

Documentation Center

  • Trial Software
  • Product Updates

midicontrols

Open a group of MIDI controls for reading

Syntax

  • h = midicontrols example
  • h = midicontrols(ControlNumbers) example
  • h = midicontrols(ControlNumbers,InitialValues) example
  • h = midicontrols(___,'MIDIDevice',devicename) example
  • h = midicontrols(___,'OutputMode',mode) example

Description

example

h = midicontrols returns an object that responds to any control on the default MIDI device. Calling midiread with the object, returns the double scalar value of the MIDI control that recently moved after the object was created. The value is normally in the range [0 1]. See OutputMode for an alternative. This object can only determine a control's value if the control is moved after the midicontrols object is created. If midiread is called before the control is moved, midiread returns a default initial value of 0.

example

h = midicontrols(ControlNumbers) returns an object that responds to the MIDI controls specified by ControlNumbers. Calling midiread with the object, returns a double array of the same shape as ControlNumbers. Use midiid to interactively identify the control number of individual MIDI controls.

example

h = midicontrols(ControlNumbers,InitialValues) returns an object that uses the specified InitialValues when controls are not moved after the object is created. Because initial values are quantized for the underlying MIDI protocol, sometimes midiread returns an initial value that is slightly different from InitialValues.

example

h = midicontrols(___,'MIDIDevice',devicename) specifies the MIDI device to which the object responds. Use midiid to interactively identify the name of a specific MIDI device. If you do not specify the 'MIDIDevice' name-value pair, the default MIDI device is used. The MATLAB® preference 'midi' 'DefaultDevice' determines the default device.

example

h = midicontrols(___,'OutputMode',mode) specifies the range of values returned by midiread and accepted as InitialValues. This name-value pair is optional, and you can insert it only at the end of the argument list.

Examples

expand all

Respond to any Control on the Default Device

Create the object, and read from it:

h =midicontrols
midiread(h)

Move one of the controls, and read the data:

midiread(h)

Respond to a Specific Control

Make the object respond to a specific control:

h = midicontrols(1081);

Use Control Numbers and an Initial Value

Return a square array, with initial value of 0.5:

h = midicontrols([1081 1083; 1082 1084], 0.5);

Set Mode to raw, and Set an Initial Value

Return a square array, with the raw initial value of 63:

h = midicontrols([1081 1083; 1082 1084], 63, 'OutputMode', 'rawmidi');

Set the Default MIDI Device

Assume your MIDI device is a Behringer BCF2000. Set the default device this way:

setpref midi DefaultDevice BCF2000

This preference persists across MATLAB sessions, so you do not need to set it again unless you want to change devices.

Use Both ControlNumbers and DeviceName

Respond to control 1001 on a Behringer BCF2000:

h = midicontrols(1001, 'MIDIDevice', 'BCF2000');

Input Arguments

expand all

ControlNumbers — Identifying MIDI controlsinteger values

ControlNumbers are integer-valued double-precision numbers. Each control on the MIDI device has a specific integer assigned to it by the device manufacturer. If ControlNumbers is [ ], then the midicontrols object responds to any control on the MIDI device. As a result, midiread returns a double scalar.

Example: 1081

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

InitialValues — Initial value of MIDI control any numeric value within range

InitialValues must either be an array of the same size as ControlNumbers or a scalar. If you do not specify InitialValues, the default initial value is 0. Typically, initial values must be in the range [0 1]. However, if you specify ‘rawmidi' as OutputMode, the InitialValues range is between 0 and 127. Because the initial values are quantized for the underlying MIDI protocol, sometimes midiread returns an initial value that is slightly different from InitialValues.

Example: 0.3 or [0 0.3 0.6]

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

devicename — Name of devicecharacter string

devicename is a character string assigned by the device manufacturer or the host operating system. The specified devicename can be a substring of the device's exact name. If you do not specify the ‘MIDIDevice' name-value pair, the default MIDI device is used. The MATLAB preference ‘midi', ‘DefaultDevice' determines the default device.

If you do not set the MATLAB preference, the host operating system chooses the default device in an unspecified way. Some systems have virtual (ie, software) MIDI devices installed. Even if you have only one hardware MIDI device attached to your system, the system may not choose it, which can cause confusion. As a best practice, use midiid to identify the name of the device you want. Then use setpref to set it as the default device.

Example: 'BCF2000 MIDI 1'

Data Types: char

mode — Mode of outputcharacter string

mode is a string and must be one of ‘normalized' or ‘rawmidi'. In normalized mode, values are in the range [0 1]. Also, initial values are quantized for the underlying MIDI protocol. In the raw MIDI mode, values are integers in the range [0 127], and the quantization of the initial values is not performed. The default of this name-value pair is ‘normalized'.

Example: 'rawmidi'

Data Types: char

Output Arguments

expand all

h — Object that listens to the controls on a MIDI deviceobject

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

See Also

| | | |

Was this topic helpful?