rosetta-code.metronome: use openAL to play sound
This brings cross-platform compatibilitydb4
parent
9f58b3ca62
commit
d92741c26f
|
@ -2,16 +2,11 @@
|
|||
! 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 -- )
|
||||
|
@ -21,9 +16,7 @@ IN: rosetta-code.metronome
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue