Skip to content

Commit

Permalink
ClipHdr.add()
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Mar 29, 2024
1 parent a50cd02 commit 9faace2
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions javascript/JZZ.midi.SMF.js
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@
var arr = _ump(msg);
var self = this;
if (this.length) e = this._orig[this._orig.length - 1];
if (!e.isEndClip()) e = undefined;
if (e && !e.isEndClip()) e = undefined;
if (e && e.tt < t) e.tt = t;
for (i = 0; i < arr.length; i++) {
msg = arr[i];
Expand All @@ -1377,7 +1377,7 @@
continue;
}
msg.tt = t;
for (j = 0; j < this._orig.length - 1; j++) if (this._orig[j].tt > t) break;
for (j = 0; j < this._orig.length; j++) if (this._orig[j].tt > t || this._orig[j] == e) break;
this._orig.splice(j, 0, msg);
}
return self;
Expand Down Expand Up @@ -1421,18 +1421,7 @@
ClipHdr.prototype.gr = Clip.prototype.gr;
ClipHdr.prototype.ch = Clip.prototype.ch;
ClipHdr.prototype.sxId = Clip.prototype.sxId;
ClipHdr.prototype.add = function(t, msg) {
t = parseInt(t);
if(isNaN(t) || t < 0) _error('Invalid parameter');
msg = JZZ.UMP(msg);
if (msg.isStartClip() || msg.isEndClip()) return this;
if (msg.isDelta()) return this.tick(msg.getDelta());
msg.tt = t;
var i;
for (i = 0; i < this._orig.length; i++) if (this._orig[i].tt > t) break;
this._orig.splice(i, 0, msg);
return this;
};
ClipHdr.prototype.add = Clip.prototype.add;

function _copyClip(clip, x) {
var i, m;
Expand Down

0 comments on commit 9faace2

Please sign in to comment.