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.
|
! 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 continuations formatting fry
|
concurrency.semaphores generalizations kernel math
|
||||||
generalizations io.launcher kernel math sequences threads timers
|
openal.example threads timers ui ui.gadgets ui.gadgets.worlds
|
||||||
ui ui.gadgets ui.gadgets.worlds ui.pens.solid ;
|
ui.pens.solid ;
|
||||||
IN: rosetta-code.metronome
|
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 ;
|
: bpm>duration ( bpm -- duration ) 60 swap / seconds ;
|
||||||
|
|
||||||
: blink-gadget ( gadget freq -- )
|
: blink-gadget ( gadget freq -- )
|
||||||
|
@ -21,9 +16,7 @@ IN: rosetta-code.metronome
|
||||||
COLOR: white <solid> >>interior relayout-1 ;
|
COLOR: white <solid> >>interior relayout-1 ;
|
||||||
|
|
||||||
: play-note ( gadget freq -- )
|
: play-note ( gadget freq -- )
|
||||||
[ dupd blink-gadget ] [ <wave-process> run-detached ] bi
|
[ blink-gadget ] [ 0.3 play-sine blank-gadget ] 2bi ;
|
||||||
[ [ kill-process blank-gadget ] 2curry 300 milliseconds later drop ]
|
|
||||||
[ [ wait-for-process ] ignore-errors drop ] bi ;
|
|
||||||
|
|
||||||
: open-metronome-window ( -- gadget )
|
: open-metronome-window ( -- gadget )
|
||||||
gadget new { 200 200 } >>pref-dim
|
gadget new { 200 200 } >>pref-dim
|
||||||
|
|
Loading…
Reference in New Issue