I’m making a little game for iPhone that involves whistling. The phone hears the frequency of your whistle, and sets the position of a sprite on the screen accordingly. Here is the code:
if frequency > 1000 then
soundbar.y = (frequency-1020)/10+30
end
This makes the bar move between 30 and higher on the y axis, with the highest whistling register being at about y 400, which is fine.
There is only one problem. The higher you whistle, the further down the bar goes. Is there any way I can edit my formula, so that the bar starts at 208, and as the pitch increases, the bar rises?
Thanks 🙂 This has had me stumped for a while!
which simplifies to…
or even…