2.4.1 Audio Files
Sound data is represented by a special
<audio> data type that
stores not only the audio samples themselves, but metadata such as
sample rate, number of channels, and how many bits are used for each
- Procedure: load-audio file-name [#:mode
Load audio within file-name. The following file formats are
Audio files can be loaded in two different ways, as indicated by
Load the entire audio file into memory.
Load chunks of the audio file as needed.
Generally speaking, sound effects don’t take up much space and should
be loaded statically, but music files are much larger and should use
streaming. Static loading is the default.
- Procedure: audio? obj
#t if obj is an audio object.
- Procedure: streaming-audio? audio
#t if audio uses stream loading.
- Procedure: static-audio?
#t if audio uses static loading.
- Procedure: audio-mode audio
Return the loading mode for audio, either
- Procedure: audio-duration audio
Return the duration of audio in seconds.
- Procedure: audio-bits-per-sample audio
Return the number of bits per sample in audio.
- Procedure: audio-channels audio
Return the number of channels in audio.
- Procedure: audio-sample-rate audio
Return the sample rate of audio.
- Procedure: audio-play audio [#:pitch 1.0] [#:volume 1.0] [#:min-volume 0.0] [#:max-volume 1.0] [#:max-distance] [#:reference-distance 0.0] [#:rolloff-factor 1.0] [#:cone-outer-volume 0.0] [#:cone-inner-angle 0.0] [#:cone-outer-angle] [#:position
(vec3 0.0 0.0 0.0)] [#:velocity
(vec3 0.0 0.0 0.0)] [#:direction
(vec3 0.0 0.0 0.0)] [#:relative?
Play audio. There are many, many knobs to tweak that will
affect the sound that comes out of the player’s speakers.:
Pitch multiplier. The default value of 1.0 means no change in pitch.
Volume multiplier. The default value of 1.0 means no change in volume.
Used with the inverse clamped distance model (the default model) to
set the distance where there will no longer be any attenuation of the
The distance where the volume for the audio would drop by half (before
being influenced by the rolloff factor or maximum distance.)
For slowing down or speeding up the rate of attenuation. The default
of 1.0 means no attenuation adjustment is made.
The volume when outside the oriented cone.
Inner angle of the sound cone, in radians. The default value is 0.
Outer angle of the sound cone, in radians. The default value is 2pi
radians, or 360 degrees.
The source of the sound emitter in 3D space.
The velocity of the sound emitter in 3D space.
The direction of the sound emitter in 3D space.
A flag that determines whether the position is in absolute coordinates
or relative to the listener’s location. Absolute coordinates are used
For games with basic sound needs (that is to say they don’t need 3D
sound modeling), the only things that really matter are volume