11-09-2012, 08:10 PM
Here is what I have worked out. I haven't really tested it, but should be ok.
Any ideas to make this better?
Function TapTempo
Trigger `
Any ideas to make this better?
Function TapTempo
Trigger `
;;Declare in init2
#compile "__MidiOut"
MidiOut midi.Open(-1)
;;;SETTINGS
double NeededTaps=3
double MinTempo=60
double MaxTempo=187
double WaitMax=(60/MinTempo)*1000
;;SETUP SOME LOGIC
int+ g_InsertKeyTime
int+ Counter
ARRAY(double)+ Clicks
Counter+1
if GetTickCount-g_InsertKeyTime<WaitMax
,Clicks[]=60000/(GetTickCount-g_InsertKeyTime)
,if Counter>=NeededTaps-1
,,for int'i 0 NeededTaps-1
,,,double TotalTime=TotalTime+Clicks[i]
,,double Average=TotalTime/Clicks.len
,,double OSD=(GetTickCount-g_InsertKeyTime)
,,int MIDI=((Average)-MinTempo)*(127/(MaxTempo-MinTempo))
,,if MIDI>127
,,,MIDI=127
,,midi.SendB(0xB0 0 MIDI);;Sends MIDI value to CC0 on channel 1
,,OnScreenDisplay F"BPM: {Average}[]MIDI: {MIDI}" OSD/1000
,,Clicks.remove(0)
else
,Clicks=0
,Counter=0
g_InsertKeyTime=GetTickCount