MinAudio
MinAudio::Capture — the 0.2.0 pull-model ring capture (ma_device with a
data callback appending f32 frames into a FIXED ring of ring_frames
frames; the audio-thread callback never enters Crystal):
cap = MinAudio::Capture.new # 48 kHz mono, 16k ring cap = MinAudio::Capture.new(ring_frames: 8_192) cap.start n = cap.available_frames # UInt64 frames waiting buf = Bytes.new(4800 * 1 * 4) # room for 4800 f32 frames n = cap.read(buf) # frames actually read cap.stop cap.close
read never blocks — call it from the UI frame loop. The ring never grows unbounded: when the app reads slower than the mic delivers, incoming frames that no longer fit are dropped (the buffered timeline keeps its order). Errors raise MinAudio::Error; permission (RECORD_AUDIO on Android, TCC on macOS) is the application's job — without it init fails cleanly.
Constants
Class methods
Raises unless cond — small guard for argument checks.