CAPTURE
Controls sfxlib audio capture where the active backend supports recording.
Syntax
`
result = Capture Start()
Capture Pause
Capture Resume
Capture Stop
status = Capture Status()
frames = Capture Available()
result = Capture Save(filename)
frames = Capture Read(samples, frames)
`
Description
CAPTURE records audio input through the active sfxlib backend when that backend supports recording. It is the input side of the sound library, while commands such as SOUND, MUSIC, and SFX are output commands.
Capture Start begins recording. Capture Pause temporarily stops adding new input without throwing away the capture state. Capture Resume continues after a pause. Capture Stop ends the recording session.
Capture Available reports how many frames can be read. A frame is one moment of audio across the capture channels. Capture Read copies captured samples into a Single buffer supplied by the program. Capture Save writes the buffered recording to a file.
Capture is inherently platform and device dependent. A laptop microphone, a loopback device, and a headless server all behave differently, so programs should check return values and be ready for capture to be unavailable.
Example
`
dim as single samples(0 to 1023)
if capture start() >= 0 then
sleep 500, 1
print "frames available="; capture available()
capture read @samples(0), 512
capture stop
else
print "capture not available"
end if
`
Notes

- Use DEVICE to inspect or select the active output backend; capture support still depends on the backend and platform.
- Capture Read expects a buffer large enough for the requested frames and channels.

See also

- `DEVICE`
- `sfxlib backends`
- `Sound Library Reference`