title: Hand Position Not Updating As Expected - Leap Motion on Processing
body: <p>I'm trying to make a theremin using a Leap Motion controller through Processing (Java). So far, I've come very close. I am able to make the pitch and amplitude change by keeping one hand very still over the controller, while the other moves. I was hoping to make it so that either one hand is able to do that, or the left hand controls amplitude while the right controls pitch.</p>
  
  <p>As it is, you have to keep one hand completely still while the other moves. If you only use one hand, it will only update the tone when the hand fully leaves and reenters the controller's view. I'm wondering if anyone can tell me why this is happening, and what I can do to make it update with the hand's position consistently.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>import processing.sound.*;
  import de.voidplus.leapmotion.*;
  
  LeapMotion leap;
  
  ArrayList&lt;PVector&gt; points; 
  PVector fp;
  
  float freq;
  float amp;
  
  TriOsc tri;
  SinOsc sin;
  SqrOsc sqr;
  SawOsc saw;
  
  void setup () {
  
    size(640,800);
  
    leap = new LeapMotion(this);
    points = new ArrayList&lt;PVector&gt;();
  
    tri = new TriOsc(this);    
    sin = new SinOsc(this);
    sqr = new SqrOsc(this);
    saw = new SawOsc(this);
  
  }
  
  void leapOnInit() {
    // println("Leap Motion Init");
  }
  void leapOnConnect() {
    // println("Leap Motion Connect");
  }
  void leapOnFrame() {
    // println("Leap Motion Frame");
  }
  void leapOnDisconnect() {
    // println("Leap Motion Disconnect");
  }
  void leapOnExit() {
    // println("Leap Motion Exit");
  }
  
  void draw() {
  
    tri.freq(freq);
    tri.amp(amp);
    tri.play();
  
      for (Hand hand : leap.getHands()) {
  
         fp   = hand.getPosition(); 
         if (fp.z &lt;= 30) {
         points = new ArrayList&lt;PVector&gt;();
      }
  
      else if (fp.z &gt; 30) {
         points.add(new PVector(fp.x, fp.y));
      }
    }
  
    for (int i = points.size()-1; i &gt;= 0; i--) {
       PVector p = points.get(i);
       amp = map(width-p.x, 0, width, 1, .01); //Volume based on x-axis
       freq = map(height-p.y, 0, height, 40, 880); //Pitch based on y-axis
    }
  }
  </code></pre>