Jazz-Soft.net

We make it sound!

Home » Documentation » JZZ.js » JZZ.midi.GM

JZZ.midi.GM

General MIDI instrument names: MIDI to String, String to MIDI.

MIDI to String

JZZ.MIDI.programName(midi) - get General MIDI instrument name.

JZZ.MIDI.groupName(midi) - get General MIDI group name.

JZZ.MIDI.percussionName(midi) - get General MIDI percussion instrument name.

String to MIDI

JZZ.MIDI.programValue(str) - get the program value corresponding to the instrument name.

If there is no exact match, tries the best guess.

JZZ.MIDI.noteValue(str) - get the note value corresponding to the percussion instrument name.

If there is no exact match, tries the best guess.

JZZ.MIDI.guessValue(str) - map the program or percussion name (whichever matches best) to the MIDI value.

If the return value is negative, it's the percussion note value with a minus sign, otherwise, it's the program value.

Helpers

In addition, when the module is loaded, JZZ helper functions
note() / noteOn() / noteOff() / aftertouch() / program()
start to understand instrument names where appropriate.

Example

// in Node.js:
var JZZ = require('jzz');
require('jzz-midi-gm')(JZZ);
// or in HTML:
<script src="JZZ.js"></script>
<script src="JZZ.midi.GM.js"></script>
// MIDI to String:

console.log(JZZ.MIDI.programName(60));
// => 'French Horn'
console.log(JZZ.MIDI.groupName(60));
// => 'Brass'
console.log(JZZ.MIDI.percussionName(60));
// => 'Hi Bongo'

// String to MIDI:

console.log(JZZ.MIDI.programName(JZZ.MIDI.programValue('piano')));
// => 'Acoustic Grand Piano'
console.log(JZZ.MIDI.percussionName(JZZ.MIDI.noteValue('snare')));
// => 'Acoustic Snare'
var n = JZZ.MIDI.guessValue('crash');
if (n < 0) console.log(JZZ.MIDI.percussionName(-n));
else console.log(JZZ.MIDI.programName(n));
// => 'Crash Cymbal 1'

// Helpers:

JZZ().openMidiOut().ch(0).program('accordion').noteOn('C#6')
     .wait(200).ch(9).noteOn('cowbell');

See also