i’m totally new to coding and p5 - i’ve been messing creating a visualiser from the intro tutorials and grabbing bits and pieces from different tuts.
Basically -
- is there away to rotate all the ellipses/objects on the canvas around a point (so it’s like the canvas has rotated)?
- is there a way for the ellipses to disappear after a set amount of time (10s for example)?
Thanks in advance <3
var song;
function setup() {
// URL copied from the Glitch assets folder
song = loadSound('https://www.zeligsound.com/s/idont.mp3');
createCanvas(512, 512);
background(220);
frameRate(15)
// create a new Amplitude analyzer
analyzer = new p5.Amplitude();
// Patch the input to an volume analyzer
analyzer.setInput(song);
fft = new p5.FFT(0.5,512);
//smoothing, bins
}
function mousePressed() {
if ( song.isPlaying() ) { // .isPlaying() returns a boolean
song.stop();
} else {
song.play();
}
}
function draw() {
let rms = analyzer.getLevel();
//calls amp thing
var spectrum = fft.analyze();
for (var i = 0; i < spectrum.length; i++)
//calls fft thing
{
var amp = spectrum[i];
var y = map(amp, 0, 256, height, 0)
fill(random(255), random(255), random(255),height); // colour of ellipse
ellipse(y+10, random(i+1, i+300), 5 + rms * 150, 5 + rms * 150,); // ellipse
}
}