I am working on an Android Experiment and I need some help. I want to have a sound play and on movement of the phone, have the sound pitch get higher. (Ex: Move phone up, higher pitch). The sounds will be different depending on the orientation of the device. But how can I have the pitch of the sound get higher or lower depending on the gyro movement / accelerometer movement of the device? Thanks for any help :)
1 Answers
You have to divide your task into two separate objectives. One is how to obtain the reading from your phone; another is to manipulate the sound output. The first task is straightforward. Search online and find a library or native API to read the device orientation.
Changing the sound pitch is more interesting. First you'll need to structure your program so that you have full control over the output stream. This allows you to change the waveform on the fly. Again, pushing bytes to the I/O is the mechanical part. But first think about the physics of sound.
When you play a clip at 2x the speed, the pitch goes twice as high, but the tempo also doubles. Similarly, slowing down the clip brings down the pitch but the clip takes longer to play. This may be what you want, but if you want to retain the tempo but only to change the pitch, you'll have to perform some wave transformation. You may read more about Pitch Scaling.

- 3,855
- 1
- 16
- 29