Run pre-commit on legacy code
This commit is contained in:
parent
fea11ac752
commit
83b7e4162e
323 changed files with 6126 additions and 6462 deletions
|
@ -49,8 +49,8 @@ var Config = function(params) {
|
|||
|
||||
params = Object.create(params);
|
||||
Object.keys(defaultParams).forEach(function(key) {
|
||||
if (!(key in params)) {
|
||||
params[key] = defaultParams[key];
|
||||
if (!(key in params)) {
|
||||
params[key] = defaultParams[key];
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -122,13 +122,13 @@ var Config = function(params) {
|
|||
fontColor: params.fontColor,
|
||||
fadeColor: params.fadeColor,
|
||||
selectBorderColor: params.selectBorderColor,
|
||||
selectBackgroundColor: params.selectBackgroundColor,
|
||||
selectBackgroundColor: params.selectBackgroundColor,
|
||||
};
|
||||
};
|
||||
|
||||
that.getTrackScroll = function getTrackScroll() {
|
||||
var scroll = params.trackscroll;
|
||||
|
||||
|
||||
return {
|
||||
left: scroll.left,
|
||||
top: scroll.top
|
||||
|
|
35
legacy/public/js/waveformplaylist/controls.js
vendored
35
legacy/public/js/waveformplaylist/controls.js
vendored
|
@ -23,7 +23,7 @@ AudioControls.prototype.events = {
|
|||
"btn_play": {
|
||||
click: "playAudio"
|
||||
},
|
||||
|
||||
|
||||
"btn_stop": {
|
||||
click: "stopAudio"
|
||||
},
|
||||
|
@ -60,7 +60,7 @@ AudioControls.prototype.events = {
|
|||
"btn_open": {
|
||||
click: "open"
|
||||
},
|
||||
|
||||
|
||||
"btn_trim_audio": {
|
||||
click: "trimAudio"
|
||||
},
|
||||
|
@ -151,7 +151,7 @@ AudioControls.prototype.cueToSeconds = function(value) {
|
|||
|
||||
"hh:mm:ss.uuu": function(value) {
|
||||
return clockConverter(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
func = converter[this.timeFormat];
|
||||
|
@ -188,19 +188,19 @@ AudioControls.prototype.cueFormatters = function(format) {
|
|||
},
|
||||
|
||||
"hh:mm:ss": function (seconds) {
|
||||
return clockFormat(seconds, 0);
|
||||
return clockFormat(seconds, 0);
|
||||
},
|
||||
|
||||
"hh:mm:ss.u": function (seconds) {
|
||||
return clockFormat(seconds, 1);
|
||||
return clockFormat(seconds, 1);
|
||||
},
|
||||
|
||||
"hh:mm:ss.uu": function (seconds) {
|
||||
return clockFormat(seconds, 2);
|
||||
return clockFormat(seconds, 2);
|
||||
},
|
||||
|
||||
"hh:mm:ss.uuu": function (seconds) {
|
||||
return clockFormat(seconds, 3);
|
||||
return clockFormat(seconds, 3);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -232,7 +232,7 @@ AudioControls.prototype.init = function(config) {
|
|||
}
|
||||
|
||||
for (className in events) {
|
||||
|
||||
|
||||
tmpEl = container.getElementsByClassName(className)[0];
|
||||
this.ctrls[className] = tmpEl;
|
||||
|
||||
|
@ -243,7 +243,7 @@ AudioControls.prototype.init = function(config) {
|
|||
tmpEl.addEventListener(event, func);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.ctrls["time_format"]) {
|
||||
this.ctrls["time_format"].value = this.config.getTimeFormat();
|
||||
|
@ -458,7 +458,7 @@ AudioControls.prototype.zeroCrossing = function(e) {
|
|||
this.fire('trackedit', {
|
||||
type: "zeroCrossing"
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AudioControls.prototype.trimAudio = function(e) {
|
||||
|
@ -472,7 +472,7 @@ AudioControls.prototype.trimAudio = function(e) {
|
|||
this.fire('trackedit', {
|
||||
type: "trimAudio"
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AudioControls.prototype.removeAudio = function(e) {
|
||||
|
@ -486,7 +486,7 @@ AudioControls.prototype.removeAudio = function(e) {
|
|||
this.fire('trackedit', {
|
||||
type: "removeAudio"
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AudioControls.prototype.createFade = function(e) {
|
||||
|
@ -502,11 +502,11 @@ AudioControls.prototype.createFade = function(e) {
|
|||
this.fire('trackedit', {
|
||||
type: "createFade",
|
||||
args: {
|
||||
type: type,
|
||||
type: type,
|
||||
shape: shape
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AudioControls.prototype.onAudioSelection = function() {
|
||||
|
@ -521,12 +521,12 @@ AudioControls.prototype.onAudioDeselection = function() {
|
|||
start, end in seconds
|
||||
*/
|
||||
AudioControls.prototype.notifySelectionUpdate = function(start, end) {
|
||||
|
||||
|
||||
this.fire('changeselection', {
|
||||
start: start,
|
||||
end: end
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
start, end in seconds
|
||||
|
@ -557,6 +557,5 @@ AudioControls.prototype.onCursorSelection = function(args) {
|
|||
AudioControls.prototype.onAudioUpdate = function(args) {
|
||||
if (this.ctrls["audio_pos"]) {
|
||||
this.ctrls["audio_pos"].innerHTML = this.cueFormatters(this.timeFormat)(args.seconds);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ Curves.createLinearBuffer = function createLinearBuffer(length, rotation) {
|
|||
}
|
||||
else {
|
||||
curve[i] = 1 - x;
|
||||
}
|
||||
}
|
||||
}
|
||||
return curve;
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ Curves.createExponentialBuffer = function createExponentialBuffer(length, rotati
|
|||
for (i = 0; i < length; i++) {
|
||||
x = i / scale;
|
||||
index = rotation > 0 ? i : length - 1 - i;
|
||||
|
||||
|
||||
curve[index] = Math.exp(2 * x - 1) / Math.exp(1);
|
||||
}
|
||||
return curve;
|
||||
|
@ -69,4 +69,3 @@ Curves.createLogarithmicBuffer = function createLogarithmicBuffer(length, base,
|
|||
|
||||
return curve;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var Fades = function() {};
|
||||
|
||||
Fades.prototype.init = function init(sampleRate) {
|
||||
|
||||
this.sampleRate = sampleRate;
|
||||
|
||||
this.sampleRate = sampleRate;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -18,20 +18,20 @@ The duration parameter is the amount of time in seconds (after the time paramete
|
|||
During the time interval: startTime <= t < startTime + duration, values will be calculated:
|
||||
|
||||
v(t) = values[N * (t - startTime) / duration], where N is the length of the values array.
|
||||
|
||||
|
||||
After the end of the curve time interval (t >= startTime + duration), the value will remain constant at the final curve value, until there is another automation event (if any).
|
||||
*/
|
||||
|
||||
|
||||
Fades.prototype.sCurveFadeIn = function sCurveFadeIn(gain, start, duration, options) {
|
||||
var curve;
|
||||
|
||||
|
||||
curve = Curves.createSCurveBuffer(this.sampleRate, (Math.PI/2));
|
||||
gain.setValueCurveAtTime(curve, start, duration);
|
||||
};
|
||||
|
||||
Fades.prototype.sCurveFadeOut = function sCurveFadeOut(gain, start, duration, options) {
|
||||
var curve;
|
||||
|
||||
|
||||
curve = Curves.createSCurveBuffer(this.sampleRate, -(Math.PI/2));
|
||||
gain.setValueCurveAtTime(curve, start, duration);
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ The endTime parameter is the time in the same time coordinate system as AudioCon
|
|||
The value during the time interval T0 <= t < T1 (where T0 is the time of the previous event and T1 is the endTime parameter passed into this method) will be calculated as:
|
||||
|
||||
v(t) = V0 + (V1 - V0) * ((t - T0) / (T1 - T0))
|
||||
|
||||
|
||||
Where V0 is the value at the time T0 and V1 is the value parameter passed into this method.
|
||||
|
||||
If there are no more events after this LinearRampToValue event then for t >= T1, v(t) = V1
|
||||
|
@ -79,7 +79,7 @@ The endTime parameter is the time in the same time coordinate system as AudioCon
|
|||
The value during the time interval T0 <= t < T1 (where T0 is the time of the previous event and T1 is the endTime parameter passed into this method) will be calculated as:
|
||||
|
||||
v(t) = V0 * (V1 / V0) ^ ((t - T0) / (T1 - T0))
|
||||
|
||||
|
||||
Where V0 is the value at the time T0 and V1 is the value parameter passed into this method.
|
||||
|
||||
If there are no more events after this ExponentialRampToValue event then for t >= T1, v(t) = V1
|
||||
|
|
|
@ -12,7 +12,7 @@ BufferLoader.prototype.init = function(params) {
|
|||
loader.loadCount = 0;
|
||||
|
||||
loader.defaultParams = {
|
||||
|
||||
|
||||
};
|
||||
|
||||
loader.params = Object.create(params);
|
||||
|
@ -27,7 +27,7 @@ BufferLoader.prototype.requestBuffer = function(url, name) {
|
|||
|
||||
request.open("GET", url, true);
|
||||
request.responseType = "arraybuffer";
|
||||
|
||||
|
||||
request.onload = function() {
|
||||
loader.context.decodeAudioData(request.response, function(buffer) {
|
||||
if (!buffer) {
|
||||
|
@ -67,12 +67,12 @@ BufferLoader.prototype.loadAudio = function(aUrls, callback) {
|
|||
|
||||
this.urlList = paths;
|
||||
|
||||
var i,
|
||||
var i,
|
||||
length;
|
||||
|
||||
for (i = 0, length = paths.length; i < length; i++) {
|
||||
this.requestBuffer(paths[i], names[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BufferLoader.prototype.onAudioFileLoad = function(name, buffer) {
|
||||
|
|
|
@ -11,7 +11,7 @@ var publisher = {
|
|||
on: function (type, fn, context) {
|
||||
type = type || 'any';
|
||||
fn = typeof fn === "function" ? fn : context[fn];
|
||||
|
||||
|
||||
if (typeof this.subscribers[type] === "undefined") {
|
||||
this.subscribers[type] = [];
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ var publisher = {
|
|||
subscribers = this.subscribers[pubtype],
|
||||
i,
|
||||
max = subscribers ? subscribers.length : 0;
|
||||
|
||||
|
||||
for (i = 0; i < max; i += 1) {
|
||||
if (action === 'publish') {
|
||||
subscribers[i].fn.call(subscribers[i].context, arg);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (subscribers[i].fn === arg && subscribers[i].context === context) {
|
||||
subscribers.splice(i, 1);
|
||||
|
|
|
@ -39,13 +39,13 @@ PlaylistEditor.prototype.init = function(tracks) {
|
|||
}
|
||||
|
||||
this.timeScale = timeScale;
|
||||
|
||||
|
||||
for (i = 0, len = tracks.length; i < len; i++) {
|
||||
|
||||
trackEditor = new TrackEditor();
|
||||
trackEditor.setConfig(this.config);
|
||||
trackElem = trackEditor.loadTrack(tracks[i]);
|
||||
|
||||
|
||||
this.trackEditors.push(trackEditor);
|
||||
fragment.appendChild(trackElem);
|
||||
|
||||
|
@ -73,7 +73,7 @@ PlaylistEditor.prototype.init = function(tracks) {
|
|||
div.onscroll = this.onTrackScroll.bind(that);
|
||||
|
||||
this.sampleRate = this.config.getSampleRate();
|
||||
|
||||
|
||||
this.scrollTimeout = false;
|
||||
|
||||
//for setInterval that's toggled during play/stop.
|
||||
|
@ -89,15 +89,15 @@ PlaylistEditor.prototype.init = function(tracks) {
|
|||
audioControls.on("trimaudio", "onTrimAudio", this);
|
||||
audioControls.on("removeaudio", "onRemoveAudio", this);
|
||||
audioControls.on("changestate", "onStateChange", this);
|
||||
audioControls.on("changeselection", "onSelectionChange", this);
|
||||
audioControls.on("changeselection", "onSelectionChange", this);
|
||||
};
|
||||
|
||||
PlaylistEditor.prototype.removeTrack = function(trackEditor) {
|
||||
var i,
|
||||
len,
|
||||
var i,
|
||||
len,
|
||||
editor,
|
||||
editors = this.trackEditors;
|
||||
|
||||
|
||||
for (i = 0, len = editors.length; i < len; i++) {
|
||||
editor = editors[i];
|
||||
|
||||
|
@ -121,7 +121,7 @@ PlaylistEditor.prototype.onTrimAudio = function() {
|
|||
return;
|
||||
}
|
||||
|
||||
track.trim(selected.start, selected.end);
|
||||
track.trim(selected.start, selected.end);
|
||||
};
|
||||
|
||||
PlaylistEditor.prototype.onRemoveAudio = function() {
|
||||
|
@ -137,7 +137,7 @@ PlaylistEditor.prototype.onRemoveAudio = function() {
|
|||
};
|
||||
|
||||
PlaylistEditor.prototype.onSelectionChange = function(args) {
|
||||
|
||||
|
||||
if (this.activeTrack === undefined) {
|
||||
return;
|
||||
}
|
||||
|
@ -173,11 +173,11 @@ PlaylistEditor.prototype.onTrackScroll = function(e) {
|
|||
|
||||
//limit the scroll firing to every 25ms.
|
||||
that.scrollTimeout = setTimeout(function() {
|
||||
|
||||
|
||||
that.config.setTrackScroll(el.scrollLeft, el.scrollTop);
|
||||
that.fire('trackscroll', e);
|
||||
that.scrollTimeout = false;
|
||||
}, 25);
|
||||
}, 25);
|
||||
};
|
||||
|
||||
PlaylistEditor.prototype.activateTrack = function(trackEditor) {
|
||||
|
@ -201,7 +201,7 @@ PlaylistEditor.prototype.activateTrack = function(trackEditor) {
|
|||
};
|
||||
|
||||
PlaylistEditor.prototype.onSelectUpdate = function(event) {
|
||||
|
||||
|
||||
this.activateTrack(event.editor);
|
||||
};
|
||||
|
||||
|
@ -215,13 +215,13 @@ PlaylistEditor.prototype.onCursorSelection = function(args) {
|
|||
};
|
||||
|
||||
PlaylistEditor.prototype.rewind = function() {
|
||||
|
||||
|
||||
if (this.activeTrack !== undefined) {
|
||||
this.activeTrack.resetCursor();
|
||||
}
|
||||
else {
|
||||
this.resetCursor();
|
||||
}
|
||||
}
|
||||
|
||||
this.stop();
|
||||
};
|
||||
|
@ -304,7 +304,7 @@ PlaylistEditor.prototype.updateEditor = function() {
|
|||
cursorPos = this.config.getCursorPos(),
|
||||
cursorPixel,
|
||||
playbackSec,
|
||||
selected = this.getSelected(),
|
||||
selected = this.getSelected(),
|
||||
start, end,
|
||||
highlighted = false;
|
||||
|
||||
|
@ -319,7 +319,7 @@ PlaylistEditor.prototype.updateEditor = function() {
|
|||
if (elapsed) {
|
||||
playbackSec = cursorPos + elapsed;
|
||||
cursorPixel = Math.ceil(playbackSec * this.sampleRate / res);
|
||||
|
||||
|
||||
for (i = 0, len = editors.length; i < len; i++) {
|
||||
editors[i].updateEditor(cursorPixel, start, end, highlighted);
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ PlaylistEditor.prototype.updateEditor = function() {
|
|||
for (i = 0, len = editors.length; i < len; i++) {
|
||||
editors[i].updateEditor(-1, undefined, undefined, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PlaylistEditor.prototype.getJson = function() {
|
||||
|
@ -376,4 +376,3 @@ PlaylistEditor.prototype.restore = function() {
|
|||
this.trackContainer.innerHTML='';
|
||||
this.init(state);
|
||||
};
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ AudioPlayout.prototype.init = function(config) {
|
|||
|
||||
this.fadeMaker = new Fades();
|
||||
this.fadeMaker.init(this.ac.sampleRate);
|
||||
|
||||
|
||||
this.gainNode = undefined;
|
||||
this.destination = this.ac.destination;
|
||||
};
|
||||
|
@ -80,7 +80,7 @@ AudioPlayout.prototype.loadData = function (audioData, cb) {
|
|||
that.buffer = buffer;
|
||||
cb(buffer);
|
||||
},
|
||||
function(err) {
|
||||
function(err) {
|
||||
console.log("err(decodeAudioData): "+err);
|
||||
cb(null, err);
|
||||
}
|
||||
|
@ -139,8 +139,8 @@ AudioPlayout.prototype.setSource = function(source) {
|
|||
};
|
||||
|
||||
/*
|
||||
source.start is picky when passing the end time.
|
||||
If rounding error causes a number to make the source think
|
||||
source.start is picky when passing the end time.
|
||||
If rounding error causes a number to make the source think
|
||||
it is playing slightly more samples than it has it won't play at all.
|
||||
Unfortunately it doesn't seem to work if you just give it a start time.
|
||||
*/
|
||||
|
@ -151,12 +151,11 @@ AudioPlayout.prototype.play = function(when, start, duration) {
|
|||
}
|
||||
|
||||
this.setSource(this.ac.createBufferSource());
|
||||
|
||||
|
||||
this.source.start(when || 0, start, duration);
|
||||
};
|
||||
|
||||
AudioPlayout.prototype.stop = function(when) {
|
||||
|
||||
|
||||
this.source && this.source.stop(when || 0);
|
||||
};
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ TimeScale.prototype.init = function(config) {
|
|||
if (div === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
canv = document.createElement("canvas");
|
||||
this.canv = canv;
|
||||
this.context = canv.getContext('2d');
|
||||
|
@ -77,7 +77,7 @@ TimeScale.prototype.formatTime = function(seconds) {
|
|||
};
|
||||
|
||||
TimeScale.prototype.clear = function() {
|
||||
|
||||
|
||||
this.container.innerHTML = "";
|
||||
this.context.clearRect(0, 0, this.width, this.height);
|
||||
};
|
||||
|
@ -125,7 +125,7 @@ TimeScale.prototype.drawScale = function(offset) {
|
|||
sTime = this.formatTime(counter);
|
||||
time = document.createTextNode(sTime);
|
||||
div = document.createElement("div");
|
||||
|
||||
|
||||
div.style.left = pix+"px";
|
||||
div.appendChild(time);
|
||||
fragment.appendChild(div);
|
||||
|
@ -145,7 +145,7 @@ TimeScale.prototype.drawScale = function(offset) {
|
|||
cc.fillRect(pix, scaleY, 1, scaleHeight);
|
||||
}
|
||||
|
||||
counter++;
|
||||
counter++;
|
||||
}
|
||||
|
||||
container.appendChild(fragment);
|
||||
|
@ -153,7 +153,7 @@ TimeScale.prototype.drawScale = function(offset) {
|
|||
|
||||
TimeScale.prototype.onTrackScroll = function() {
|
||||
var scroll = this.config.getTrackScroll(),
|
||||
scrollX = scroll.left;
|
||||
scrollX = scroll.left;
|
||||
|
||||
if (scrollX !== this.prevScrollPos) {
|
||||
this.prevScrollPos = scrollX;
|
||||
|
@ -163,8 +163,7 @@ TimeScale.prototype.onTrackScroll = function() {
|
|||
|
||||
TimeScale.prototype.onResolutionChange = function() {
|
||||
var scroll = this.config.getTrackScroll(),
|
||||
scrollX = scroll.left;
|
||||
scrollX = scroll.left;
|
||||
|
||||
this.drawScale(scrollX);
|
||||
};
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ TrackEditor.prototype.init = function(src, start, end, fades, cues, stateConfig)
|
|||
});
|
||||
|
||||
this.enabledStates = statesEnabled;
|
||||
|
||||
|
||||
makePublisher(this);
|
||||
|
||||
this.container = document.createElement("div");
|
||||
|
@ -106,19 +106,19 @@ TrackEditor.prototype.init = function(src, start, end, fades, cues, stateConfig)
|
|||
|
||||
this.fades = {};
|
||||
if (fades !== undefined && fades.length > 0) {
|
||||
|
||||
|
||||
for (var i = 0; i < fades.length; i++) {
|
||||
this.fades[this.getFadeId()] = fades[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (cues.cuein !== undefined) {
|
||||
this.setCuePoints(this.secondsToSamples(cues.cuein), this.secondsToSamples(cues.cueout));
|
||||
}
|
||||
|
||||
|
||||
this.active = false;
|
||||
this.selectedArea = undefined; //selected area of track stored as inclusive buffer indices to the audio buffer.
|
||||
|
||||
|
||||
this.container.classList.add("channel-wrapper");
|
||||
this.container.style.left = this.leftOffset;
|
||||
|
||||
|
@ -146,9 +146,9 @@ TrackEditor.prototype.loadTrack = function(track) {
|
|||
var el;
|
||||
|
||||
el = this.init(
|
||||
track.src,
|
||||
track.start,
|
||||
track.end,
|
||||
track.src,
|
||||
track.start,
|
||||
track.end,
|
||||
track.fades,
|
||||
{
|
||||
cuein: track.cuein,
|
||||
|
@ -185,7 +185,7 @@ TrackEditor.prototype.loadBuffer = function(src) {
|
|||
if (e.lengthComputable) {
|
||||
percentComplete = e.loaded / e.total * 100;
|
||||
that.drawer.updateLoader(percentComplete);
|
||||
}
|
||||
}
|
||||
|
||||
}, false);
|
||||
|
||||
|
@ -236,7 +236,7 @@ TrackEditor.prototype.onTrackLoad = function(buffer, err) {
|
|||
this.config.setResolution(res);
|
||||
this.resolution = res;
|
||||
}
|
||||
|
||||
|
||||
this.drawTrack(buffer);
|
||||
|
||||
if (this.selectedArea !== undefined) {
|
||||
|
@ -294,8 +294,8 @@ TrackEditor.prototype.timeShift = function(e) {
|
|||
e.preventDefault();
|
||||
|
||||
var el = e.currentTarget, //want the events placed on the channel wrapper.
|
||||
startX = e.pageX,
|
||||
diffX = 0,
|
||||
startX = e.pageX,
|
||||
diffX = 0,
|
||||
origX = 0,
|
||||
updatedX = 0,
|
||||
editor = this,
|
||||
|
@ -304,13 +304,13 @@ TrackEditor.prototype.timeShift = function(e) {
|
|||
scrollX = scroll.left;
|
||||
|
||||
origX = editor.leftOffset / res;
|
||||
|
||||
|
||||
//dynamically put an event on the element.
|
||||
el.onmousemove = function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var endX = e.pageX;
|
||||
|
||||
|
||||
diffX = endX - startX;
|
||||
updatedX = origX + diffX;
|
||||
editor.drawer.setTimeShift(updatedX);
|
||||
|
@ -337,7 +337,7 @@ TrackEditor.prototype.timeShift = function(e) {
|
|||
TrackEditor.prototype.notifySelectUpdate = function(startTime, endTime) {
|
||||
|
||||
this.updateEditor(-1, undefined, undefined, true);
|
||||
|
||||
|
||||
this.fire('changecursor', {
|
||||
start: startTime,
|
||||
end: endTime,
|
||||
|
@ -392,7 +392,7 @@ TrackEditor.prototype.adjustSelectedArea = function(start, end) {
|
|||
start, end in pixels
|
||||
*/
|
||||
TrackEditor.prototype.setSelectedArea = function(start, end, shiftKey) {
|
||||
var left,
|
||||
var left,
|
||||
right,
|
||||
currentStart,
|
||||
currentEnd,
|
||||
|
@ -501,7 +501,7 @@ TrackEditor.prototype.selectStart = function(e) {
|
|||
selectStart,
|
||||
selectEnd,
|
||||
startTime, endTime;
|
||||
|
||||
|
||||
if (currentX > startX) {
|
||||
selectStart = startX;
|
||||
selectEnd = currentX;
|
||||
|
@ -534,7 +534,7 @@ TrackEditor.prototype.selectStart = function(e) {
|
|||
maxX = editor.samplesToPixels(offset + editor.selectedArea.end);
|
||||
|
||||
el.onmousemove = el.onmouseup = null;
|
||||
|
||||
|
||||
//if more than one pixel is selected, listen to possible fade events.
|
||||
if (Math.abs(minX - maxX)) {
|
||||
editor.activateAudioSelection();
|
||||
|
@ -547,7 +547,7 @@ TrackEditor.prototype.selectStart = function(e) {
|
|||
endTime = editor.samplesToSeconds(offset + editor.selectedArea.end);
|
||||
|
||||
editor.config.setCursorPos(startTime);
|
||||
editor.notifySelectUpdate(startTime, endTime);
|
||||
editor.notifySelectUpdate(startTime, endTime);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -555,7 +555,7 @@ TrackEditor.prototype.selectCursorPos = function(e) {
|
|||
var editor = this,
|
||||
startX = e.layerX || e.offsetX, //relative to e.target (want the canvas).
|
||||
offset = this.leftOffset,
|
||||
startTime,
|
||||
startTime,
|
||||
endTime,
|
||||
layerOffset;
|
||||
|
||||
|
@ -616,7 +616,7 @@ TrackEditor.prototype.selectFadeOut = function(e) {
|
|||
/* end of state methods */
|
||||
|
||||
TrackEditor.prototype.saveFade = function(id, type, shape, start, end) {
|
||||
|
||||
|
||||
this.fades[id] = {
|
||||
type: type,
|
||||
shape: shape,
|
||||
|
@ -671,7 +671,7 @@ TrackEditor.prototype.setCuePoints = function(cuein, cueout) {
|
|||
start, end are indices into the audio buffer and are inclusive.
|
||||
*/
|
||||
TrackEditor.prototype.trim = function(start, end) {
|
||||
|
||||
|
||||
this.setCuePoints(start, end+1);
|
||||
this.resetCursor();
|
||||
this.drawTrack(this.getBuffer());
|
||||
|
@ -684,7 +684,7 @@ TrackEditor.prototype.trim = function(start, end) {
|
|||
start, end are indices into the audio buffer and are inclusive.
|
||||
*/
|
||||
TrackEditor.prototype.removeAudio = function(start, end) {
|
||||
|
||||
|
||||
};
|
||||
|
||||
TrackEditor.prototype.onTrackEdit = function(event) {
|
||||
|
@ -758,7 +758,7 @@ TrackEditor.prototype.setState = function(state) {
|
|||
|
||||
if (prevState) {
|
||||
prevStateClasses = this.classes[prevState];
|
||||
|
||||
|
||||
if (enabledStates[prevState] === true) {
|
||||
for (event in prevStateEvents) {
|
||||
container.removeEventListener(event, prevStateEvents[event]);
|
||||
|
@ -773,7 +773,7 @@ TrackEditor.prototype.setState = function(state) {
|
|||
for (i = 0, len = disabledClasses.length; i < len; i++) {
|
||||
container.classList.remove(disabledClasses[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (enabledStates[state] === true) {
|
||||
|
@ -803,7 +803,7 @@ TrackEditor.prototype.onResolutionChange = function(res) {
|
|||
this.drawTrack(this.getBuffer());
|
||||
|
||||
if (this.active === true && this.selectedArea !== undefined) {
|
||||
|
||||
|
||||
this.updateEditor(-1, this.samplesToPixels(selected.start), this.samplesToPixels(selected.end), true);
|
||||
}
|
||||
};
|
||||
|
@ -815,7 +815,7 @@ TrackEditor.prototype.isPlaying = function() {
|
|||
/*
|
||||
startTime, endTime in seconds (float).
|
||||
*/
|
||||
TrackEditor.prototype.schedulePlay = function(now, delay, startTime, endTime) {
|
||||
TrackEditor.prototype.schedulePlay = function(now, delay, startTime, endTime) {
|
||||
var start,
|
||||
duration,
|
||||
relPos,
|
||||
|
@ -852,8 +852,8 @@ TrackEditor.prototype.schedulePlay = function(now, delay, startTime, endTime) {
|
|||
};
|
||||
|
||||
TrackEditor.prototype.scheduleStop = function(when) {
|
||||
|
||||
this.playout.stop(when);
|
||||
|
||||
this.playout.stop(when);
|
||||
};
|
||||
|
||||
TrackEditor.prototype.resetCursor = function() {
|
||||
|
@ -865,8 +865,8 @@ TrackEditor.prototype.resetCursor = function() {
|
|||
TrackEditor.prototype.updateEditor = function(cursorPos, start, end, highlighted) {
|
||||
var pixelOffset = this.getPixelOffset(),
|
||||
selected;
|
||||
|
||||
if (this.selectedArea) {
|
||||
|
||||
if (this.selectedArea) {
|
||||
//must pass selected area in pixels.
|
||||
selected = {
|
||||
start: this.samplesToPixels(this.selectedArea.start),
|
||||
|
@ -898,4 +898,3 @@ TrackEditor.prototype.getTrackDetails = function() {
|
|||
|
||||
return d;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ WaveformDrawer.prototype.loaderStates = {
|
|||
"decoding": "progress progress-success progress-striped active",
|
||||
"loader": "bar"
|
||||
},
|
||||
|
||||
|
||||
"jQueryUI": {
|
||||
"downloading": "ui-progressbar ui-widget ui-widget-content ui-corner-all",
|
||||
"decoding": "ui-progressbar ui-widget ui-widget-content ui-corner-all",
|
||||
|
@ -43,7 +43,7 @@ WaveformDrawer.prototype.loaderStates = {
|
|||
};
|
||||
|
||||
WaveformDrawer.prototype.getPeaks = function(buffer, cues) {
|
||||
|
||||
|
||||
// Frames per pixel
|
||||
var res = this.config.getResolution(),
|
||||
peaks = [],
|
||||
|
@ -53,16 +53,16 @@ WaveformDrawer.prototype.getPeaks = function(buffer, cues) {
|
|||
numChan = buffer.numberOfChannels,
|
||||
weight = 1 / (numChan),
|
||||
makeMono = this.config.isDisplayMono(),
|
||||
chan,
|
||||
start,
|
||||
end,
|
||||
vals,
|
||||
max,
|
||||
chan,
|
||||
start,
|
||||
end,
|
||||
vals,
|
||||
max,
|
||||
min,
|
||||
maxPeak = -Infinity; //used to scale the waveform on the canvas.
|
||||
|
||||
for (i = 0; i < pixels; i++) {
|
||||
|
||||
|
||||
peaks[i] = [];
|
||||
|
||||
for (c = 0; c < numChan; c++) {
|
||||
|
@ -87,13 +87,13 @@ WaveformDrawer.prototype.getPeaks = function(buffer, cues) {
|
|||
peaks[i].push({max:max, min:min});
|
||||
maxPeak = Math.max.apply(Math, [maxPeak, Math.abs(max), Math.abs(min)]);
|
||||
}
|
||||
|
||||
|
||||
if (makeMono) {
|
||||
max = min = 0;
|
||||
|
||||
for (c = 0 ; c < numChan; c++) {
|
||||
max = max + weight * peaks[i][c].max;
|
||||
min = min + weight * peaks[i][c].min;
|
||||
min = min + weight * peaks[i][c].min;
|
||||
}
|
||||
|
||||
peaks[i] = []; //need to clear out old stuff (maybe we should keep it for toggling views?).
|
||||
|
@ -110,7 +110,7 @@ WaveformDrawer.prototype.setTimeShift = function(pixels) {
|
|||
|
||||
for (i = 0, len = this.channels.length; i < len; i++) {
|
||||
this.channels[i].div.style.left = pixels+"px";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
WaveformDrawer.prototype.updateLoader = function(percent) {
|
||||
|
@ -129,7 +129,7 @@ WaveformDrawer.prototype.drawLoading = function() {
|
|||
|
||||
div = document.createElement("div");
|
||||
div.style.height = this.height+"px";
|
||||
|
||||
|
||||
loader = document.createElement("div");
|
||||
loader.style.height = "10px";
|
||||
loader.className = this.loaderStates["loader"];
|
||||
|
@ -156,10 +156,10 @@ WaveformDrawer.prototype.drawBuffer = function(buffer, pixelOffset, cues) {
|
|||
numChan = makeMono? 1 : buffer.numberOfChannels,
|
||||
numSamples = cues.cueout - cues.cuein + 1,
|
||||
fragment = document.createDocumentFragment(),
|
||||
wrapperHeight;
|
||||
wrapperHeight;
|
||||
|
||||
this.container.innerHTML = "";
|
||||
this.channels = [];
|
||||
this.channels = [];
|
||||
|
||||
//width and height is per waveform canvas.
|
||||
this.width = Math.ceil(numSamples / res);
|
||||
|
@ -190,11 +190,11 @@ WaveformDrawer.prototype.drawBuffer = function(buffer, pixelOffset, cues) {
|
|||
|
||||
top = top + this.height;
|
||||
}
|
||||
|
||||
|
||||
wrapperHeight = numChan * this.height;
|
||||
this.container.style.height = wrapperHeight+"px";
|
||||
this.container.appendChild(fragment);
|
||||
|
||||
|
||||
|
||||
this.getPeaks(buffer, cues);
|
||||
this.updateEditor();
|
||||
|
@ -217,11 +217,11 @@ WaveformDrawer.prototype.drawFrame = function(chanNum, index, peaks, maxPeak, cu
|
|||
h = Math.ceil(max - min);
|
||||
|
||||
//to prevent blank space when there is basically silence in the track.
|
||||
h = h === 0 ? 1 : h;
|
||||
h = h === 0 ? 1 : h;
|
||||
|
||||
if (cursorPos >= (x + pixelOffset)) {
|
||||
cc.fillStyle = colors.progressColor;
|
||||
}
|
||||
}
|
||||
else {
|
||||
cc.fillStyle = colors.waveColor;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ WaveformDrawer.prototype.draw = function(cursorPos, pixelOffset, start, end) {
|
|||
|
||||
if (i < 0 && len < 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < 0) {
|
||||
i = 0;
|
||||
|
@ -251,13 +251,13 @@ WaveformDrawer.prototype.draw = function(cursorPos, pixelOffset, start, end) {
|
|||
}
|
||||
|
||||
this.clear(i, len);
|
||||
|
||||
|
||||
for (; i < len; i++) {
|
||||
|
||||
peaks[i].forEach(function(peak, chanNum) {
|
||||
that.drawFrame(chanNum, i, peak, that.maxPeak, cursorPos, pixelOffset);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -285,7 +285,7 @@ WaveformDrawer.prototype.updateEditor = function(cursorPos, pixelOffset, start,
|
|||
this.drawHighlight(selected.start, selected.end, border);
|
||||
}
|
||||
|
||||
for (i = 0, len = this.channels.length; i < len; i++) {
|
||||
for (i = 0, len = this.channels.length; i < len; i++) {
|
||||
fragment.appendChild(this.channels[i].div);
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ WaveformDrawer.prototype.sCurveFadeIn = function sCurveFadeIn(ctx, width) {
|
|||
};
|
||||
|
||||
WaveformDrawer.prototype.sCurveFadeOut = function sCurveFadeOut(ctx, width) {
|
||||
return Curves.createSCurveBuffer(width, -(Math.PI/2));
|
||||
return Curves.createSCurveBuffer(width, -(Math.PI/2));
|
||||
};
|
||||
|
||||
WaveformDrawer.prototype.logarithmicFadeIn = function logarithmicFadeIn(ctx, width) {
|
||||
|
@ -324,7 +324,7 @@ WaveformDrawer.prototype.logarithmicFadeIn = function logarithmicFadeIn(ctx, wid
|
|||
};
|
||||
|
||||
WaveformDrawer.prototype.logarithmicFadeOut = function logarithmicFadeOut(ctx, width) {
|
||||
return Curves.createLogarithmicBuffer(width, 10, -1);
|
||||
return Curves.createLogarithmicBuffer(width, 10, -1);
|
||||
};
|
||||
|
||||
WaveformDrawer.prototype.exponentialFadeIn = function exponentialFadeIn(ctx, width) {
|
||||
|
@ -332,7 +332,7 @@ WaveformDrawer.prototype.exponentialFadeIn = function exponentialFadeIn(ctx, wid
|
|||
};
|
||||
|
||||
WaveformDrawer.prototype.exponentialFadeOut = function exponentialFadeOut(ctx, width) {
|
||||
return Curves.createExponentialBuffer(width, -1);
|
||||
return Curves.createExponentialBuffer(width, -1);
|
||||
};
|
||||
|
||||
WaveformDrawer.prototype.linearFadeIn = function linearFadeIn(ctx, width) {
|
||||
|
@ -340,7 +340,7 @@ WaveformDrawer.prototype.linearFadeIn = function linearFadeIn(ctx, width) {
|
|||
};
|
||||
|
||||
WaveformDrawer.prototype.linearFadeOut = function linearFadeOut(ctx, width) {
|
||||
return Curves.createLinearBuffer(width, -1);
|
||||
return Curves.createLinearBuffer(width, -1);
|
||||
};
|
||||
|
||||
WaveformDrawer.prototype.drawFadeCurve = function(ctx, shape, type, width) {
|
||||
|
@ -380,7 +380,7 @@ WaveformDrawer.prototype.removeFade = function(id) {
|
|||
for (i = len-1; i >= 0; i--) {
|
||||
el = els[i];
|
||||
el.parentNode.removeChild(el);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -397,7 +397,7 @@ WaveformDrawer.prototype.drawFade = function(id, type, shape, start, end) {
|
|||
|
||||
if ((end - start) === 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
width = ~~(end - start + 1);
|
||||
left = start;
|
||||
|
@ -418,8 +418,8 @@ WaveformDrawer.prototype.drawFade = function(id, type, shape, start, end) {
|
|||
this.drawFadeCurve(ctx, shape, type, width);
|
||||
|
||||
div.appendChild(canv);
|
||||
fragment.appendChild(div);
|
||||
|
||||
fragment.appendChild(div);
|
||||
|
||||
for (i = 0, len = this.channels.length; i < len; i++) {
|
||||
dup = fragment.cloneNode(true);
|
||||
tmpCtx = dup.querySelector('canvas').getContext('2d');
|
||||
|
@ -447,4 +447,3 @@ WaveformDrawer.prototype.drawFades = function(fades) {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue