Change shape by sound input

Hey, after my first problem get solved here, I hope someone can help me again. :slight_smile:
I want the shape (as you can hopefully see on the picture) is changing by sound input. When the sound is loud, the shape should be bigger and in a different color as if the sound is quieter. The inner circle is constantly in the same position. Just the outer circle should change the size.

This is my code so far:

float scale = 1;

int shapelength = 12;

int iterations = 22;

import ddf.minim.*;

Minim minim;
AudioInput in;



float[][][] shape_coords = new float[2][shapelength][2];



void setup() {

  size(3840, 2160);

  background (255, 48, 48);
  
  minim = new Minim(this);
  
  in = minim.getLineIn(); // Audio Input



// inner circle

  shape_coords[1][0][0] = 1500 * scale;

  shape_coords[1][0][1] = 1495 * scale;

  shape_coords[1][1][0] = 1500 * scale;

  shape_coords[1][1][1] = 1495 * scale;

  shape_coords[1][2][0] = 1500 * scale;

  shape_coords[1][2][1] = 1495 * scale;

  shape_coords[1][3][0] = 1500 * scale;

  shape_coords[1][3][1] = 1495 * scale;

  shape_coords[1][4][0] = 1500 * scale;

  shape_coords[1][4][1] = 1495 * scale;

  shape_coords[1][5][0] = 1500 * scale;

  shape_coords[1][5][1] = 1495 * scale;

  shape_coords[1][6][0] = 1500 * scale;

  shape_coords[1][6][1] = 1495 * scale;
    
  shape_coords[1][7][0] = 1500 * scale;

  shape_coords[1][7][1] = 1495 * scale;

  shape_coords[1][8][0] = 1500 * scale;

  shape_coords[1][8][1] = 1495 * scale;

  shape_coords[1][9][0] = 1500 * scale;

  shape_coords[1][9][1] = 1495 * scale;

  shape_coords[1][10][0] = 1500 * scale;

  shape_coords[1][10][1] = 1495 * scale;

  shape_coords[1][11][0] = 1500 * scale;

  shape_coords[1][11][1] = 1495 * scale;






// outer circle

  shape_coords[0][0][0] = 1520 * scale;

  shape_coords[0][0][1] = 485 * scale;

  shape_coords[0][1][0] = 2020 * scale;

  shape_coords[0][1][1] = 1150 * scale;

  shape_coords[0][2][0] = 2535 * scale;

  shape_coords[0][2][1] = 775 * scale;

  shape_coords[0][3][0] = 2880 * scale;

  shape_coords[0][3][1] = 1130 * scale;

  shape_coords[0][4][0] = 3100 * scale;

  shape_coords[0][4][1] = 1633 * scale;

  shape_coords[0][5][0] = 2720 * scale;

  shape_coords[0][5][1] = 1770 * scale;

  shape_coords[0][6][0] = 2170 * scale;

  shape_coords[0][6][1] = 1275 * scale;

  shape_coords[0][7][0] = 1365 * scale;

  shape_coords[0][7][1] = 1760 * scale;

  shape_coords[0][8][0] = 725 * scale;

  shape_coords[0][8][1] = 1160 * scale;

  shape_coords[0][9][0] = 1520 * scale;

  shape_coords[0][9][1] = 485 * scale;

  shape_coords[0][10][0] = 2020 * scale;

  shape_coords[0][10][1] = 1150 * scale;

  shape_coords[0][11][0] = 2535 * scale;

  shape_coords[0][11][1] = 1150 * scale;

}



void draw() {

  
  strokeWeight (2);

 //shaping
 

  for (int j = 0; j < iterations; j++) {

    
    stroke (118, 138, 0);
    noFill();

    beginShape();

    for (int i = 0; i < shapelength; i++) {

      curveVertex(lerp(shape_coords[0][i][0], shape_coords[1][i][0], float(j)/float(iterations)), lerp(shape_coords[0][i][1], shape_coords[1][i][1], float(j)/float(iterations)));

    }

    endShape();

  }

}

Thanks a lot for any help!

1 Like

I learned that I am no longer allowed to give you the code but here is a nice quote from the guidelines:

Have fun.

Hint: There already is a scale-factor, maybee use that? Be careful tho since it applies to both shapes.

Thanks. I just want to finish this project, after I will need processing never again. As I said in my first question, I need to understand the code by myself, so I don’t just copy and paste it. I have no idea how to start and build a working code by my own. A whole code is also a help like just a hint. Sometimes the better help. And I think it’s everybodys own business, if he or she just copy a code or try to understand it. :slight_smile:

You need to look into some examples provided by the minim library. Any basic example will show you how you can get the amplitude from your input signal via your mic.

Then you need to associate the value of scale to the amplitude read by minim. This is done in setup.

The third thing you need to do is to move your points definitions into draw so they get updated every time scale is updated.

Kf

Thanks for your help. I tried my best but can’t fix my problem. Are there any other tips or examples you can give?

Hi,
how far did you get?
Are you able to get the input volume as a number? If so try to print it with println(); and upload your code so we can help you go further.

Hey, my code doesn’t change. Everything I tried doesn’t work. :frowning:

You may want to try using the getVolume() method of AudioInput. So: in.getVolume() will return a value – this value can then be used to scale a shape, or change the number of iterations in a loop.

http://code.compartmental.net/minim/audioinput_method_getvolume.html