@pencilpix/peaks
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -83,7 +83,7 @@ const { createCanvas, loadImage } = require('canvas') | ||
const { height, peaks } = this | ||
const absmax = 1 | ||
//const absmax = 1 | ||
const hasMinValue = peaks.some(p => p < 0) | ||
// should be used if we need to normalize | ||
// const [min, max, hasMinValue] = $getMaxMin(peaks) | ||
// const absmax = -min > max ? -min : max // normalized max. | ||
const { min, max } = this.getMaxMin(peaks) | ||
const absmax = -min > max ? -min : max // normalized max. | ||
const offsetY = 0 | ||
@@ -120,3 +120,15 @@ const halfH = height / 2 | ||
} | ||
getMaxMin(peaks) { | ||
let min = 0 | ||
let max = 0 | ||
peaks.forEach(peak => { | ||
if (peak < min) min = peak | ||
if (peak > max) max = peak | ||
}) | ||
return { min, max } | ||
} | ||
} | ||
{ | ||
"name": "@pencilpix/peaks", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "nodejs server that accept posting a url of audio file and respond with it's peaks.", | ||
@@ -5,0 +5,0 @@ "main": "Server.js", |
87673
261