07-08-2012, 06:43 PM
So I need a function for tap tempo and I can figure it out, so I need help.
Variables:
Minimum Tempo
Maximum Tempo
Required Taps
Timeout Length
Flags:
Averaging
Ultimately this function will be sending midi to a soft synth program that will adjust the tempo parameter. So the final "tempo" will be expressed between 0-127 (which will probably be offset in the synth program to affect the tempo between 40bpm and 180bpm)
Function SecondsToMIDI
The number of times the trigger needs to be activated should be variable. (e.g. requires 3 taps to lock in a tempo)
*This is the biggest trouble is getting a function to start with a trigger and then keep track of time between triggering again and the number of times it has been triggered.
There will need to be a timeout length (probably calculated by the slowest tempo), so
An averaging function would be nice
if times to trigger is 4, then keeps track of all times and then on the 4 tap, averages them and uses that value
if the trigger is hit a 5th time, a new value is averaged and output. Same for 6th, 7th, etc until the timeout length is met (i.e. user has stopped hitting the button)
If the averaging function is turned off, the tempo would be calculated between the last two hits and converted to midi.
-jim
Variables:
Minimum Tempo
Maximum Tempo
Required Taps
Timeout Length
Flags:
Averaging
Ultimately this function will be sending midi to a soft synth program that will adjust the tempo parameter. So the final "tempo" will be expressed between 0-127 (which will probably be offset in the synth program to affect the tempo between 40bpm and 180bpm)
Function SecondsToMIDI
double seconds=0.36
double MaxTempo=180
double MinTempo=40
double MaxMIDI=127
double MinMIDI=0
int MIDI=((60/seconds)-MinTempo)*(MaxMIDI/(MaxTempo-MinTempo))
out MIDI
The number of times the trigger needs to be activated should be variable. (e.g. requires 3 taps to lock in a tempo)
*This is the biggest trouble is getting a function to start with a trigger and then keep track of time between triggering again and the number of times it has been triggered.
There will need to be a timeout length (probably calculated by the slowest tempo), so
An averaging function would be nice
if times to trigger is 4, then keeps track of all times and then on the 4 tap, averages them and uses that value
if the trigger is hit a 5th time, a new value is averaged and output. Same for 6th, 7th, etc until the timeout length is met (i.e. user has stopped hitting the button)
If the averaging function is turned off, the tempo would be calculated between the last two hits and converted to midi.
-jim