rosetta-code.metronome: correct disposal of timer
parent
ccf1b82882
commit
d04bf5c10a
|
@ -2,8 +2,8 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
|
||||||
USING: accessors calendar circular colors.constants colors.hsv
|
USING: accessors calendar circular colors.constants colors.hsv
|
||||||
concurrency.semaphores kernel math openal.example threads timers
|
concurrency.semaphores continuations kernel math openal.example
|
||||||
ui ui.gadgets ui.gadgets.worlds ui.pens.solid ;
|
threads timers ui ui.gadgets ui.gadgets.worlds ui.pens.solid ;
|
||||||
IN: rosetta-code.metronome
|
IN: rosetta-code.metronome
|
||||||
|
|
||||||
: bpm>duration ( bpm -- duration ) 60 swap / seconds ;
|
: bpm>duration ( bpm -- duration ) 60 swap / seconds ;
|
||||||
|
@ -32,9 +32,11 @@ IN: rosetta-code.metronome
|
||||||
: start-metronome-timer ( bpm -- timer semaphore )
|
: start-metronome-timer ( bpm -- timer semaphore )
|
||||||
0 <semaphore> [ (start-metronome-timer) ] keep ;
|
0 <semaphore> [ (start-metronome-timer) ] keep ;
|
||||||
|
|
||||||
|
: run-metronome ( semaphore notes -- )
|
||||||
|
[ open-metronome-window ] 2dip <circular> swap metronome-loop ;
|
||||||
|
|
||||||
: metronome ( bpm notes -- )
|
: metronome ( bpm notes -- )
|
||||||
[ start-metronome-timer ] dip
|
[ start-metronome-timer ] dip
|
||||||
[ open-metronome-window ] 2dip <circular> swap metronome-loop
|
[ run-metronome ] curry [ stop-timer ] [ ] cleanup ;
|
||||||
stop-timer ;
|
|
||||||
|
|
||||||
! example usage: 60 { 440 220 330 } metronome
|
! example usage: 60 { 440 220 330 } metronome
|
||||||
|
|
Loading…
Reference in New Issue