Next: , Up: Audio   [Contents][Index]


5.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 sample.

Procedure: load-audio file-name [#:mode static]

Load audio within file-name. The following file formats are currently supported:

Audio files can be loaded in two different ways, as indicated by mode:

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

Return #t if obj is an audio object.

Procedure: streaming-audio? audio

Return #t if audio uses stream loading.

Procedure: static-audio?

Return #t if audio uses static loading.

Procedure: audio-mode audio

Return the loading mode for audio, either static or stream.

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? #f]

Play audio. There are many, many knobs to tweak that will affect the sound that comes out of the player’s speakers.:

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 and pitch.


Next: , Up: Audio   [Contents][Index]