UNPKG

meyda

Version:

Real-time feature extraction for the web audio api

19 lines (16 loc) 468 B
import { mu } from "./extractorUtilities"; export default function ({ ampSpectrum, }: { ampSpectrum: Float32Array; }): number { if (typeof ampSpectrum !== "object") { throw new TypeError(); } var mu1 = mu(1, ampSpectrum); var mu2 = mu(2, ampSpectrum); var mu3 = mu(3, ampSpectrum); var numerator = 2 * Math.pow(mu1, 3) - 3 * mu1 * mu2 + mu3; var denominator = Math.pow(Math.sqrt(mu2 - Math.pow(mu1, 2)), 3); return numerator / denominator; }