Skip to content

Commit

Permalink
Yamaha Chords
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Jul 1, 2021
1 parent 511aeb0 commit 7001ad0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
21 changes: 16 additions & 5 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -2142,14 +2142,14 @@
function _is_yamaha_chord(ff, dd) { return _is_yamaha_smf(ff, dd) && dd.charCodeAt(2) == 1; }
function _yamaha_chord(a, b) {
if (a >= 0 && a <= 0x7f && b >= 0 && b <= 0x7f) {
var c = a & 0xff;
var c = a & 0xf;
var d = a >> 4;
if (c > 0 && c < 8 && d < 7) c = ['C', 'D', 'E', 'F', 'G', 'A', 'B'][c - 1] + ['bbb', 'bb', 'b', '', '#', '##', '###'][d];
else return '-';
if (b > 34) c + '?';
if (b > 34) return c + '?';
else return c + [
'Maj', 'Maj6', 'Maj7', 'Maj7(#11)', 'Maj(9)', 'Maj7(9)', 'Maj6(9)', 'aug', 'min', 'min6', 'min7', 'min7b5',
'min(9)', 'min7(9)', 'min7(11)', 'minMaj7', 'minMaj7(9)', 'dim', 'dim7', '7th', '7sus4', '7b5', '7(9)',
'', '6', 'Maj7', 'Maj7(#11)', '(9)', 'Maj7(9)', '6(9)', 'aug', 'm', 'm6', 'm7', 'm7b5',
'm(9)', 'm7(9)', 'm7(11)', 'm+7', 'm+7(9)', 'dim', 'dim7', '7', '7sus4', '7b5', '7(9)',
'7(#11)', '7(13)', '7(b9)', '7(b13)', '7(#9)', 'Maj7aug', '7aug', '1+8', '1+5', 'sus4', '1+2+5', 'cc'][b];
}
return '-';
Expand Down Expand Up @@ -2311,7 +2311,18 @@
}
else s+= 'invalid';
}
else if (this.ff == 127) s += 'Sequencer Specific' + _smfhex(this.dd);
else if (this.ff == 127) {
if (this.dd.charCodeAt(0) == 0x43) {
if (this.dd.charCodeAt(1) == 0x7b) {
s += '[XF:' + __hex(this.dd.charCodeAt(2)) + ']';
if (this.dd.charCodeAt(1) == 0x7b) {
s += ' Chord: ' + this.getText();
}
return s;
}
}
s += 'Sequencer Specific' + _smfhex(this.dd);
}
else s += 'SMF' + _smfhex(this.dd);
return s;
}
Expand Down
2 changes: 1 addition & 1 deletion minified/JZZ.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,13 @@ describe('SMF events', function() {
assert.equal(JZZ.MIDI.smfSequencer('\x0a\x0b\x0c').toString(), 'ff7f -- Sequencer Specific: 0a 0b 0c');
assert.equal(JZZ.MIDI.smfSequencer([0xa, 0xb, 0xc]).toString(), 'ff7f -- Sequencer Specific: 0a 0b 0c');
});
it('smf/XF Chord', function() {
assert.equal(JZZ.MIDI.smf(0x7f, '\x43\x7b\x01\x33\x0a\x33\x0a').toString(), 'ff7f -- [XF:01] Chord: Em7');
assert.equal(JZZ.MIDI.smf(0x7f, '\x43\x7b\x01\x27\x13\x27\x13').toString(), 'ff7f -- [XF:01] Chord: Bb7');
assert.equal(JZZ.MIDI.smf(0x7f, '\x43\x7b\x01\x26\x00\x27\x13').toString(), 'ff7f -- [XF:01] Chord: Ab');
assert.equal(JZZ.MIDI.smf(0x7f, '\x43\x7b\x01\x44\x23\x44\x23').toString(), 'ff7f -- [XF:01] Chord: F#?');
assert.equal(JZZ.MIDI.smf(0x7f, '\x43\x7b\x01\x00\x00\x00\x00').toString(), 'ff7f -- [XF:01] Chord: -');
});
});

describe('SMPTE', function() {
Expand Down

0 comments on commit 7001ad0

Please sign in to comment.