Interpretazione grafica della "energia"

// height=260 lines=auto
let sound;
let fft;

function preload() {
    sound = loadSound( 'assets/liszt.mp3' );
}

function setup() {
    createCanvas( 670, 260 );
    colorMode( HSL );
    noFill();
    strokeWeight(3);

    sound.loop();
    fft = new p5.FFT();
}

function draw() {
    background(100);

    let spectrum = fft.analyze();

    let redEnergy = fft.getEnergy("bass");
    let greenEnergy = fft.getEnergy("lowMid");
    let bluEnergy = fft.getEnergy("mid");

    stroke(0,100,50);
    circle( 335, 130, redEnergy);  

    stroke(80,100,45);
    circle( 335, 130, greenEnergy);  

    stroke(200,100,60);
    circle( 335, 130, bluEnergy);  
}

...descrizione codice in preparazione...

Provare a usare il secondo audio presente nella cartella "assets":

sound = loadSound( 'assets/like_analogue.mp3' );

Provare anche a impostare parametri di getEnergy() diversi, fra "bass", "lowMid", "mid", "highMid" e "treble".


Strutturazione dei file: