Browse Source

Fix min/max

Noah 7 years ago
parent
commit
bcbe422be7
1 changed files with 7 additions and 4 deletions
  1. 7 4
      audiogram/waveform.js

+ 7 - 4
audiogram/waveform.js View File

33
     stream.on("error", cb);
33
     stream.on("error", cb);
34
 
34
 
35
     stream.on("end", function(output){
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
       return cb(null, processed);
38
       return cb(null, processed);
38
     });
39
     });
39
 
40
 
60
 
61
 
61
       for (var i = 0, l = pointSamples.length; i < l; i++) {
62
       for (var i = 0, l = pointSamples.length; i < l; i++) {
62
         localMin = Math.min(localMin, pointSamples[i]);
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
       min = Math.min(min, localMin);
67
       min = Math.min(min, localMin);
67
-      max = Math.min(max, localMax);
68
+      max = Math.max(max, localMax);
68
 
69
 
69
       return [localMin, localMax];
70
       return [localMin, localMax];
70
 
71
 
72
 
73
 
73
   });
74
   });
74
 
75
 
76
+  console.log(unadjusted[0]);
77
+
75
   return unadjusted.map(function(frame){
78
   return unadjusted.map(function(frame){
76
     return frame.map(function(point){
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