I’ve got a graph mapping the amplitude of a song (titled AYNIL.mp3 in the code) but I want it to travel in a spiral starting from the center rather than along the canvas width. (so it creates this weird spiral made of amplitude peaks). Anyone know how?
var song;
var amp;
var button;
var volhistory = [];
function toggleSong() {
if (song.isPlaying()) {
song.pause();
} else {
song.play();
}
}
function preload() {
song = loadSound('AYNIL.mp3');
}
function setup() {
createCanvas(400, 400);
button = createButton('Play/Pause');
button.mousePressed(toggleSong);
song.play();
background(0);
amp = new p5.Amplitude();
}
function draw() {
background(0);
var vol = amp.getLevel();
if (song.isPlaying()) {
volhistory.push(vol);
beginShape();
}
for (var i = 0; i < volhistory.length; i = i + 5) {
var y = map(volhistory[i], 0, 0.5, height, 0);
stroke(255);
noFill();
vertex(i, y);
}
endShape();
}