Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tap Tempo.
#4
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 `     Help - how to add the trigger to the macro
Code:
Copy      Help
;;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


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)