1 ! Copyright (C) 2007 Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: calendar kernel openal openal.alut sequences threads ;
9 first dup AL_BUFFER alutCreateBufferHelloWorld set-source-param
11 1000 milliseconds sleep ;
13 : play-waveform ( waveshape freq phase duration -- )
16 [ 1 gen-sources first dup AL_BUFFER ] 4dip
17 alutCreateBufferWaveform
20 ] [ seconds sleep ] bi ;
22 : play-sine ( freq duration -- )
23 [ ALUT_WAVEFORM_SINE ] 2dip [ 0 ] dip play-waveform ;
25 : (play-file) ( source -- )
26 100 milliseconds sleep
27 dup source-playing? [ (play-file) ] [ drop ] if ;
29 : play-file ( filename -- )
31 create-buffer-from-file
33 first dup [ AL_BUFFER rot set-source-param ] dip
38 : play-wav ( filename -- )
40 create-buffer-from-wav
42 first dup [ AL_BUFFER rot set-source-param ] dip