xxxxxxxxxx
let sound;
let peaks;
let index = 0;
function preload() {
sound = loadSound("01_BeastieBoys_NowGetBusy.mp3");
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
//sound.play();
}
function draw() {
background(100);
peaks = sound.getPeaks(width);
for (let i=0; i<peaks.length; i+=1) {
let peak = map(peaks[i], 0, 1, 0, height/2);
let c = map(peaks[i], 0, 1, 0, 255);
stroke(c);
//stroke(0, c, 100+c);
line(i, 0, i, peak);
//line(i, height, i, height-peak);
//noFill();
//ellipse(i, peak, 5, 5);
// Winkel
/*
push();
let r = map(peaks[i], 0, 1, 0, 0.1);
translate(i, 0);
rotate(r);
line(0, 0, 0, peak);
pop();
*/
//let diameter = map(peaks[i], 0, 1, 2, 20);
//noFill();
//ellipse(i, peak, diameter, diameter);
}
/*
beginShape();
for (let i=0; i<peaks.length; i+=5) {
let peak = map(peaks[i], 0, 1, 0, height/2);
stroke(255);
noFill();
//vertex(i, peak);
curveVertex(i, peak);
}
endShape();
*/
/*
let pos = map(sound.currentTime(), 0, sound.duration(), 0, width);
stroke(255, 0, 100);
line(pos, 0, pos, height);
text(sound.currentTime(), 20, 20);
*/
}