Added thresholds
This commit is contained in:
parent
76c97155ce
commit
41b24dabb2
16
src/index.js
16
src/index.js
|
@ -2,6 +2,7 @@ import p5 from 'p5';
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
|
|
||||||
const FFT_SIZE = 256;
|
const FFT_SIZE = 256;
|
||||||
|
const VOLUME_THRESHOLD = 20;
|
||||||
|
|
||||||
function getRMS(spectrum) {
|
function getRMS(spectrum) {
|
||||||
let rms = 0;
|
let rms = 0;
|
||||||
|
@ -85,12 +86,15 @@ async function main() {
|
||||||
fresh = false;
|
fresh = false;
|
||||||
sketch.background(sketch.color(0, 0, 0));
|
sketch.background(sketch.color(0, 0, 0));
|
||||||
|
|
||||||
bars.push({
|
if (volume > VOLUME_THRESHOLD) {
|
||||||
x: getRandomX(),
|
bars.push({
|
||||||
volume,
|
x: getRandomX(),
|
||||||
pitch,
|
volume,
|
||||||
age: 1,
|
pitch,
|
||||||
});
|
age: 1,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const newBars = [];
|
const newBars = [];
|
||||||
for (const bar of bars) {
|
for (const bar of bars) {
|
||||||
sketch.fill(sketch.color(0, (bar.volume / volumeThreshold) * 255, 255));
|
sketch.fill(sketch.color(0, (bar.volume / volumeThreshold) * 255, 255));
|
||||||
|
|
Loading…
Reference in a new issue