var volume = 0
var pitch = 0
var context = new AudioContext()
var o = context.createOscillator()
var g = context.createGain()
o.connect(g)
g.connect(context.destination)
g.gain.value = 0.0
o.start(0)
Leap.loop(function(frame) {
frame.hands.forEach(function(hand, index) {
if (hand.type == "left")
{
volume = -1 *hand.screenPosition()[1] / 200.0
g.gain.value = volume
}
else {
pitch = hand.screenPosition()[2]
o.frequency.value = pitch/2.0+440
}
});
}).use('screenPosition');