rearrange order of <static-audio-clip> args to be consistent with <streaming-audio-clip> . add a streaming noise generator to audio.engine.test to ensure streaming clips work
parent
5692b17500
commit
90a065e690
|
@ -183,6 +183,7 @@ M: static-audio-clip (update-audio-clip)
|
|||
drop ;
|
||||
|
||||
M:: streaming-audio-clip (update-audio-clip) ( audio-clip -- )
|
||||
"blip" P drop
|
||||
audio-clip al-source>> :> al-source
|
||||
0 c:<uint> :> buffer
|
||||
al-source AL_BUFFERS_PROCESSED get-source-param [
|
||||
|
@ -246,7 +247,7 @@ M: audio-engine dispose*
|
|||
[ [ alcCloseDevice* ] when* f ] change-al-device
|
||||
drop ;
|
||||
|
||||
:: <static-audio-clip> ( audio-engine audio source loop? -- audio-clip/f )
|
||||
:: <static-audio-clip> ( audio-engine source audio loop? -- audio-clip/f )
|
||||
audio-engine get-available-source :> al-source
|
||||
|
||||
al-source [
|
||||
|
@ -274,7 +275,7 @@ M: audio-engine dispose*
|
|||
buffer-count dup (uint-array) [ alGenBuffers ] keep :> al-buffers
|
||||
generator generator-audio-format :> ( channels sample-bits sample-rate )
|
||||
|
||||
audio-clip new-disposable
|
||||
streaming-audio-clip new-disposable
|
||||
audio-engine >>audio-engine
|
||||
source >>source
|
||||
al-source >>al-source
|
||||
|
|
|
@ -1,24 +1,38 @@
|
|||
! (c)2009 Joe Groff bsd license
|
||||
USING: accessors alarms audio audio.engine audio.loader calendar
|
||||
destructors io kernel locals math math.functions ;
|
||||
destructors io kernel locals math math.functions math.ranges specialized-arrays
|
||||
sequences random math.vectors ;
|
||||
FROM: alien.c-types => short ;
|
||||
SPECIALIZED-ARRAY: short
|
||||
IN: audio.engine.test
|
||||
|
||||
TUPLE: noise-generator ;
|
||||
|
||||
M: noise-generator generator-audio-format
|
||||
drop 1 16 8000 ;
|
||||
M: noise-generator generate-audio
|
||||
nip P [ -1 shift [ -4096 4096 [a,b] random ] short-array{ } replicate-as ] keep ;
|
||||
|
||||
:: audio-engine-test ( -- )
|
||||
"vocab:audio/engine/test/loop.aiff" read-audio :> loop-sound
|
||||
"vocab:audio/engine/test/once.wav" read-audio :> once-sound
|
||||
0 :> i!
|
||||
<standard-audio-engine> :> engine
|
||||
engine start-audio*
|
||||
engine loop-sound T{ audio-source f { 1.0 0.0 0.0 } 1.0 { 0.0 0.0 0.0 } f } t
|
||||
|
||||
engine T{ audio-source f { 1.0 0.0 0.0 } 1.0 { 0.0 0.0 0.0 } f } loop-sound t
|
||||
play-static-audio-clip :> loop-clip
|
||||
engine T{ audio-source f { -1.0 0.0 0.0 } 1.0 { 0.0 0.0 0.0 } f } noise-generator new 8192 2
|
||||
play-streaming-audio-clip :> noise-clip
|
||||
|
||||
[
|
||||
i 1 + i!
|
||||
i 0.05 * sin :> s
|
||||
loop-clip source>> { s 0.0 0.0 } >>position drop
|
||||
i 0.05 * [ sin ] [ cos ] bi :> ( s c )
|
||||
loop-clip source>> { c 0.0 s } >>position drop
|
||||
noise-clip source>> { c 0.0 s } -2.0 v*n >>position drop
|
||||
|
||||
i 50 mod zero? [
|
||||
engine once-sound T{ audio-source f { 0.0 0.0 0.0 } 1.0 { 0.0 0.0 0.0 } f } f
|
||||
engine T{ audio-source f { 0.0 0.0 0.0 } 1.0 { 0.0 0.0 0.0 } f } once-sound f
|
||||
play-static-audio-clip drop
|
||||
] when
|
||||
|
||||
|
@ -29,5 +43,4 @@ IN: audio.engine.test
|
|||
alarm cancel-alarm
|
||||
engine dispose ;
|
||||
|
||||
|
||||
MAIN: audio-engine-test
|
||||
|
|
|
@ -78,14 +78,14 @@ CONSTANT: initial-spheres {
|
|||
|
||||
audio-engine world >>listener update-audio
|
||||
|
||||
audio-engine "vocab:gpu/demos/raytrace/mirror-ball.aiff" read-audio
|
||||
spheres first t <static-audio-clip>
|
||||
audio-engine "vocab:gpu/demos/raytrace/red-ball.aiff" read-audio
|
||||
spheres second t <static-audio-clip>
|
||||
audio-engine "vocab:gpu/demos/raytrace/green-ball.aiff" read-audio
|
||||
spheres third t <static-audio-clip>
|
||||
audio-engine "vocab:gpu/demos/raytrace/yellow-ball.aiff" read-audio
|
||||
spheres fourth t <static-audio-clip>
|
||||
audio-engine spheres first
|
||||
"vocab:gpu/demos/raytrace/mirror-ball.aiff" read-audio t <static-audio-clip>
|
||||
audio-engine spheres second
|
||||
"vocab:gpu/demos/raytrace/red-ball.aiff" read-audio t <static-audio-clip>
|
||||
audio-engine spheres third
|
||||
"vocab:gpu/demos/raytrace/green-ball.aiff" read-audio t <static-audio-clip>
|
||||
audio-engine spheres fourth
|
||||
"vocab:gpu/demos/raytrace/yellow-ball.aiff" read-audio t <static-audio-clip>
|
||||
|
||||
4array play-clips ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue