Jazz-Soft.net

We make it sound!

Home » Documentation » JZZ.js » JZZ.MIDI.SMF

JZZ.MIDI.SMF - Standard MIDI Files

NOTE: The SMF API is currently under active development. Please return to this page soonu to find the additional features.

Construction

JZZ.MIDI.SMF(data) - create the SMF (Standard MIDI File) object; works with or without the new keyword.

data - the MIDI file contents as string.

If no data specified, an empty SMF onject will be created.

player()

smf.player() - create the Player object.

Player is subclassed from MIDI-In and inherits all its methods, in particular, connect() and disconnect().

play()

player.play() - start playback.

stop()

player.stop() - stop playback.

pause()

player.pause() - pause playback.

resume()

player.pause() - resume playback.

loop()

player.loop(value) - set / unset the loop.

value - if integer - set the loop counter to value; otherwise if true - set the loop to infinity; if false - unset the loop.

duration()

player.duration() - return the MIDI file duration in MIDI ticks.

position()

player.position() - return the current MIDI file position in MIDI ticks.

jump()

player.jump(pos) - jump to specified position.

pos - position in MIDI ticks.

Example

var JZZ = require('jzz');
require('jzz-midi-smf')(JZZ);

var data = require('fs').readFileSync('test.mid').toString('binary');
var smf = new JZZ.MIDI.SMF(data);

var player = smf.player();
JZZ().or('Cannot start MIDI engine!').openMidiOut().or('Cannot open MIDI Out!').and(function() {
  player.connect(this);
  player.play();
});

See also