Next: , Previous: , Up: API Reference   [Contents][Index]


3.10 Sound

(use-modules (sdl2 mixer))
Scheme Variable: %default-frequency
Scheme Variable: %default-format
Scheme Variable: %default-chunk-size
Procedure: mixer-init [#:optional formats='(flac mod modplug mp3 ogg fluidsynth)]

Initialize mixer library with support for formats, a list of symbols representing audio file formats. Possible formats are:

Procedure: mixer-quit

Shutdown mixer library.

Procedure: open-audio [#:frequency=%default-frequency] [#:format=%default-format] [#:stereo?=#t] [#:chunk-size=%default-chunk-size]

Initialize the mixer API. frequency specificies the sample rate in hertz. When stereo? is #t, two output channels are used, otherwise mono output is used instead. chunk-size specifies the number of bytes used per output sample. format is a symbol that specifies the output sample format. Possible values are:

Procedure: close-audio

Shut down the mixer API.

Procedure: chunk? c

Return #t if c is a chunk.

Procedure: load-chunk file

Load the audio data in file and return an audio chunk.

Procedure: delete-chunk! chunk

Free the memory used for chunk.

Procedure: set-chunk-volume! chunk volume

Set the loudness of chunk to volume, an integer in the range [0,128]. Return the previous chunk volume setting.

Procedure: play-chunk! chunk [#:loops=0] [#:channel]

Play chunk on channel, an integer channel identifier or #f to use the first unreserved audio channel. chunk will play loops + 1 times. Return the channel identifier that chunk is played on.

Procedure: set-channel-volume! channel volume

Set the loudness of channel, an integer channel identifier or #f for all channels, to volume, an integer in the range [0,128]. Return the previous volume of channel, or the average of all channels if channel is #f.

Procedure: pause-channel! channel

Pause playback on channel, an integer channel identifier, or #f to pause all channels.

Procedure: resume-channel! channel

Resume playback on channel, an integer channel identifier, or #f to resume all channels.

Procedure: stop-channel! channel

Halt playback on channel, an integer channel identifier, or #f to halt all channels.

Procedure: channel-playing? channel

Return #t if channel is playing.

Procedure: playing-channels-count

Return the number of channels currently playing.

Procedure: channel-paused? channel

Return #t if channel is paused.

Procedure: paused-channels-count

Return the number of channels that are paused.

Procedure: music? m

Return #t if m is music.

Procedure: load-music file

Load music from file.

Procedure: delete-music! music

Delete the memory used for music.

Procedure: play-music! music [#:optional loops=1]

Play music, repeated loops times. loops may be #f, in which case the music loops indefinitely.

Procedure: set-music-volume! volume

Set music loudness to volume, an integer in the range [0,128]. Return the previous volume.

Procedure: music-volume

Return the music volume.

Procedure: pause-music!

Puase the music.

Procedure: resume-music!

Resume music playback.

Procedure: rewind-music!

Start music playback from the beginning. Rewinding is only supported for MOD, OGG, MP3, and native MIDI music.

Procedure: stop-music!

Halt music playback.

Procedure: music-playing?

Return #t if music is currently playing.

Procedure: music-paused?

Return #t if music is currently paused.


Next: , Previous: , Up: API Reference   [Contents][Index]