MIDI 2.0 messages are handled as JZZ.MIDI2 objects (alias: JZZ.UMP). This type inherits from the JavaScript Array, and therefore allows all array operations on it.
MIDI 2.0 object behavior is in many ways identical to that of the MIDI 1.0 object.
JZZ.MIDI2() works with or without the new keyword.
It accepts an array or a comma-separated list of the message bytes or another JZZ.MIDI2 object.
String names for the notes are allowed where appropriate.
All following statements will produce the same result:
msg = new JZZ.MIDI2([0x20, 0x90, 0x3f, 0x7f]); msg = new JZZ.UMP([0x20, 0x90, 0x3f, 0x7f]); msg = new JZZ.MIDI2(0x20, 0x90, 0x3f, 0x7f); msg = JZZ.MIDI2(0x20, 0x90, 0x3f, 0x7f); msg = JZZ.UMP(0x20, 0x90, 0x3f, 0x7f); msg = JZZ.MIDI2([0x20, 0x90, 'Eb5', 0x7f]); msg = JZZ.MIDI2.noteOn(0, 0, 'D#5', 0x7f);
toString() converts MIDI message to a human-readable string.
When used in MIDI 2.0 context, MIDI 1.0 helpers require group as an additional first parameter and produce MIDI 1.0 messages wrapped into Universal MIDI Packages (UMP).
Long MIDI 1.0 messages such as SysEx can be split into multiple UMPs. Multiple messages will be returned in an Array.
SMF metaevents are not used in MIDI 2.0.
JZZ.MIDI.noteOn(c, nn, vv); // => 9c nn vv JZZ.MIDI2.noteOn(g, c, nn, vv); // => 2g 9c nn vv
Utility Messages
noop() - no operation; returns 00 00 00 00.
umpClock(xxxx) - clock message; returns 00 10 xx xx.
umpTimestamp(xxxx) - timestamp message; returns 00 20 xx xx.
umpTicksPQN(xxxx) - ticks per quarter note; returns 00 30 xx xx.
umpDelta(xxxx) - ticks since the last event; returns 00 40 xx xx.
MIDI 2.0 Channel Voice Messages
umpNoteOn(g, c, nn, vvvv, tt, aaaa) - note on; returns 4g 9c nn tt vv vv aa aa. If omitted, default velocity value is FFFF, default attribute type and value are zeros.
umpNoteOff(g, c, nn, vvvv, tt, aaaa) - note off; returns 4g 8c nn tt vv vv aa aa. Defaults - as above.
umpProgram(g, c, xx), umpProgram(g, c, xx, mm, ll) - program change; mm and ll - bank MSB and LSB; returns 4g Cc 00 00 xx 00 00 00 or 4g Cc 00 01 xx 00 mm ll.
umpPressure(g, c, xx), umpPressure(g, c, x1, x2, x3, x4) - channel pressure; x - a 4-byte value, or x1, x2, x3, x4 - its bytes separately; returns 4g Dc 00 00 x1 x2 x3 x4.
umpPressureF(g, c, xx) - as above; maps 0 <= xx <= 1 to a 4 byte value.
umpPnPressure(g, c, nn, xx), umpPnPressure(g, c, nn, x1, x2, x3, x4) - per-note pressure (aftertouch); returns 4g Ac nn 00 x1 x2 x3 x4.
umpPnPressureF(g, c, nn, xx) - as above; maps 0 <= xx <= 1 to a 4 byte value.
umpAftertouch(g, c, nn, xx), umpAftertouch(g, c, nn, x1, x2, x3, x4) - an alias to umpPnPressure().
umpAftertouchF(g, c, nn, xx), umpAftertouch(g, c, nn, xx) - an alias to umpPnPressureF().
umpPitchBend(g, c, xx), umpPitchBend(g, c, x1, x2, x3, x4) - channel pitch bend; returns 4g Ec 00 00 x1 x2 x3 x4.
umpPitchBendF(g, c, xx) - as above; maps -1 <= xx <= 1 to a 4 byte value.
umpPnPitchBend(g, c, nn, xx), umpPnPitchBend(g, c, nn, x1, x2, x3, x4) - per-note pitch bend; returns 4g 6c nn 00 x1 x2 x3 x4.
umpPnPitchBendF(g, c, xx) - as above; maps -1 <= xx <= 1 to a 4 byte value.
umpRPN(g, c, bb, mm, xx), umpRPN(g, c, bb, mm, x1, x2, x3, x4) - registered parameter; bb - bank (RPM MSB), mm parameter number (RPN LSB); returns 4g 2c bb mm x1 x2 x3 x4.
umpPnRPN(g, c, nn, xx), umpPnRPN(g, c, nn, x1, x2, x3, x4) - per-note registered parameter; nn - note, mm parameter number; returns 4g 0c nn mm x1 x2 x3 x4.
umpNRPN(g, c, bb, mm, xx), umpNRPN(g, c, bb, mm, x1, x2, x3, x4) - non-registered (assignable) parameter; returns 4g 3c bb mm x1 x2 x3 x4.
umpPnNRPN(g, c, nn, xx), umpPnNRPN(g, c, nn, x1, x2, x3, x4) - per-note non-registered (assignable) parameter; returns 4g 1c nn mm x1 x2 x3 x4.
umpControl(g, c, mm, xx), umpControl(g, c, mm, x1, x2, x3, x4) - control change; mm - 7-bit control number (except 0, 6, 32, 38, 98, 99, 100, 101); returns 4g Bc mm 00 x1 x2 x3 x4.
Flex Data Messages
umpTempo(g, tttt) - tempo; returns Dg 10 00 00 tt tt 00 00 00 00 00 00 00 00 00 00; where tttt is a number of 10 nanosecond units per quarter note.
umpBPM(g, bpm) - BPM; calculates tttt from bpm and runs umpTempo().
umpTimeSignature(g, tsg), umpTimeSignature(g, nn, dd) - time signature;
returns Dg 10 00 01 nn xx cc 00 00 00 00 00 00 00 00 00;
where tss = nn + '/' + dd is a time signature string, e.g. '6/8',
nn - time signature numerator, and dd = 2xx - time signature denominator (must be a power of 2).
umpCustomText(g, c, d, bb, ss, txt) - custom text;
returns [Dg Xc bb ss nn xx xx xx xx xx xx xx xx xx xx xx, ...];
where d = 0 - channel-specific text, d = 1 - group-only text,
bb/ss - message bank and status that define the text role.
umpMetadata(g, txt), umpCMetadata(g, c, txt) - metadata text; returns [Dg Xc 01 00 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpProjectName(g, txt), umpCProjectName(g, c, txt) - project name; returns [Dg Xc 01 01 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpCompositionName(g, txt), umpCCompositionName(g, c, txt) - composition name; returns [Dg Xc 01 02 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpClipName(g, txt), umpCClipName(g, c, txt) - clip name; returns [Dg Xc 01 03 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpCopyright(g, txt), umpCCopyright(g, c, txt) - copyright; returns [Dg Xc 01 04 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpComposerName(g, txt), umpCComposerName(g, c, txt) - composer name; returns [Dg Xc 01 05 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpLyricistName(g, txt), umpCLyricistName(g, c, txt) - lyricist name; returns [Dg Xc 01 06 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpArrangerName(g, txt), umpCArrangerName(g, c, txt) - arranger name; returns [Dg Xc 01 07 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpPublisherName(g, txt), umpCPublisherName(g, c, txt) - publisher name; returns [Dg Xc 01 08 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpPerformerName(g, txt), umpCPerformerName(g, c, txt) - performer name; returns [Dg Xc 01 09 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpAccPerformerName(g, txt), umpCAccPerformerName(g, c, txt) - accompanying performer name; returns [Dg Xc 01 0A xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpRecordingDate(g, txt), umpCRecordingDate(g, c, txt) - recording date; returns [Dg Xc 01 0B xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpRecordingLocation(g, txt), umpCRecordingLocation(g, c, txt) - recording location; returns [Dg Xc 01 0C xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpText(g, txt), umpCText(g, c, txt) - text event; returns [Dg Xc 02 00 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpLyrics(g, txt), umpCLyrics(g, c, txt) - lyrics; returns [Dg Xc 02 01 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpLyricsLanguage(g, txt), umpCLyricsLanguage(g, c, txt) - lyrics language; returns [Dg Xc 02 02 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpRuby(g, txt), umpCRuby(g, c, txt) - ruby; returns [Dg Xc 02 03 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
umpRubyLanguage(g, txt), umpCRubyLanguage(g, c, txt) - metadata text; returns [Dg Xc 02 04 xx xx xx xx xx xx xx xx xx xx xx xx, ...].
UMP Stream Messages
umpStartClip() - start of MIDI clip; returns F0 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00.
umpEndClip() - end of MIDI clip; returns F0 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00.
More to come...
Group, Channel and SysEx ID modifiers
gr(g) - default group; e.g. JZZ.MIDI2.gr(2).noteOn(5, 'C5', 127) is equialent to JZZ.MIDI2.noteOn(2, 5, 'C5', 127).
ch(c) - default channel; e.g. JZZ.MIDI2.ch(5).noteOn(2, 'C5', 127) is equialent to JZZ.MIDI2.noteOn(2, 5, 'C5', 127) and to JZZ.MIDI2.gr(2).ch(5).noteOn('C5', 127).
sxId(n) - default SysEx ID; e.g. JZZ.MIDI2.sxId(5).sxMasterCoarseTuning(0, 1) returns [30 06 7F 05 04 04 00 01] instead of [30 06 7F 7F 04 04 00 01].
All helpers above can be directly used with the MIDI-Out port in MIDI 2.0 mode and MIDI Clip objects.
isNoteOn() - return true if the message is a MIDI 1.0 or MIDI 2.0 Note On event, or false otherwise.
isNoteOff() - return true if the message is a MIDI 1.0 or MIDI 2.0 Note Off event, or false otherwise.
isTempo() - return true if the message is a Tempo event, or false otherwise.
isTimeSignature() - return true if the message is a Time Signature event, or false otherwise.
isTicksPQN() - return true if the message is a Ticks Per Quarter Note event, or false otherwise.
isDelta() - return true if the message is a Delta Time event, or false otherwise.
isStartClip() - return true if the message is an Start of MIDI Clip event, or false otherwise.
isEndClip() - return true if the message is an End of MIDI Clip event, or false otherwise.
getTempo() - extract the tempo as a number of 10 nanosecond units per quarter note from a Tempo event.
getBPM() - extract the tempo in beats per minute from a Tempo event.
getTimeSignature() - extract the time signature from a Time Signature event.
getTicksPQN() - extract the number of ticks per quarter note from a Ticks Per Quarter Note event.
getDelta() - extract the number of ticks from a Delta Time event.