{ { $snippet "use-audio-engine?" } " specifies whether the game world should manage an " { $link audio-engine } " instance. False by default." }
{ { $snippet "audio-engine-device" } " specifies the string name of the OpenAL device the audio engine, if any, should try to open. The default value of " { $link POSTPONE: f } " attempts to open the default OpenAL device." }
{ { $snippet "audio-engine-voice-count" } " determines the number of independent voices the audio engine will make available. This determines how many individual audio clips can play simultaneously. This cannot exceed the OpenAL implementation's limit on supported voices." }
-{ { $snippet "audio-engine-buffer-size" } " determines the size in bytes of the audio buffers the audio engine will stream to the sound card." }
-{ { $snippet "audio-engine-buffer-count" } " determines the number of buffers the audio engine will allocate per audio clip played." }
} ;
HELP: game-world
{ use-audio-engine? boolean }
{ audio-engine-device initial: f }
{ audio-engine-voice-count initial: 16 }
- { audio-engine-buffer-size initial: 8192 }
- { audio-engine-buffer-count initial: 2 }
{ tick-slice float initial: 0.0 } ;
GENERIC: begin-game-world ( world -- )
{
[ audio-engine-device>> ]
[ audio-engine-voice-count>> ]
- [ audio-engine-buffer-size>> ]
- [ audio-engine-buffer-count>> ]
} cleave <audio-engine>
[ start-audio* ] keep ; inline
{ use-game-input? boolean initial: f }
{ use-audio-engine? boolean initial: f }
{ audio-engine-device initial: f }
- { audio-engine-voice-count initial: 16 }
- { audio-engine-buffer-size initial: 8192 }
- { audio-engine-buffer-count initial: 2 } ;
+ { audio-engine-voice-count initial: 16 } ;
M: game-world apply-world-attributes
{
[ use-audio-engine?>> >>use-audio-engine? ]
[ audio-engine-device>> >>audio-engine-device ]
[ audio-engine-voice-count>> >>audio-engine-voice-count ]
- [ audio-engine-buffer-size>> >>audio-engine-buffer-size ]
- [ audio-engine-buffer-count>> >>audio-engine-buffer-count ]
[ call-next-method ]
} cleave ;
audio-engine world >>listener update-audio
audio-engine "vocab:gpu/demos/raytrace/mirror-ball.aiff" read-audio
- spheres first t (audio-clip)
+ spheres first t <static-audio-clip>
audio-engine "vocab:gpu/demos/raytrace/red-ball.aiff" read-audio
- spheres second t (audio-clip)
+ spheres second t <static-audio-clip>
audio-engine "vocab:gpu/demos/raytrace/green-ball.aiff" read-audio
- spheres third t (audio-clip)
+ spheres third t <static-audio-clip>
audio-engine "vocab:gpu/demos/raytrace/yellow-ball.aiff" read-audio
- spheres fourth t (audio-clip)
+ spheres fourth t <static-audio-clip>
4array play-clips ;
{ grab-input? t }
{ use-game-input? t }
{ use-audio-engine? t }
- { audio-engine-buffer-count 4 }
{ pref-dim { 1024 768 } }
{ tick-interval-micros $[ 60 fps ] }
} ;