2. Recording, Realtime PCM & WAV Decoding
Control recording start/stop, set custom segment durations or 8-hex session IDs, insert RECORD_MARK anchors, and decode 0x00-prefixed 4:1 IMA ADPCM streams into 16 kHz mono WAV in the browser.
ReAI Recording Card SDK Documentation › Recording & Realtime Audio
SDK v0.0.9 (MIT)BLE 5 NUS (Text + 0x00 Binary)Core >= 0.3.0 · Session >= 0.3.8 · Duration >= 0.3.13
Audio Encoding Specification
- Format: 16 kHz / 16-bit / mono PCM compressed via 4-bit IMA ADPCM (~8 KB/s).
- Nibble Order: Low nibble (
byte & 0x0f) is decoded first, followed by high nibble (byte >> 4). - Segment Continuity: Reset
AdpcmDecoderonly at segment start edges; never reset mid-recording.
Code Examples
javascript
await client.setRealtimeEnabled(true);
await client.startRecordingWithDuration(300);
const unsub = client.onAudio((chunk) => {
console.log(`Decoded ${chunk.samples.length} PCM samples`);
});
await client.recordMark();
await client.stopRealtimeRecording();
unsub();rust
use reai_card_sdk::{wav_bytes, SAMPLE_RATE_HZ};
let session = device.start_realtime_recording().await?;
let mut audio = session.subscribe();
let mut samples = Vec::new();
for _ in 0..150 {
samples.extend_from_slice(&audio.recv().await?.samples);
}
session.stop().await?;
std::fs::write("realtime.wav", wav_bytes(&samples, SAMPLE_RATE_HZ))?;Live Web Demo
Web Bluetooth is unavailable in this browser/context (requires Chrome/Edge on HTTPS or localhost). You can still test every API using the Virtual Card Simulator.
Idle
PCM 16 kHz / 16-bit mono: 0 samples (0.00s)
Wire Protocol Log (BLE NUS / HTTP)
Connect a real card or Virtual Card Simulator to inspect live protocol frames.