Genre and p5

So for this assignment, I wanted to play around with the sound library in p5 by visualizing different genres on my bass. I was curious if there was any visible difference between funk and classical or rock and something more harmonic when the notes were given a form. I’m curious to see what happens if I play a p5 sketch before I play the video of me with the bass to see if people can guess what genre this is. Unfortunately, the audio that I got from my Mac speakers is… nothing short of awful. But it’s mostly there to prove that what I am playing is what is occurring in the sketch. The code is at the very bottom of the sketch. 

var song;
var fft;
var button;
var mic;

var volhistory = [];

function toggleSong() {
background(255);
}

function setup() {
createCanvas(400, 400);
mic = new p5.AudioIn();
mic.start();
angleMode(DEGREES);
button = createButton(‘toggle’);
button.mousePressed(toggleSong);
//song.play();
fft = new p5.FFT();
fft.setInput(mic);
}

function draw() {
// background(0);
var spectrum = fft.analyze();
var vol = mic.getLevel();
stroke(random(255), random(255), random(255));
for (var i=0; i var amp = spectrum[i];
var y = map(amp, 0, 256, height, 0);
ellipse(i, y, vol*200, vol*200);
}
// volhistory.push(vol);
stroke(255);
noFill();
}
// translate(width / 2, height / 2);
// beginShape();
// for (var i = 0; i < 360; i++) {
// var r = map(volhistory[i], 0, 1, 10, 100);
// var x = r * cos(i);
// var y = r * sin(i);
// vertex(x, y);
// }
// endShape();

// if (volhistory.length > 360) {
// volhistory.splice(0, 1);
// }
// //ellipse(100, 100, 200, vol * 200);
// }

Leave a Reply

Your email address will not be published. Required fields are marked *