1 ! Copyright (C) 2008 Alex Chapman
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays kernel namespaces openal sequences synth synth.buffers ;
6 : play-sine-wave ( freq seconds sample-freq -- )
8 <16bit-mono-buffer> >sine-wave-buffer send-buffer id>>
10 [ AL_BUFFER rot set-source-param ] [ source-play ] bi
13 : test-instrument1 ( -- harmonics )
18 4 0.03125 <harmonic> ,
21 : test-instrument2 ( -- harmonics )
29 : sine-instrument ( -- harmonics )
30 1 1 <harmonic> 1array ;
32 : test-note-buffer ( note -- )
34 test-instrument2 swap cd-sample-freq <16bit-mono-buffer>
35 >note send-buffer id>>
36 1 gen-sources first [ swap queue-buffer ] [ source-play ] bi