Paste: how to modify this to play music?
Author: | typemore |
Mode: | factor |
Date: | Tue, 21 Sep 2010 04:41:24 |
Plain Text |
TUPLE: noise-generator ;
M: noise-generator generator-audio-format
drop 1 16 8000 ;
M: noise-generator generate-audio
drop
4096 [ -4096 4096 [a,b] random ] short-array{ } replicate-as
8192 ;
M: noise-generator dispose
drop ;
:: audio-test ( -- )
0 :> i!
f 4 <audio-engine> :> engine
engine start-audio*
engine T{ audio-source f { -1.0 0.0 0.0 } 1.0 { 0.0 0.0 0.0 } f } noise-generator new 2
play-streaming-audio-clip :> noise-clip
[
noise-clip source>>
drop
engine update-audio
] 20 milliseconds every :> timer
"Press Enter to stop the test." print
readln drop
timer stop-timer
engine dispose ;
New Annotation