We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Animations to music (Read 713 times)
Animations to music
Nov 30th, 2007, 11:59am
 
I'm currently playing around with a visualizer.

I've been having some trouble figuring this one out, so I help someone out there can help me.

The current action I have reacts on mouseclicks, but I want it to react to sound.

I'm using this example to test things out in:
http://www.screamyguy.net/tree/index.htm

I'm using the minim sound library, and getting the audio from the LineIn input.

What I have:
-----------------------------------------
void mouseClicked(){
if (controller.getMouseConsumed() == 0){
 trunk.branch();
 swide*=1.1;
}
}
-----------------------------------------

What I wish worked the way I wanted it to:
-----------------------------------------
void (){
if (beat.isKick(){
 trunk.branch();
 swide*=1.1;
}
}
-----------------------------------------

I cant really get this thing to run the way I want to - and more importantly, the one time I got this thing running, it just kept doing the action. I'd rather like it to work on a peak - and just do the animation once.

Every bit of help is very much appreciated!
Re: Animating to music
Reply #1 - Nov 30th, 2007, 12:28pm
 
Oh, and just for the record, I realize that void() by itself doesn't do much, but the reason I left that one blank is because I have *no* idea what to put there to get this thing to work.
Re: Animations to music
Reply #2 - Dec 1st, 2007, 3:59am
 
There isn't any kind of callback that Minim would be using, if that's what you are wondering. The code you have inside of void () can just go into draw() above your drawing code. It should then work, hopefully as you expect, though I'd have to see more of your code to know for sure.
Re: Animations to music
Reply #3 - Dec 3rd, 2007, 9:18am
 
Thanks for your reply. It worked as it should, and I'm now one step closer to getting it working like it should.

Got things covered - and for people struggling with the same kind of issues, here's a code snippet.

***
void draw(){
 
      noStroke();
      background(255,255,255);
      beat.detect(music.mix);
      fill(0,0,0,.1);
      ellipseMode(CENTER);
      ellipse(width/2,420+5,swide*100,swide*30);
      ellipse(width/2,420+5,swide*80,swide*20);
      ellipseMode(CORNER);
      trunk.render(width/2,420);
   
      if (beat.isSnare()) {
      fullTree(); }
***
Page Index Toggle Pages: 1