Skip to content

Commit

Permalink
label()
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Jul 17, 2021
1 parent 9ef8ea2 commit e473f66
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -2281,7 +2281,14 @@
function _smftxt(dd) {
return dd.length ? ': ' + _toLine(JZZ.lib.fromUTF8(dd)) : '';
}
MIDI.prototype.label = function(s) {
this.lbl = this.lbl ? this.lbl + ', ' + s : s;
return this;
};
MIDI.prototype.toString = function() {
return this.lbl ? this._str() + ' (' + this.lbl + ')' : this._str();
};
MIDI.prototype._str = function() {
var s;
var ss;
if (!this.length) {
Expand Down
2 changes: 1 addition & 1 deletion minified/JZZ.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"author": "jazz-soft (https://jazz-soft.net/)",
"dependencies": {
"@types/webmidi": "^2.0.5",
"@types/webmidi": "^2.0.6",
"jazz-midi": "^1.7.5"
},
"devDependencies": {
Expand Down
3 changes: 3 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ describe('MIDI messages', function() {
msg._unstamp();
assert.equal(msg.toString(), 'empty');
});
it('label', function() {
assert.equal(JZZ.MIDI(0x90, 'C#5', 0x7f).label('C#').label('Db').toString(), '90 3d 7f -- Note On (C#, Db)');
});
it('noteOn', function() {
var msg = JZZ.MIDI.noteOn(1, 'C5', 20);
assert.equal(msg.getChannel(), 1);
Expand Down

0 comments on commit e473f66

Please sign in to comment.