sound.open

sound

open(opts) -> dev, err

Open a PCM playback device

Opens /dev/snd/pcmC<card>D<device>p, negotiates hardware/software parameters, and prepares the stream.

Playback auto-starts once the ring buffer fills. While the device is open it is held exclusively — there is no dmix, so other programs cannot play through it.

opts fielddefaultdescription
card0ALSA card number
device0PCM device number
rate48000sample rate, Hz
channels2channel count
period1024frames per period (latency granularity)
periods4periods in the ring buffer
format"auto""auto" picks float if the card accepts it, else s16; or force "f32"/"s16"

The device object has the following methods:

MethodDescription
dev:fd()TBD...
dev:period()
dev:channels()
dev:rate()
dev:format()
dev:avail()
dev:write(buf)
dev:recover()
dev:start()
dev:drop()
dev:close()