1 ! Copyright (C) 2008 Alex Chapman
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays kernel namespaces make openal sequences
7 : play-sine-wave ( freq seconds sample-freq -- )
9 <16bit-mono-buffer> >sine-wave-buffer send-buffer id>>
11 [ AL_BUFFER rot set-source-param ] [ source-play ] bi
14 : test-instrument1 ( -- harmonics )
19 4 0.03125 <harmonic> ,
22 : test-instrument2 ( -- harmonics )
30 : sine-instrument ( -- harmonics )
31 1 1 <harmonic> 1array ;
33 : test-note-buffer ( note -- )
35 test-instrument2 swap cd-sample-freq <16bit-mono-buffer>
36 >note send-buffer id>>
37 1 gen-sources first [ swap queue-buffer ] [ source-play ] bi