45 lines
843 B
Plaintext
45 lines
843 B
Plaintext
import processing.sound.*;
|
|
|
|
SoundFile soundFile;
|
|
|
|
float tx = 0;
|
|
float ty = 100;
|
|
|
|
void setup() {
|
|
size(500, 500);
|
|
background(0);
|
|
|
|
// Load a sound file
|
|
soundFile = new SoundFile(this, "vibraphon.aiff");
|
|
soundFile.loop();
|
|
noStroke();
|
|
}
|
|
|
|
void draw() {
|
|
fill(0, 10);
|
|
rect(0, 0, width, height);
|
|
// Generate noise values
|
|
float nx = noise(tx);
|
|
float ny = noise(ty);
|
|
|
|
// Map noise values to screen coordinates
|
|
float x = nx * width;
|
|
float y = ny * height;
|
|
|
|
// Draw a circle at the mapped coordinates
|
|
fill(255);
|
|
ellipse(x, y, 50, 50);
|
|
|
|
// Map noise values to sound parameters
|
|
float rate = map(nx, 0, 1, 0.1, 1);
|
|
float amp = map(ny, 0, 1, 0.5, 1);
|
|
|
|
// Set sound parameters based on noise values
|
|
soundFile.rate(rate);
|
|
soundFile.amp(amp);
|
|
|
|
// Increment noise offsets
|
|
tx += 0.003;
|
|
ty += 0.003;
|
|
}
|