I'm working on a sound related project using a leap to control the sound. I have successfully managed to have the sound fade out when the leap input leaves the edges of the project window, e.g.:
if( hp.x < -400 ) //if hand position(x) is less than or equal to -400...
{
amp = 0; //... then volume is 0%
}
else if( hp.x < 0 ) //if hand position(x) is less than 0...
{
amp = map( hp.x, 0, -400, 1, 0.01 ); //... then posx between 0 & -400 changes volume between 100 - 0%
}
This snippet of example code fades the volume down to 0 as the leap motion leaves the sketch to the left of the sketch. However, this doesn't help when there is no leap motion location detected (for example when the sketch begins), or if the leap motions location leaves the project window so fast that the last known location was inside of it.
I'm very new to processing, and this seems like a really simple one, but how on earth do I set the project volume (amp) to be at 0 when the project first starts, and ideally also if no leap motion position is detected
Many thanks,
D.