我正在为我正在做的项目编写这个脚本,我对目前的帧速率不满意。它在FPS周围蹦蹦跳跳,我需要至少30个,所以我可以在视频安装中进一步使用它而不会延迟。
由于我的数学很糟糕,而且我不太明白原来的其他人是怎么做数学的,所以我无法弄清楚冗余代码的位置。 我一直在努力工作一整天没有结果。
如果您需要原始的.aif或svg,请使用Holler。
我认为你可以用任何类型的音轨替代,因为我可以收集的是这些计算单独运行。
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
Minim minim;
AudioPlayer data1;
AudioPlayer data2;
AudioPlayer data3;
AudioPlayer data4;
/* OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/6598*@* */
/* !do not delete the line above, required for linking your tweak if you upload again */
float grid[][][];
PGraphics boundary;
int page = 0;
int sides = 3;
float w = PI/10;
PShape world;
public void setup() {
size(1920, 1080, FX2D);
//fullScreen(FX2D, 0);
frameRate(30);
grid = new float[2][width-1][height-1];
boundary = createGraphics(width, height);
world = loadShape("world.svg");
makeBoundary(sides);
loadPixels();
minim = new Minim (this);
data1 = minim.loadFile ("indo.aif");
data1.loop();
data1.play();
data2 = minim.loadFile ("chile.aif");
data2.loop();
data2.play();
data3 = minim.loadFile ("fuku.aif");
data3.loop();
data3.play();
data4 = minim.loadFile ("samoa.aif");
data4.loop();
data4.play();
}
void makeBoundary(int sides) {
for (int i=0; i<width-1; i++) {
for (int j=0; j<height-1; j++) {
grid[page][i][j] = 0;
grid[page^1][i][j] = 0;
}
}
boundary.beginDraw();
boundary.background(0);
boundary.fill(255);
boundary.shape(world, 0, 0, 1860, 1020);
boundary.endDraw();
}
public void draw() {
println(frameRate);
float thresh = map(mouseX, 0, width, 0, 255);
oscillator(data1, 380, 700, 32); // Indonesian Wellenquelle
oscillator(data2, 1470, 780, 32);
oscillator(data3, 570, 400, 32);
oscillator(data4, 700, 750, 32);
for (int i=1; i<width-2; i++) {
for (int j=1; j<height-2; j++) {
int wa = boundary.pixels[i+width*j];
float dx = (wa == 0xffffffff) ? 0: (grid[page][i-1][j] + grid[page][i+1][j]);
float dy = (wa == 0xffffffff) ? 0: (grid[page][i][j-1] + grid[page][i][j+1]);
float value = (dx+dy )/2 - grid[page^1][i][j] ;
grid[page^1][i][j] = value * 0.992;
int val = (int) (abs(value) * 512);
val = val > 255 ? 255 : val;
pixels[i+j*width] = 0xFF000000 | val << 16 | val << 8 | val;
}
}
page ^= 1;
updatePixels();
fill(0);
ellipse(380, 700, 64, 64);
ellipse(1470, 780, 64, 64);
ellipse( 570, 400, 64, 64);
ellipse(700, 750, 64, 64);
}
public void oscillator(AudioPlayer data, int x, int y, int r) {
//grid[page][cx][cy] = sou.mix.level() * 60; // Zahl ändert Anzahl von Kreisen/Wellen
//w += PI/16;
int r2 = r * r;
int area = r2 << 2;
int rr = r << 1;
for (int i = 0; i < area; i++)
{
int tx = (i % rr) - r;
int ty = (i / rr) - r;
if (tx * tx + ty * ty <= r2)
grid[page][x + tx][y + ty] = data.mix.level() * 30;
//SetPixel(x + tx, y + ty, c);
}
}
public void mousePressed() {
makeBoundary(++sides);
}
public void keyPressed() {
if (key == ' ') {
sides = 3;
makeBoundary(sides);
}
//saveFrame();
}