Skip to content

Commit

Permalink
Gate
Browse files Browse the repository at this point in the history
  • Loading branch information
kwm4385 committed Jul 31, 2019
1 parent 903ed84 commit 6ed8fe7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/TheGlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import Konva from "konva";

import { Rect } from "react-konva";

const NOISE_GATE = 150;
const BUFFER_SIZE = 5;
let buffer = new Uint8Array(BUFFER_SIZE);

const rootMeanSquare = values => {
const quadraticMean = values => {
const squares = values.reduce((acc, val) => acc + Math.pow(val, 2), 0);
return Math.sqrt(squares / values.length);
};

const TheGlow = ({ audioLevel }) => {
const gatedValue = audioLevel >= 150 ? audioLevel : 0;
const gatedValue = audioLevel >= NOISE_GATE ? audioLevel : 0;
buffer = Uint8Array.from([...buffer.slice(1, BUFFER_SIZE), gatedValue]);

const r = rootMeanSquare(buffer);
Expand Down

0 comments on commit 6ed8fe7

Please sign in to comment.