Minim Exercise HELP

#1

Hi Everybody!
I’ve just started playing with Minim Library and I’m struggling with an exercise i found here (http://responsivedesign.de/wp-content/uploads/2016/05/tutorial-06_processing-soundmapping2.pdf). In a few words, it transforms audio data (a music file) into graphic animation. Based on that, my goal is to record audio as my input data (which i did somehow) and let the graphics go all the X-axis and descends by steps. I can’t see where im missing so i’d appreciate your help very much.

import ddf.minim.*;

Minim minim;
AudioInput in;

int spacing = 16;
int border = spacing*6;
int amplification = 10;
int y = spacing;
float ySteps;

void setup() {
  size(800,800);
  background(255);
  strokeWeight(1);
  noFill();
  
  minim = new Minim(this);
  in = minim.getLineIn();
}

void draw() {
  int screenSize = int((width-2*border)*(height-1.5*border)/spacing); //seteo bordes
  int x = int(map(in.bufferSize() -1, 0, in.sampleRate(), 0, screenSize));
  
  ySteps = x/(width-2*border);
  x -= (width-2*border)*ySteps;
  
  float frequency = in.mix.get(int(x))*spacing*amplification;
  
  for(int i = 0; i < in.bufferSize() -1; i++) {
    ellipse(x+border, y*ySteps+border, frequency, frequency);
  }
}
1 Like

#2

Do you mean that you want the output to wrap around and move down by a line – like a typewriter or a text box?

Here is a simple example of wrapping cursor logic. It also jumps from the bottom of the page to the top.

/**
 * discourse.processing.org/t/audio-visualization-minim-exercise/9492
 * 2019-03-24  Processing 3.4
 **/

CursorBox point;

void setup() {
  size(400, 400);
  float margin=40;
  point = new CursorBox(margin, margin, width-2*margin, height-2*margin);
  point.step = new PVector(20, 20);
}

void draw() {
  point.render();
  point.advance();
}

class CursorBox {
  PVector cursor;
  PVector step;
  float x;
  float y;
  float w;
  float h;

  CursorBox(float x, float y, float w, float h) {
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    cursor = new PVector(0, 0);
    step = new PVector(10, 10);
  }

  void advance() {
    cursor.x += step.x;
    this.bounds();
  }

  void bounds() {
    if (cursor.x > w) { // carriage return
      cursor.x = 0;
      cursor.y += step.y;
    }
    if (cursor.y > h) {
      cursor.y = 0;
    }
  }

  void render() {
    ellipse(cursor.x + x, cursor.y + y, random(step.x), random(step.y));
  }
}

cursorbox-frame

1 Like

#3

Thanks Jeremy! I’ll re-write my code. I havent found the problem with my sketch but i will i guess

0 Likes

#4

Are you just trying to run sketch_06_01 from the PDF? What specifically is the problem you are having? Do you have an audio file in the sketch folder?

0 Likes

#5

No, my sketch is a variation from the example of the PDF. In my sketch, im trying to move figures down by a line in the x-axis. The frequency values of my audio input(a record source) will affect the figures size as they continue moving by a line and descends by steps in y-axis. I hope i’ve been clear in my answer.

0 Likes

#6

Okay, so your goal is for figures to fall like rain, in y?
Or to move in x+y, like going down stairs?

0 Likes

#7

Yes, the second one. like you said earlier before, i want the output to wrap around and move down by a line — like a typewriter. like Yours example. Its just that i dont know how to apply that skecth into mine :confused:

0 Likes