xxxxxxxxxx
41
//var mic;
var song;
var button;
var amp;
var volhistory = [];
function toggleSong(){
if (song.isPlaying()){
song.pause();
}else{
song.play();
}
}
function preload() {
song = loadSound("rnb.mp3");
}
function setup() {
createCanvas(400, 400);
song.play();
button = createButton ('toggle');
button.mousePressed(toggleSong);
amp = new p5.Amplitude();
}
function draw() {
background(0);
var vol = amp.getLevel();
console.log(vol);
volhistory.push(vol);
stroke(255);
for (var i=0; i<volhistory.length; i++){
var y = map (volhistory[i], 0,1, height,0)
point(i, y);
}
//ellipse(200, 200, 200, vol * 600);
}