Pike v8.1 release 6

Method SDL.open_audio()


Method open_audio

void open_audio(int frequency, int format, int channels, int bufsize)

Description

Initializes the audio API.

Throws an exception if audio can't be initialized.

Parameter frequency

Output sampling frequency, measured in samples per second (Hz). A value of 44100 provides CD-quality playback. A less CPU-intensive value for games is 22050.

Parameter format

Output sample format. One of the following constants:

SDL.AUDIO_U8

Unsigned 8-bit samples.

SDL.AUDIO_S8

Signed 8-bit samples.

SDL.AUDIO_U16LSB

Unsigned 16-bit samples in little-endian byte order.

SDL.AUDIO_S16LSB

Signed 16-bit samples in little-endian byte order.

SDL.AUDIO_U16MSB

Unsigned 16-bit samples in big-endian byte order.

SDL.AUDIO_S16MSB

Signed 16-bit samples in big-endian byte order.

SDL.AUDIO_U16

Same as SDL.AUDIO_U16LSB.

SDL.AUDIO_S16

Same as SDL.AUDIO_S16LSB.

SDL.AUDIO_U16SYS

Unsigned 16-bit samples in system byte order.

SDL.AUDIO_S16SYS

Signed 16-bit samples in system byte order. If in doubt, try this one first.

Parameter channels

Number of sound channels in output: 1 for mono, 2 for stereo.

Parameter bufsize

How many bytes to use per output sample. 1024 is a typical value for games. If just playing music you might set this to 4096 or higher.