! See http://factorcode.org/license.txt for BSD license.
USING: accessors calendar circular colors.constants colors.hsv
-concurrency.semaphores continuations formatting fry
-generalizations io.launcher kernel math sequences threads timers
-ui ui.gadgets ui.gadgets.worlds ui.pens.solid ;
+concurrency.semaphores generalizations kernel math
+openal.example threads timers ui ui.gadgets ui.gadgets.worlds
+ui.pens.solid ;
IN: rosetta-code.metronome
-! linux alsa..
-! For debian, in package alsa-utils
-: <wave-process> ( freq -- process )
- "speaker-test -t sine -f %d -p 20000" sprintf ;
-
: bpm>duration ( bpm -- duration ) 60 swap / seconds ;
: blink-gadget ( gadget freq -- )
COLOR: white <solid> >>interior relayout-1 ;
: play-note ( gadget freq -- )
- [ dupd blink-gadget ] [ <wave-process> run-detached ] bi
- [ [ kill-process blank-gadget ] 2curry 300 milliseconds later drop ]
- [ [ wait-for-process ] ignore-errors drop ] bi ;
+ [ blink-gadget ] [ 0.3 play-sine blank-gadget ] 2bi ;
: open-metronome-window ( -- gadget )
gadget new { 200 200 } >>pref-dim