xxxxxxxxxx
let n;
let m;
let a;
let b;
let song;
let fft;
let timeFactor = 0;
function preload() {
song = loadSound("N O M I N A L - EVERYDAY ANYONE.mp3");
fft = new p5.FFT();
}
function setup() {
createCanvas(1000, 1000);
noFill();
}
function draw() {
background(0);
strokeWeight(2);
fft.analyze();
let lowFreq = fft.getEnergy("bass");
let highFreq = fft.getEnergy("treble");
let midFreq = fft.getEnergy(400, 2000);
timeFactor += 0.01;
let r = map(sin(timeFactor + lowFreq * 0.1), -1, 1, 50, 255);
let g = map(cos(timeFactor + highFreq * 0.1), -1, 1, 50, 255);
let b = map(sin(timeFactor + midFreq * 0.05), -1, 1, 50, 255); // Mid frekansı burada kullanıyoruz
stroke(r, g, b);
n = map(sin(lowFreq * 0.5), -1, 1, 2, 10);
m = map(sin(highFreq * 0.2), -1, 1, 2, 10);
a = map(sin(midFreq * 0.3), -1, 1, 2, 10); // Mid frekansını burada da kullanıyoruz
b = map(sin(midFreq * 0.3), -1, 1, 2, 10); // Mid frekansını burada da kullanıyoruz
let resolution = 0.004;
for (let x = -1; x <= 1; x += resolution) {
for (let y = -1; y <= 1; y += resolution) {
let value = a * sin(PI * n * x) * sin(PI * m * y) +
b * sin(PI * m * x) * sin(PI * n * y);
if (abs(value) < 0.2) {
let px = map(x, -1, 1, 0, width);
let py = map(y, -1, 1, 0, height);
point(px, py);
}
}
}
}
function mouseClicked() {
if (song.isPlaying()) {
song.pause();
noLoop();
} else {
song.play();
loop();
}
}