Skip to content

Commit

Permalink
Dump CASM -- in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Jun 3, 2023
1 parent 69b2e1d commit 019bc77
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ require(['JZZ', 'JZZ.midi.SMF', 'JZZ.midi.STY'], function(JZZ, dummy1, dummy2) {
```js
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
// data can be String, Buffer, ArrayBuffer, Uint8Array, Int8Array,
// or a JZZ.MIDI.SMF object
var sty = new JZZ.MIDI.STY(data);
```

Expand All @@ -91,6 +92,7 @@ console.log('All style tracks:', sty.tracks());
// '', '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');
```

## Some useful Style links
Expand Down
22 changes: 21 additions & 1 deletion javascript/JZZ.midi.STY.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
}
t = tt;
}
//if (this.casm) smf.push(new JZZ.MIDI.SMF.Chunk('CASM', _dumpCASM(this.casm)));
if (this.casm) smf.push(new JZZ.MIDI.SMF.Chunk('CASM', _dumpCASM(this.casm)));
if (this.otsc) smf.push(new JZZ.MIDI.SMF.Chunk('OTSc', _dumpOTSc(this.otsc)));
if (this.fnrc) smf.push(new JZZ.MIDI.SMF.Chunk('FNRc', _dumpFNRc(this.fnrc)));
if (this.mhhd) smf.push(new JZZ.MIDI.SMF.Chunk('MHhd', this.mhhd));
Expand Down Expand Up @@ -177,7 +177,15 @@
return casm;
}
function _dumpCASM(casm) {
var i, j, s, x;
var dump = '';
for (i = 0; i < casm.length; i++) {
x = casm[i];
s = _pack('Sdec', x.sdec);
if (x.ctab) for (j = 0; j < x.ctab.length; j++) s += _pack('Ctab', _dumpCtab(x.ctab[j]));
if (x.ctb2) for (j = 0; j < x.ctb2.length; j++) s += _pack('Ctb2', _dumpCtab(x.ctb2[j]));
dump += _pack('CSEG', s);
}
return dump;
}
function _splitCSEG(s) {
Expand Down Expand Up @@ -221,6 +229,10 @@
ctb.chord = [s.charCodeAt(18), s.charCodeAt(19)];
return ctb;
}
function _dumpCtb(ctb) {
var dump = '';
return dump;
}
function _splitCtab(s) {
var ctb = _splitCtb(s);
ctb.ctab = true;
Expand All @@ -236,6 +248,10 @@
}
return ctb;
}
function _dumpCtab(ctab) {
var dump = _dumpCtb(ctab);
return dump;
}
function _splitCtb2(s) {
var ctb = _splitCtb(s);
ctb.ctb2 = true;
Expand Down Expand Up @@ -263,6 +279,10 @@
for (var i = 40; i < s.length; i++) ctb.extra.push(s.charCodeAt(i));
return ctb;
}
function _dumpCtb2(ctb2) {
var dump = _dumpCtb(ctb2);
return dump;
}
function _splitCntt(s) {
var cntt = {};
cntt.src = s.charCodeAt(0);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"jzz-midi-smf": "^1.7.6"
},
"devDependencies": {
"eslint": "^8.41.0",
"eslint": "^8.42.0",
"grunt": "^1.6.1",
"grunt-contrib-jshint": "^3.2.0",
"grunt-contrib-uglify": "^5.2.2",
Expand Down

0 comments on commit 019bc77

Please sign in to comment.