Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

How to make animation react to sound?

$
0
0

Hi, I'm a music student but we're learning processing and our lecturer wants us to make and animation which reacts to sound.

I'm trying to make an animation which creates spheres. The brightness( cooler colors for loq freq, brighter for high) and the number and size of the spheres increase with amplitude. Can anyone help me with how to go about doing that?

This is my code so far:

int c = 255; float op = random(0, 255);

void setup() { size(960, 500, P3D); background(0); frameRate(25); noStroke(); rectMode(CENTER); }

void draw() { fill(c, random(100));

float sz = random(200); float big = random(1, 200); float placex = random(10, 960); float placey = random(10, 500);

fill(random(255), random(255), random(255)); ellipse(random(width), random(height), sz, sz); noStroke(); lights(); translate(placex, placey); sphere(big);

if (frameCount % 200 == 0) { c = 255 - c; // 255 0 255 0 255 0 .. } saveFrame("frame-####.tif");

if (frameCount > 500) { // 20 seconds * 25 fps = 500 noLoop(); } }


Viewing all articles
Browse latest Browse all 2896

Trending Articles