UNPKG

meyda

Version:

Real-time feature extraction for the web audio api

19 lines (16 loc) 402 B
'use strict'; function rms (_a) { var signal = _a.signal; // Keeping this bad runtime typecheck for consistency if (typeof signal !== "object") { throw new TypeError(); } var rms = 0; for (var i = 0; i < signal.length; i++) { rms += Math.pow(signal[i], 2); } rms = rms / signal.length; rms = Math.sqrt(rms); return rms; } module.exports = rms;