86 lines
1.9 KiB
Plaintext
86 lines
1.9 KiB
Plaintext
WindowWidth =230
|
|
WindowHeight =220
|
|
|
|
button #w.b1 "Start", [start], LR, 110, 90, 55, 20
|
|
button #w.b2 "Tempo", [tempo], LR, 180, 90, 55, 20
|
|
button #w.b3 "Pattern", [pattern], LR, 40, 90, 55, 20
|
|
|
|
open "Metronome" for graphics_nsb_nf as #w
|
|
|
|
#w "trapclose quit"
|
|
#w "down"
|
|
#w "fill darkblue ; backcolor darkblue ; color white"
|
|
|
|
tempo = 60 ' per minute
|
|
interval =1000 /(tempo /60) ' timer works in ms
|
|
tickCount = 0 ' cycle counter
|
|
running = 1 ' flag for state
|
|
bar$ = "HLLL" ' initially strong-weak-weak-weak
|
|
count = len( bar$)
|
|
|
|
wait
|
|
|
|
sub quit w$
|
|
close #w$
|
|
end
|
|
end sub
|
|
|
|
[start]
|
|
if running =1 then
|
|
running =0
|
|
#w.b1 "Stop"
|
|
#w.b2 "!disable"
|
|
#w.b3 "!disable"
|
|
else
|
|
running =1
|
|
#w.b1 "Start"
|
|
#w.b2 "!enable"
|
|
#w.b3 "!enable"
|
|
end if
|
|
if running =0 then timer interval, [tick] else timer 0
|
|
wait
|
|
|
|
[tempo]
|
|
prompt "New tempo 30...360"; tempo$
|
|
tempo =val( tempo$)
|
|
tempo =min( tempo, 360)
|
|
tempo =max( tempo, 30)
|
|
interval =int( 1000 /(tempo /60))
|
|
wait
|
|
|
|
[pattern]
|
|
prompt "New Pattern, eg 'HLLL' "; bar$
|
|
count =len( bar$)
|
|
if count <2 or count >8 then goto [pattern]
|
|
|
|
wait
|
|
|
|
[tick]
|
|
'beep and flash
|
|
#w "place 115 40"
|
|
|
|
if mid$( bar$, tickCount +1, 1) ="H" then
|
|
playwave "mHi.wav", async
|
|
#w "backcolor blue ; color white ; circlefilled "; 20 -tickCount *2
|
|
else
|
|
playwave "mLo.wav", async
|
|
#w "backcolor cyan ; circlefilled "; 20 -tickCount *2
|
|
end if
|
|
|
|
#w "place 50 140 ; backcolor darkblue ; color white"
|
|
#w "\ "; tempo; " beats /min."
|
|
#w "place 85 160"
|
|
#w "\"; bar$
|
|
|
|
#w "place 85 120"
|
|
#w "\Beat # "; tickCount +1
|
|
|
|
#w "place 115 40"
|
|
#w "color darkblue"
|
|
|
|
tickCount =( tickCount +1) mod count
|
|
|
|
#w "flush"
|
|
|
|
wait
|