Using image instead of Processing shape
in
Core Library Questions
•
2 years ago
In this example, a cloud moves when someone blows or speaks into the mic. I want to make the same but with my own image. I got this far but I cannot get the image to move like the cloud does.
Here is the cloud example, my adapted code is below:
- import ddf.minim.*;
- Minim minim;
- AudioInput in;
- PImage p1;
- void setup() {
- size( 500,300 );
- smooth();
- frameRate(25);
- minim = new Minim(this);
- in = minim.getLineIn( Minim.MONO, 512 );
- p1 = loadImage("p1.jpg");
- }
- int pos = 0;
- void draw() {
- background( 128, 128, 255 );
- float m = 0;
- for(int i = 0; i < in.bufferSize() - 1; i++) {
- if ( abs(in.mix.get(i)) > m ) {
- m = abs(in.mix.get(i));
- }
- }
- pos += m * 50;
- dinge( pos, 150, 80 );
- if ( pos > width ) {
- pos = 0;
- }
- }
- void dinge( int x, int y, int w ) {
- image(p1, 150, 80);
- int u = w/6;
- int u15 = int(u * 1.5);
- int u25 = int(u * 2.5);
- }
Does anyone know what I am doing wrong?
2