Processing- 内置音乐与图形交互

Music: Butter-BTS!!!!!!!

代码:

import ddf.minim.analysis.;

import ddf.minim.;

Minim minim;
AudioPlayer butter;
FFT fft;

void setup()
{
size(800, 640, P3D);
minim = new Minim(this);
butter = minim.loadFile("butter.mp3", 4096);
butter.loop();
fft = new FFT( butter.bufferSize(), butter.sampleRate() );
colorMode(HSB, 255, 255,255);
}

void draw()
{
background(255);
stroke(255);
fft.forward( butter.mix );

for(int i = 0; i < fft.specSize( )*0.002; i++)//use i<xx times a number to adjust the degree of density
{
stroke(255);
rect(random(50,800), random(50,640), fft.getBand(i)/200-600, fft.getBand(i)/200-600);//use random to
fill(random(200),fft.getBand(i)+300,240,fft.getBand(i)+100);//high values will result in higher saturation. The fourth number is bu tou ming du.
}
delay(700); //how to let the beat fit?
}

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注