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

Want the minim sketch to follow or trace after mouse

$
0
0

Hello.

I would like to have the centerX and Y to move after the mouse with a small delay. Not be fixed as it is now. This movement is independent of the sound file. I have tried to insert an if statement that worked in an earlier project. I am new to processing so appreciate the help much.

Will need a sound file and Minim library. first post on forum, so not sure how to add a sound file.

import ddf.minim.*;
import ddf.minim.signals.*;
Minim minim;
AudioPlayer mySound;
int n=0;

float centerX, centerY;
float[] x = new float[n];
float[] y = new float[n];
float s = 0.005;
float depth = 0.5;
int startTime;

void setup(){
  size(displayWidth, displayHeight, P3D);
  noStroke();
  rectMode(CENTER);
  minim = new Minim(this);
  mySound = minim.loadFile("leonard.mp3");  //or any sound file
  mySound.play();
}

void draw(){
  background(255);
  translate(width/3,height/3);

  if (mouseX != 0 || mouseY != 0) {
    centerX += (mouseX-centerX) * 0.01;
    centerY += (mouseY-centerY) * 0.01;
  }

for(int i = 0; i < mySound.bufferSize() - 1; i++)  {
    rotateX(n*-PI/7*0.01);
    rotateY(n*-PI/7*0.01);
    rotateZ(n*-PI/7*0.01);
    fill(0);
    ellipse(i,i,mySound.left.get(i)*70,mySound.left.get(i)*50);
  }
  n++;
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles