Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Pattern created with audio using minim

$
0
0

Hi. I'm very new to Processing, so I would really appreciate your help on my project. I have been working on a sketch where I use audio as an input to generate a random pattern.


So far I have used noise as a variable, and the only output so far is a ellipse/rectangle shape moving in a random path. I was wondering if you guys knew how I for instance could use a more organic and complex shape as an output, like for instance a tree, or if it is possible to trigger different .svg shapes based on the frequency and the height of the notes.


I realize that this probably is a complex question, but I would be grateful for any help!

My code so far looks like this:


  1. import ddf.minim.*;
  2. Minim minim;
  3. AudioInput input;
  4. float x;
  5. float y;

  6. float t = 0;
  7. int nbLignes = 400;
  8. int i=0;
  9.  
  10. void setup() {
  11.   size(700,700);
  12.   background(160);
  13.   noStroke();
  14.   smooth();
  15.   
  16.   minim = new Minim (this);
  17.   input = minim.getLineIn (Minim.STEREO, 512);
  18. }
  19.  
  20. void draw() {
  21.   float dim = input.mix.level () * width;

  22.   x += input.mix.level () * 100;
  23.   
  24.   float n = noise(t);
  25.   float h = map(n, 0, 1, 0, 500);
  26.   fill(103, 255, 255);
  27.   pushMatrix();
  28.   translate(i*(height/nbLignes), width/2);
  29.   rotate(radians(h));
  30.   ellipse(0, 100-h/2, dim, dim);
  31.   ellipse(0, 100+h/4, dim, dim);
  32.   popMatrix();
  33.   t+=0.01;
  34.   if (i<width) i++;
  35.   else {
  36.     i=0;
  37.   }
  38. }

Viewing all articles
Browse latest Browse all 1768

Trending Articles