|
|
|
@ -879,70 +879,6 @@ HuesEditor.prototype.copyXML = function() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function drawWaveform(buffer) { |
|
|
|
|
var ca = document.querySelector("#waveform"); |
|
|
|
|
var c = ca.getContext("2d"); |
|
|
|
|
|
|
|
|
|
var samples = buffer.getChannelData(0); |
|
|
|
|
var width = (buffer.duration * secondWidth) | 0; |
|
|
|
|
|
|
|
|
|
ca.width = width; |
|
|
|
|
ca.height = 128; |
|
|
|
|
|
|
|
|
|
c.strokeStyle = "black"; |
|
|
|
|
|
|
|
|
|
var samplesInColumn = (samples.length / width) | 0; |
|
|
|
|
|
|
|
|
|
// console.log(samplesInColumn)
|
|
|
|
|
|
|
|
|
|
var t, b; |
|
|
|
|
for (var i = 0; i < width; i++) { |
|
|
|
|
var pmin = 999; |
|
|
|
|
var pmax = 0; |
|
|
|
|
|
|
|
|
|
var nmin = 0; |
|
|
|
|
var nmax = -999; |
|
|
|
|
for (var j = 0; j < samplesInColumn; j++) { |
|
|
|
|
var s = samples[i*samplesInColumn+j] |
|
|
|
|
// console.log(s)
|
|
|
|
|
if (s > 0 && s < pmin) { pmin = s;} |
|
|
|
|
else if (s > 0 && s > pmax) { pmax = s;} |
|
|
|
|
|
|
|
|
|
else if (s < 0 && s < nmin) { nmin = s;} |
|
|
|
|
else if (s < 0 && s > nmax) { nmax = s;} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// console.log(pmax, pmin, nmax, nmin)
|
|
|
|
|
var ch = ca.height; |
|
|
|
|
|
|
|
|
|
// t = (pmax) * ch/2
|
|
|
|
|
// b = (2+nmin) * ch/2
|
|
|
|
|
|
|
|
|
|
t = (1-pmax) * ch/2 |
|
|
|
|
b = ch - (1+nmin) * ch/2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c.strokeStyle = "black"; |
|
|
|
|
c.beginPath() |
|
|
|
|
c.moveTo(i, t) |
|
|
|
|
c.lineTo(i, b) |
|
|
|
|
c.stroke(); |
|
|
|
|
|
|
|
|
|
// t = (1-pmax) * ch/2
|
|
|
|
|
// b = ch - (1+nmin) * ch/2
|
|
|
|
|
// c.strokeStyle = "green";
|
|
|
|
|
// c.beginPath()
|
|
|
|
|
// c.moveTo(i, t)
|
|
|
|
|
// c.lineTo(i, b)
|
|
|
|
|
// c.stroke();
|
|
|
|
|
// pixel(c, i, t, [255,0,0,255])
|
|
|
|
|
// pixel(c, i, b, [0,0,255,255])
|
|
|
|
|
// console.log(pmin, nmax)
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
window.HuesEditor = HuesEditor; |
|
|
|
|
|
|
|
|
|