jzz-midi-sty
v0.1.0
Published
Yamaha-PSR styles
Downloads
7
Readme
JZZ-midi-STY
Yamaha-PSR styles
Install
npm install jzz-midi-sty --save
or yarn add jzz-midi-sty
or get the full development version and minified scripts from GitHub
Usage
Plain HTML
<script src="JZZ.js"></script>
<script src="JZZ.midi.SMF.js"></script>
<script src="JZZ.midi.STY.js"></script>
//...
CDN (jsdelivr)
<script src="https://cdn.jsdelivr.net/npm/jzz"></script>
<script src="https://cdn.jsdelivr.net/npm/jzz-midi-smf"></script>
<script src="https://cdn.jsdelivr.net/npm/jzz-midi-sty"></script>
//...
CDN (unpkg)
<script src="https://unpkg.com/jzz"></script>
<script src="https://unpkg.com/jzz-midi-smf"></script>
<script src="https://unpkg.com/jzz-midi-sty"></script>
//...
CommonJS
var JZZ = require('jzz');
require('jzz-midi-smf')(JZZ);
require('jzz-midi-sty')(JZZ);
//...
TypeScript / ES6
import { JZZ } from 'jzz';
import { SMF } from 'jzz-midi-smf';
import { STY } from 'jzz-midi-sty';
SMF(JZZ);
STY(JZZ);
//...
AMD
require(['JZZ', 'JZZ.midi.SMF', 'JZZ.midi.STY'], function(JZZ, dummy1, dummy2) {
// ...
});
Style files
Reading file
var fs = require('fs');
var data = fs.readFileSync('my-style.sty', 'binary');
// data can be String, Buffer, ArrayBuffer, Uint8Array, Int8Array,
// or a JZZ.MIDI.SMF object
var sty = new JZZ.MIDI.STY(data);
Extracting MIDI tracks
console.log('All style tracks:', sty.tracks());
// additional track names not reported by tracks() can be:
// '', 'SFF1', 'SFF2', 'OTSc1', 'OTSc2', 'OTSc3', 'OTSc4' (if present)
var smf = sty.export('Intro A'); // see JZZ.MIDI.SMF
fs.writeFileSync('intro-a.mid', smf.dump(), 'binary');
fs.writeFileSync('otsc1.mid', sty.export('OTSc1').dump(), 'binary');
Cleaning up
// remove the OTSc section: it is not required
// unless you use it on a Yamaha keyboard (see the docs...)
delete sty.otsc;
// remove the FNRc section: it is not used for playback
// and in most cases contains garbage (see the docs...)
delete sty.fnrc;
Writing file
fs.writeFileSync('new-style.sty', sty.dump(), 'binary');
Some useful Style links
- http://wierzba.homepage.t-online.de/stylefiles_v101.pdf
- http://www.jososoft.dk/yamaha/articles/keyboard_and_style.pdf