I am attempting to programmatically generate Android vibration patterns with 'micro pulses' on and off to control how strong the vibration feels to the end user. This is the solution I've seen recommended in a few similar topics, to the problem of the API not providing an interface for controlling the vibration strength (because of how the hardware functions, as I understand it).
The algorithm for generating these patterns, however, seems to only be hinted at, but no actual algorithm posted.
What I would like to do is, given an input intensity between 0.0f and 1.0f, generate an array following a pattern something like this:
(zero intensity)
[20,0]
[9,1,9,1]
...
[3,1,3,1,3,1,3,1,3,1]
[2,1,2,1,2,1,2,1,2,1,2,1,2]
(half intensity)
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
[1,2,1,2,1,2,1,2,1,2,1,2,1,1]
[1,3,1,3,1,3,1,3,1,3]
...
[1,9,1,9]
(full intensity)
[0,20]
Any help with writing such an algorithm (or suggestions for a better strategy to meet the same goal)?
Edit: I've added a bounty of 100 reputation to the mix :)