-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
25 lines (22 loc) · 662 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
var JZZ, WAAPI;
try {
WAAPI = require('node-web-audio-api');
JZZ = require('jzz');
require('jzz-midi-smf')(JZZ);
require('.')(JZZ);
}
catch (e) {
console.log('Please run `npm install` ...');
process.exit(0);
}
var file = process.argv[2];
if (typeof file == 'undefined') file = 'test.mid';
var data = require('fs').readFileSync(file, 'binary');
var smf = new JZZ.MIDI.SMF(data);
global.window = { AudioContext: WAAPI.AudioContext };
var player = smf.player();
player.onEnd = function() { console.log('Done!'); JZZ.lib.closeAudioContext(); };
JZZ.synth.OSC().or('Cannot open MIDI Out!').and(function() {
player.connect(this);
player.play();
});