diff --git a/javascript/JZZ.midi.SMF.js b/javascript/JZZ.midi.SMF.js index 5f7e9c6..41f0da6 100644 --- a/javascript/JZZ.midi.SMF.js +++ b/javascript/JZZ.midi.SMF.js @@ -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]; @@ -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; @@ -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;