From f4d517716aed3abc35df002369363a51f9b5552b Mon Sep 17 00:00:00 2001 From: barkaiavital Date: Thu, 18 Jun 2020 15:19:22 +0200 Subject: [PATCH] Upload files to '12' --- 12/sketch2.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 12/sound.html | 15 +++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 12/sketch2.js create mode 100644 12/sound.html diff --git a/12/sketch2.js b/12/sketch2.js new file mode 100644 index 0000000..fc93d7e --- /dev/null +++ b/12/sketch2.js @@ -0,0 +1,51 @@ +let mic, fft; +let spacer; +let t = 0; // time variable + + +function setup(){ + createCanvas(710, 400); + mic = new p5.AudioIn(); + mic.start(); + fft = new p5.FFT(); + fft.setInput(mic); + noStroke(); + fill(255); +} + + +function draw() { + background(0); + strokeWeight(2); + stroke(255); + //frameRate(10); + + let spectrum = fft.analyze(); + //console.log(spectrum.length); + // console.log(spectrum); + + // beginShape(); + // for (i = 0; i < spectrum.length; i++) { + // vertex(i, map(spectrum[i], 0, 255, height, 0)); + // } + // endShape(); + + beginShape(); + for (x = 0; x < spectrum.length; x= x+5) { + // stroke(255); + //noStroke(); + let alpha = map(spectrum.length, 0,1024,0,100) + strokeWeight(2); + stroke(114,126,143, alpha); + noFill(); + print(alpha) + //fill(255,255,255, alpha); + //console.log(spectrum[x]); + line(width/random(8) ,height/random(8) , spectrum[x]*10, spectrum[x]*8); + //line(random(300,700) ,random(200,300), spectrum[x]*10, spectrum[x]*15); + line(spectrum[x]*8, spectrum[x]*8, spectrum[x]*12, alpha*10); + //rect(600 , 100, spectrum[x]/1.8, spectrum[x]/1.8); + + } + endShape(); +} \ No newline at end of file diff --git a/12/sound.html b/12/sound.html new file mode 100644 index 0000000..3255169 --- /dev/null +++ b/12/sound.html @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file