3.2 MIDI Controller Interface

3.2.1 midicallback

: oldhandle = midicallback (midicontrolsObj, functionHandle)
: oldhandle = midicallback (midicontrolsObj, [])
: currhandle = midicallback (midicontrolsObj)

Get, set or clear the midicontrol object callback.

Inputs

midicontrolObj - control object created using midicontrols.

functionHandle - function handle to set for call back. If it is [], the callback function will be cleared.

NOTE: currently anonymous functions will not work.

NOTE: callbacks should be cleared before losing all references to the midicontrols object.

Outputs

oldhandle The previously set midicallback function handle when setting a new callback.

currhandle The current set midicallback function handle.

Examples

Set a callback on a midicontrols object

 ctrl = midicontrols(2001)
 function dispCallback(ctrl),disp(midiread(ctrl)),endfunction;
 midicallback(ctrl, @dispCallback);
 

Clear the callback on a midicontrols object

 ctrl = midicontrols(2001)
 midicallback(ctrl, []);
 

Get the current callback on a midicontrols object

 ctrl = midicontrols(2001)
 cb = midicallback(ctrl);
 

See also: midicontrols, midisync, midiread.

3.2.2 midicontrols

: obj = midicontrols ()
: obj = midicontrols (ctrlid)
: obj = midicontrols (ctrlid, initialvalues)
: obj = midicontrols (__, propertyname, propertyvalue)

Create a midi controls object

Inputs

ctrlid - single control id or array of control ids to monitor, or [] to use any controller.
initialvalues - initial values to use for controls. It should be the same size as ctrlid
propertyname, propertyvalue - properties to set on the controller. If a device is not specified the value from getpref("midi", "DefaultDevice", 0) will be used.

Known properties are:

mididevice

name of the mididevice to monitor.

outputmode

the scaling mode for values: ’rawmidi’ will return values between 0 .. 127, ’normalized’ will use values between 0 .. 1.

Outputs

obj - returns a midicontrols object

Examples

Create a midicontrols object monitoring control id 2001 on the default midi device

 ctrl = midicontrols(2001)
 

Create a midicontrols object monitoring control id 2001 on a a non default device

 ctrl = midicontrols(2001, 'mididevice', 1)
 

See also: midiread, midisync.

3.2.3 midiid

: [ctrlid, dev] = midiid ()

Scan for control messages from midi devices to get the id of the device

Function will display a prompt for the user to move the midi control and return when a control messages is detected or ctrl-C is pressed.

Inputs

None

Outputs

ctrlid - control id made from the controller channel * 1000 + controller number.
dev = name of the midi device the controller was detected on.

Examples

Monitor midi devices for first moving controller

 [ctrlid, devname] = midiid()
 

See also: mididevinfo, midicontrols.

3.2.4 midiread

: val = midiread (midicontrolsObj)

Read current values of midi controls

Inputs

midicontrolObj - control object created using midicontrols

Outputs

val single value or array of current values from the midi device.

Examples

Read current value of midicontrols with a ctrlid 2001 on the default midi device.

 ctrl = midicontrols(2001)
 val = midiread(ctrl);
 

Read current value of midicontrols with a ctrlid 2001 on a non default midi device.

 ctrl = midicontrols(2001, 'mididevice', 1)
 val = midiread(ctrl);
 

See also: midicontrols, midisync.

3.2.5 midisync

: midisync (midicontrolsObj)
: midisync (midicontrolsObj, ctrlvalues)

Send the values of control object to the control, using ctrlvalues values if specified instead

Inputs

midicontrolObj - control object created using midicontrols
ctrlvalues - values to send to the controls instead of initial values

Outputs

None

Examples

Send sync command to a midicontrols with a ctrlid 2001 to set a value of 1

 ctrl = midicontrols(2001)
 midisync(ctrl, 1);
 

See also: midicontrols.


Next: MIDI File I/O, Previous: MIDI Device Interface, Up: Function Reference   [Contents][Index]