JMB - abudaan/JazzMIDIBridge GitHub Wiki

init(callback,onerror)

Initializes the JazzMIDIBridge. This method takes care of embedding the plugin as well.

The return value of the callback function is a reference to the MIDIAccess wrapper.

If you do not pass an onerror function and something goes wrong, an alert box with the error message will appear.

JMB.init(
    function (MIDIAccess){
        console.log('all is well!');
    },

    function (msg){
        console.log('an error occurred:', msg);
    }
);

noteNameMode

Sets or gets the current note name mode. Note name modes can be:

  • "sharp" : all chromatic notes are sharps; "C", "C#", "D", ...
  • "flat" : all chromatic notes are flats; "C", "D♭", "D", ...
  • "enh-sharp" : all notes are enharmonic sharps; "B#", "C#", "C##", ...
  • "enh-flat" : all notes are enharmonic flats; "D♭♭", "D♭", "E♭♭", ...

Default value is sharp. You can use static variables for passing one of these values, see below.

getNoteName(noteNumber,mode)

Returns the note name in the given note name mode. Last element is optional, when omitted the current setting is used.

console.log(JMB.getNoteName(49,JMB.NOTE_NAMES_FLAT));
--> prints: D♭3

###getNoteNumber(noteName,octave) Returns the MIDI note number value of the given note name in the given octave.

console.log(JMB.getNoteNumber("D♭",3));
--> prints: 49

getCommand(status)

Returns the human readable command value of the status byte (e.g. "NOTE OFF", "PITCH BEND" etc.)

console.log(JMB.getCommand(0x98));
--> prints: NOTE ON

getChannel(status)

Returns the lower 4 bits of the status byte, i.e. the MIDI channel. Note: channels are zero based.

console.log(JMB.getChannel(0x98));
--> prints: 8

rescan()

Rescans the MIDI system for device changes.

getVersion()

Returns the version of the JazzMIDIBridge.

getJazz()

Returns a reference to the Jazz browser plugin, you can call every available method directly on the returned object, see the API.

var Jazz;

JMB.init(function(MIDIAccess){
	Jazz = JMB.getJazz();
	Jazz.MidiOutRaw([0xF0,0x7F,0x7F,0x04,0x01,0x7F,0x33,0xF7]);
});

getJazzVersion()

Returns the version of the Jazz browser plugin.

getTime()

Returns the time in milliseconds since the plugin initialization.

wrapElement(element)

Adds the standard addEventListener(id,callback,bubbles) method to the specified element in Internet Explorer 8

Useful statics:

### MIDI Commands:
NOTE_OFF = 0x80
NOTE_ON = 0x90
POLY_PRESSURE = 0xA0
CONTROL_CHANGE = 0xB0
PROGRAM_CHANGE = 0xC0
CHANNEL_PRESSURE = 0xD0
PITCH_BEND = 0xE0
SYSTEM_EXCLUSIVE = 0xF0
MIDI_TIMECODE = 241
SONG_POSITION = 242
SONG_SELECT = 243
TUNE_REQUEST = 246
EOX = 247
TIMING_CLOCK = 248
START = 250
CONTINUE = 251
STOP = 252
ACTIVE_SENSING = 254
SYSTEM_RESET = 255

### Note name modes:
NOTE_NAMES_SHARP = "sharp"
NOTE_NAMES_FLAT = "flat"
NOTE_NAMES_SOUNDFONT = "soundfont"
NOTE_NAMES_ENHARMONIC_SHARP = "enh-sharp"
NOTE_NAMES_ENHARMONIC_FLAT = "enh-flat"