I have a question regarding accelerometer and sound playback. I have an application which plays a sound when the device is shaken, it plays an mp3 sample which I made, but I want to find a way to be able to increase the intensity of the sound as the device is shaking " harder ". This would require, in my opinion, more than one sample assosicated with it. If you are familiar with the concept of " velocity " you probably know what I mean: when you hit a key harder for example on a midi controller which plays back your sound, not only the volume increases but also other qualities of the sound itself, for example its content in harmonics. Therefore,I would like to know how to achieve this result. Thank you in advance.
Asked
Active
Viewed 184 times
0
-
Accelerometers do measure velocity. The numbers you get from the accelerometer are in direct proportion to how "hard" you are shaking the device. – Robert Harvey Jul 15 '13 at 18:23
-
Yes I understand this but perhaps I need to clarify my concept: how can I associate " harder " shakes to different sound samples? – Nicola Loverre Jul 15 '13 at 18:41
1 Answers
0
As Robert has commented, you can simply look at the change in acceleration (dA/dt = jerk) over a short period of time and if you see a lot of zero-crossings, or large differences, you can assume someone is shaking the device. Now depending on the intensity of this shake you will see larger values in a derivative, indicating how hard the user is shaking.
I however would be careful when this is implemented because what if the user is not shaking the device, we may not want their volume to set to 0, but that can be solved with some simple thresholding.

MZimmerman6
- 8,445
- 10
- 40
- 70
-
-
Just store an array of the past 5 values or something like that, then every time you get a new value push the new one on, and remove the oldest. From this, calculate the difference between consecutive samples (sample based derivative) and there you have the "jerk" value, sum them, see if it exceeds some threshold, if it does, use the value to do what you want. – MZimmerman6 Jul 15 '13 at 20:20
-
Thank you....I am a newbie and I think that this is all far beyond my capabilities but nonetheless now I know what I should concentrate on, study-wise. – Nicola Loverre Jul 15 '13 at 21:16