16.4. Microphone capture and record-to-WAV
Module audio_record
16.4.1. Structures
- AudioDeviceInfo
A capture (microphone) device, as returned by sound_record_list_devices.
- Fields:
name : string - < Human-readable device name.
is_default : bool - < True if this is the system default input device.
index : int - < Index to pass as device_index to sound_record_start / record_to_wav.
16.4.2. Recording
- record_to_wav(fname: string; seconds: float; rate: int = 44100; channels: int = 1; device_index: int = -1 ): bool
Record seconds of audio from the microphone into a 16-bit PCM WAV file. Blocks until done. Returns false (and writes nothing) on invalid arguments, if a recording is already active, if the device fails to open, produces no audio, or stalls mid-capture, or if the WAV cannot be written.
- Arguments:
fname : string
seconds : float
rate : int
channels : int
device_index : int
- sound_record_list_devices(): array<AudioDeviceInfo>
Enumerate available capture (microphone) devices. Pass an entry’s index to sound_record_start / record_to_wav as device_index, or -1 for the system default.