gizhw:alsa
the Linux backend of gizhw:audio. PCM audio through ALSA (libasound.so.2, loaded at run time, so no build-time link): play and capture 16-bit little-endian interleaved frames on a PCM name ("default", "hw:0,0"). The library's constants are ALSA's (SND_PCM_STREAM_PLAYBACK 0, SND_PCM_STREAM_CAPTURE 1, SND_PCM_FORMAT_S16_LE 2, SND_PCM_ACCESS_RW_INTERLEAVED 3).
import * as Alsa from "gizhw:alsa";Types
Pcm
type PcmAn open PCM: the library's snd_pcm_t pointer, the library, the channel count and the rate.
channels:i64rate:i64
Functions
frameBytes
function frameBytes(channels: i64): i64The bytes of one frame (all channels of one instant).
Effects: fail.
open
function open(sys: System, name: string, capture: bool, rate: i64, channels: i64): Pcm throws stringOpens PCM name for capture or playback at rate Hz with channels channels.
Effects: fail, io.
play
function play(pcm: Pcm, samples: bytes): i64 throws stringPlays samples (whole frames); gives the frames played. An underrun is recovered and the write retried once.
Effects: fail, io.
capture
function capture(pcm: Pcm, frames: i64): bytes throws stringCaptures frames frames; gives the bytes read (whole frames).
Effects: fail, io.
close
function close(pcm: Pcm): voidCloses the PCM.
Effects: fail, io.
cards
function cards(sys: System): Vec<Device.Device> throws IoErrorThe sound cards the sound class has (their devices; the PCM names are on each card).
Effects: fail, io.