uvi-script
Musical event scripting with Lua
MIDI

Classes

class  Event
 Event types. More...
 
class  MidiEvent
 A Midi Event. More...
 
class  MidiSequence
 A Midi sequence that represent a midi file. More...
 

Functions

void postMidiEvent (MidiEvent e)
 send a MidiEvent directly to the script engine event queue.
 
function enable_rpn_as_cc (value)
 lets the script receive RPN as plain CC.
 
function enable_nrpn_as_cc (value)
 lets the script receive NRPN as plain CC.
 
function enable_data_entry_as_cc (value)
 lets the script receive 'data entry' as plain CC.
 
function controlChange (cc, val, ch, inp)
 sends a ControlChange event.
 
function programChange (val, ch, inp)
 sends a ProgramChange event.
 
function pitchBend (b, ch, inp)
 sends a PitchBend event.
 
function afterTouch (v, ch, inp)
 sends an AfterTouch event.
 
function polyAfterTouch (v, n, ch, inp)
 sends a PolyAfterTouch event.
 

Detailed Description

MIDI event generation, file handling, and event structures.

Provides helper functions for generating outgoing MIDI events, classes for loading and manipulating MIDI files, and functions to post raw MIDI events to the engine.

Event Generation Helpers:

Key Classes:

MIDI File Operations:

Raw Event Posting:

Note
MIDI events posted via postMidiEvent() don't have voice IDs. For advanced voice tracking, use playNote() and releaseVoice() instead.
See also
MIDI Event Generation, Events, Async

Function Documentation

◆ afterTouch()

function afterTouch ( v ,
ch ,
inp  )

sends an AfterTouch event.

Parameters
vMIDI AfterTouch value in [0;127], out of range values are clipped
ch(optional) MIDI channel in [1;16], nil or 0 for all channels
inp(optional) MIDI input in [1;4], nil or 0 for all inputs
See also
postEvent, onAfterTouch

◆ controlChange()

function controlChange ( cc ,
val ,
ch ,
inp  )

sends a ControlChange event.

Parameters
ccMIDI Control Change number in [0;127]
valMIDI Control Change value in [0;127], out of range values are clipped
ch(optional) MIDI channel in [1;16], nil or 0 for all channels
inp(optional) MIDI input in [1;4], nil or 0 for all inputs
See also
postEvent, onController

◆ enable_data_entry_as_cc()

function enable_data_entry_as_cc ( value )

lets the script receive 'data entry' as plain CC.

By default CC 6 and CC 38 (data entry MSB, LSB) are consumed before the script sees them: they never reach onController()/onEvent(), getCC() or the script output. Once enabled they are delivered like any other CC and the MSB, LSB midi state machine is left to the script author

Parameters
valuetrue to receive them, any other value restores the default filtering
See also
enable_rpn_as_cc, enable_nrpn_as_cc

◆ enable_nrpn_as_cc()

function enable_nrpn_as_cc ( value )

lets the script receive NRPN as plain CC.

By default CC 98 and CC 99 (NRPN LSB, MSB) are consumed before the script sees them: they never reach onController()/onEvent(), getCC() or the script output. Once enabled they are delivered like any other CC and the MSB, LSB midi state machine is left to the script author

Parameters
valuetrue to receive them, any other value restores the default filtering
See also
enable_rpn_as_cc, enable_data_entry_as_cc

◆ enable_rpn_as_cc()

function enable_rpn_as_cc ( value )

lets the script receive RPN as plain CC.

By default CC 100 and CC 101 (RPN LSB, MSB) are consumed before the script sees them: they never reach onController()/onEvent(), getCC() or the script output. Once enabled they are delivered like any other CC and the MSB, LSB midi state machine is left to the script author

Parameters
valuetrue to receive them, any other value restores the default filtering
See also
enable_nrpn_as_cc, enable_data_entry_as_cc

◆ pitchBend()

function pitchBend ( b ,
ch ,
inp  )

sends a PitchBend event.

Parameters
bPitchBend value in [-1;1], out of range values are clipped
ch(optional) MIDI channel in [1;16], nil or 0 for all channels
inp(optional) MIDI input in [1;4], nil or 0 for all inputs
See also
postEvent, onPitchBend

◆ polyAfterTouch()

function polyAfterTouch ( v ,
n ,
ch ,
inp  )

sends a PolyAfterTouch event.

Parameters
vMIDI AfterTouch value in [0;127], out of range values are clipped
nMIDI note number in [0;127]
ch(optional) MIDI channel in [1;16], nil or 0 for all channels
inp(optional) MIDI input in [1;4], nil or 0 for all inputs
See also
postEvent, onPolyAfterTouch

◆ postMidiEvent()

void postMidiEvent ( MidiEvent e)

send a MidiEvent directly to the script engine event queue.

MidiEvent are posted as-is to the event queue in order to make midi file playing easy. i.e. they don't have voiceId If you need more advanced events processing, you should use playNote() and releaseVoice() and keep track yourself of which note triggered each voiceId.

Note
The event's timestamp is ignored: the event is posted at the current time of the calling thread. To schedule events from a MidiSequence, wait() until each event is due (converting ticks with the sequence's division) and post it then.
Parameters
eMIDI event to be sent
See also
loadMidi, MidiEvent, MidiSequence

◆ programChange()

function programChange ( val ,
ch ,
inp  )

sends a ProgramChange event.

Parameters
valMIDI Program Change value in [0;127], out of range values are clipped
ch(optional) MIDI channel in [1;16], nil or 0 for all channels
inp(optional) MIDI input in [1;4], nil or 0 for all inputs
See also
postEvent, onProgramChange