|
@@ -33,7 +33,8 @@ function getWaveform(filename, options, cb) {
|
33
|
33
|
stream.on("error", cb);
|
34
|
34
|
|
35
|
35
|
stream.on("end", function(output){
|
36
|
|
- var processed = processSamples(samples, options.numFrames, options.samplesPerFrame);
|
|
36
|
+ var processed = processSamples(samples, Math.floor(data.duration * options.framesPerSecond), options.samplesPerFrame);
|
|
37
|
+ console.log(processed[0]);
|
37
|
38
|
return cb(null, processed);
|
38
|
39
|
});
|
39
|
40
|
|
|
@@ -60,11 +61,11 @@ function processSamples(samples, numFrames, samplesPerFrame) {
|
60
|
61
|
|
61
|
62
|
for (var i = 0, l = pointSamples.length; i < l; i++) {
|
62
|
63
|
localMin = Math.min(localMin, pointSamples[i]);
|
63
|
|
- localMax = Math.min(localMax, pointSamples[i]);
|
|
64
|
+ localMax = Math.max(localMax, pointSamples[i]);
|
64
|
65
|
}
|
65
|
66
|
|
66
|
67
|
min = Math.min(min, localMin);
|
67
|
|
- max = Math.min(max, localMax);
|
|
68
|
+ max = Math.max(max, localMax);
|
68
|
69
|
|
69
|
70
|
return [localMin, localMax];
|
70
|
71
|
|
|
@@ -72,9 +73,11 @@ function processSamples(samples, numFrames, samplesPerFrame) {
|
72
|
73
|
|
73
|
74
|
});
|
74
|
75
|
|
|
76
|
+ console.log(unadjusted[0]);
|
|
77
|
+
|
75
|
78
|
return unadjusted.map(function(frame){
|
76
|
79
|
return frame.map(function(point){
|
77
|
|
- return [point[0] / min, point[1] / max];
|
|
80
|
+ return [-point[0] / min, point[1] / max];
|
78
|
81
|
});
|
79
|
82
|
});
|
80
|
83
|
|