YAPC::EU 2018 Glasgow Update!
This commit is contained in:
parent
22f33d4004
commit
4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions
35
Task/Metronome/Phix/metronome.phix
Normal file
35
Task/Metronome/Phix/metronome.phix
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
integer tempo = 120, -- beats per minute (max 800)
|
||||
measure = 4, -- beats per bar
|
||||
runsecs = 5 -- total run time (rounded up to whole bars)
|
||||
|
||||
integer low_freq = #200, low_duration = 20,
|
||||
high_freq = #400, high_duration = 20
|
||||
|
||||
atom k32=0, xBeep
|
||||
atom t0 = time(), count = 0
|
||||
atom duration = 60/tempo,
|
||||
next = time()+duration
|
||||
|
||||
while time()<t0+runsecs do
|
||||
for j=1 to measure do
|
||||
if platform()=WINDOWS then
|
||||
if k32=0 then
|
||||
k32 = open_dll("kernel32.dll")
|
||||
xBeep = define_c_proc(k32, "Beep", {C_INT,C_INT})
|
||||
end if
|
||||
if j=1 then
|
||||
c_proc(xBeep,{high_freq,high_duration})
|
||||
if count=0 then t0 = time() end if
|
||||
else
|
||||
c_proc(xBeep,{low_freq,low_duration})
|
||||
end if
|
||||
else
|
||||
puts(1,7)
|
||||
end if
|
||||
count += 1
|
||||
puts(1,iff(j=1?"\nH":"L"))
|
||||
sleep(next-time())
|
||||
next += duration
|
||||
end for
|
||||
end while
|
||||
printf(1,"\naverage %f bpm\n",{count*60/(time()-t0)})
|
||||
Loading…
Add table
Add a link
Reference in a new issue