Quantcast
Viewing all articles
Browse latest Browse all 1768

Re : Linking rotation speed to volume of audio input?

I'm confused why you would have more than one variable used for the rotation.
Here's an example I have where the rotation amount increases constantly each frame, but does additional rotation if it detects the mouse has moved horizontally. You should be able to replace that with an amount based on the sound input...

  1. float rot = 0;

  2. void setup(){
  3.   size(220,220);
  4.   noStroke();
  5.   smooth();
  6.   rectMode(CENTER);
  7. }

  8. void draw(){
  9.   
  10.  rot+=.01; // Constant rotation.
  11.  rot+=map( abs(mouseX-pmouseX),0,width,0,1); // Additional rotation.
  12.  rot%=TWO_PI;
  13.  
  14.  background(0); 
  15.  translate(110,110);
  16.  fill(255,0,0);
  17.  rotate( rot );
  18.  rect(0,0,90,90);
  19. }

Viewing all articles
Browse latest Browse all 1768

Trending Articles