# LV2 MIDI

http://lv2plug.in/ns/ext/midi
A normalised definition of raw MIDI.

Version | 1.8
Date | 2018-03-16
Discuss | devel@lists.lv2plug.in (subscribe)
Developers | David Robillard, Lars Luthman
Maintainer | David Robillard

- Index
- Reference
- History
- API

This specification defines a data type for a MIDI message, midi:MidiEvent, which is normalised for fast and convenient real-time processing. MIDI is the Musical Instrument Digital Interface, a ubiquitous binary standard for controlling digital music devices.

For plugins that process MIDI (or other situations where MIDI is sent via a generic transport) the main type defined here, midi:MidiEvent, can be mapped to an integer and used as the type of an LV2 Atom or Event.

This specification also defines a complete human and machine readable description of the MIDI standard (except for standard controller numbers). These descriptions are detailed enough to express any MIDI message as properties.

## Index

Classes | Properties | Files
--- | --- | ---
Chunk HexByte MidiEvent SystemMessage SystemCommon QuarterFrame SongPosition SongSelect TuneRequest SystemExclusive SystemRealtime ActiveSense Clock Continue Reset Start Stop VoiceMessage Aftertouch Bender ChannelPressure Controller NoteOff NoteOn ProgramChange | benderValue binding byteNumber channel chunk controllerNumber controllerValue noteNumber pressure programNumber property songNumber songPosition status statusMask velocity | lv2-midi.doap.ttl midi.h midi.ttl

## Reference

### Class midi:ActiveSense

Active Sense Message

Sub-class of | midi:SystemRealtime
midi:status | FE

### Class midi:Aftertouch

Aftertouch Message

Sub-class of | midi:VoiceMessage
midi:chunk |
midi:byteNumber | 0
midi:property | midi:noteNumber
midi:chunk |
midi:byteNumber | 1
midi:property | midi:pressure
midi:statusMask | A0

### Class midi:Bender

Bender Message

Sub-class of | midi:VoiceMessage
midi:chunk |
midi:byteNumber | 0
midi:byteNumber | 1
midi:property | midi:benderValue
midi:statusMask | E0

### Class midi:ChannelPressure

Channel Pressure Message

Sub-class of | midi:VoiceMessage
midi:chunk |
midi:byteNumber | 0
midi:property | midi:pressure
midi:statusMask | D0

### Class midi:Chunk

MIDI Chunk

A series of contiguous bytes (usually one) in a message.

In domain of | midi:property
| midi:byteNumber

### Class midi:Clock

Clock Message

Sub-class of | midi:SystemRealtime
midi:status | F8

### Class midi:Continue

Continue Message

Sub-class of | midi:SystemRealtime
midi:status | FB

### Class midi:Controller

Controller Change Message

Sub-class of | midi:VoiceMessage
midi:chunk |
midi:byteNumber | 0
midi:property | midi:controllerNumber
midi:chunk |
midi:byteNumber | 1
midi:property | midi:controllerValue
midi:statusMask | B0

### Class midi:HexByte

A hexadecimal byte, which is a xsd:hexBinary value <= FF

In range of | midi:statusMask
| midi:status
| midi:velocity
owl:onDatatype | xsd:hexBinary
owl:withRestrictions |
rdf:first |
xsd:maxInclusive | FF
rdf:rest | rdf:nil

### Class midi:MidiEvent

MIDI Message

A single raw MIDI message (i.e. a sequence of bytes).

This is equivalent to a standard MIDI messages, except with the following restrictions to simplify handling:

- Running status is not allowed, every message must have its own status byte.
- Note On messages with velocity 0 are not allowed. These messages are equivalent to Note Off in standard MIDI streams, but here only proper Note Off messages are allowed.
- "Realtime messages" (status bytes 0xF8 to 0xFF) are allowed, but may not occur inside other messages like they can in standard MIDI streams.
- All messages are complete valid MIDI messages. This means, for example, that only the first byte in each event (the status byte) may have the eighth bit set, that Note On and Note Off events are always 3 bytes long, etc. Where messages are communicated, the writer is responsible for writing valid messages, and the reader may assume that all events are valid.

If a midi:MidiEvent is serialised to a string, the format should be xsd:hexBinary, e.g. (in Turtle notation):

    [] eg:someEvent "901A01"^^midi:MidiEvent .

Sub-class of | ev:Event
| atom:Atom
In range of | midi:binding
owl:onDatatype | xsd:hexBinary

### Class midi:NoteOff

Note Off Message

Sub-class of | midi:VoiceMessage
midi:chunk |
midi:byteNumber | 0
midi:property | midi:noteNumber
midi:chunk |
midi:byteNumber | 1
midi:property | midi:velocity
midi:statusMask | 80

### Class midi:NoteOn

Note On Message

Sub-class of | midi:VoiceMessage
midi:chunk |
midi:byteNumber | 0
midi:property | midi:noteNumber
midi:chunk |
midi:byteNumber | 1
midi:property | midi:velocity
midi:statusMask | 90

### Class midi:ProgramChange

Program Change Message

Sub-class of | midi:VoiceMessage
midi:chunk |
midi:byteNumber | 0
midi:property | midi:programNumber
midi:statusMask | C0

### Class midi:QuarterFrame

Quarter Frame Message

Sub-class of | midi:SystemCommon
midi:status | F1

### Class midi:Reset

Reset Message

Sub-class of | midi:SystemRealtime
midi:status | FF

### Class midi:SongPosition

Song Position Pointer Message

Sub-class of | midi:SystemCommon
midi:chunk |
midi:byteNumber | 0
midi:byteNumber | 1
midi:property | midi:songPosition
midi:status | F2

### Class midi:SongSelect

Song Select Message

Sub-class of | midi:SystemCommon
midi:status | F3

### Class midi:Start

Start Message

Sub-class of | midi:SystemRealtime
midi:status | FA

### Class midi:Stop

Stop Message

Sub-class of | midi:SystemRealtime
midi:status | FC

### Class midi:SystemCommon

System Common Message

Sub-class of | midi:SystemMessage

### Class midi:SystemExclusive

System Exclusive Message

Sub-class of | midi:SystemMessage
midi:status | F0

### Class midi:SystemMessage

System Message

Sub-class of | midi:MidiEvent
midi:statusMask | F0

### Class midi:SystemRealtime

System Realtime Message

Sub-class of | midi:SystemMessage

### Class midi:TuneRequest

Tune Request Message

Sub-class of | midi:SystemCommon
midi:status | F6

### Class midi:VoiceMessage

Voice Message

Sub-class of | midi:MidiEvent
midi:statusMask | F0

### Property midi:benderValue

bender value

The value of a pitch bender (-8192 to 8192).

OWL Type | Datatype Property
Range | xsd:short

### Property midi:binding

binding

The MIDI event to bind a parameter to. This describes which MIDI events should be used to control a port, parameter, or other object. The binding should be a midi:MidiEvent but the property that represents the control value may be omitted. For example, to bind to the value of controller 17:

    port midi:binding [
        a midi:Controller ;
        midi:controllerNumber 17
    ] .

OWL Type | Object Property
Range | midi:MidiEvent

### Property midi:byteNumber

byte number

The 0-based index of a byte which is part of this chunk.

OWL Type | Datatype Property
Domain | midi:Chunk
Range | xsd:unsignedByte

### Property midi:channel

MIDI channel

The channel number of a MIDI message.

OWL Type | Datatype Property
Range | xsd:unsignedByte

### Property midi:chunk

MIDI chunk

A chunk of a MIDI message.

Range | xsd:hexBinary
| xsd:byte

### Property midi:controllerNumber

MIDI controller number

The numeric ID of a controller (0 to 127).

OWL Type | Datatype Property
Range | xsd:byte

### Property midi:controllerValue

MIDI controller value

The value of a controller (0 to 127).

OWL Type | Datatype Property
Range | xsd:byte

### Property midi:noteNumber

note number

The numeric ID of a note (0 to 127).

OWL Type | Datatype Property
Range | xsd:byte

### Property midi:pressure

key pressure

Key pressure (0 to 127).

OWL Type | Datatype Property
Range | xsd:byte

### Property midi:programNumber

program number

The numeric ID of a program (0 to 127).

OWL Type | Datatype Property
Range | xsd:byte

### Property midi:property

property

The property this chunk represents.

OWL Type | Object Property
Domain | midi:Chunk
Range | rdf:Property

### Property midi:songNumber

song number

The numeric ID of a song (0 to 127).

OWL Type | Datatype Property
Range | xsd:byte

### Property midi:songPosition

song position

Song position in MIDI beats (16th notes) (-8192 to 8192).

OWL Type | Datatype Property
Range | xsd:short

### Property midi:status

status byte

The exact status byte for a message of this type.

OWL Type | Datatype Property
Range | midi:HexByte

### Property midi:statusMask

status mask

The status byte for a message of this type on channel 1, i.e. a status byte with the lower nibble set to zero.

OWL Type | Datatype Property
Range | midi:HexByte

### Property midi:velocity

velocity

The velocity of a note message (0 to 127).

OWL Type | Datatype Property
Range | midi:HexByte

## History

Version 1.8 (2012-10-14)
  - Remove non-standard midi:Tick message type.
  - Add midi:binding and midi:channel predicates.
  - Fix definition of SystemExclusive status byte.
  - Use consistent label style.
  - Add midi:HexByte datatype for status bytes and masks.
  - Add C definitions for message types and standard controllers.
Version 1.6 (2012-04-17)
  - Add class definitions for various message types.
  - Document how to serialise a MidiEvent to a string.
  - Merge with unified LV2 package.
Version 1.4 (2011-11-21)
  - Improve documentation.
  - Update packaging.
Version 1.2 (2011-05-26)
  - Add build system for installation.
  - Switch to ISC license.
Version 1.0 (2010-10-04)
  - Initial release.