Files
chanora/poc/audio-capture-playback-spike/Cargo.toml
T
EdisonJwa d5b53996bc feat(poc/audio): add audio capture/playback spike (partial — desktop only)
Proof-of-concept addressing the audio exit criterion from
docs/architecture/proof-of-concept-plan.md §2:
  "Capture/playback works on at least one desktop and one mobile
   target."

PARTIAL PASS. The desktop half is verified on Linux; the mobile
half is NOT verified by this PoC and remains a documented open gap.

Implements via cpal (matching DEC-011 'platform-native first'):
  - AudioCapture::record_to_wav opens the default input device,
    handles f32/i16/u16 sample formats, down-mixes to mono, writes
    16-bit PCM WAV via hound.
  - AudioPlayback::play_wav opens the default output device, picks
    a stream config matching the WAV, blocks until drained.
  - synth_sine_wav produces a deterministic 440 Hz test signal for
    headless verification of the playback path when no microphone
    is available.
  - Typed AudioError DTO with NoInputDevice, NoOutputDevice,
    DefaultConfig, BuildStream, PlayStream, Wav, Io,
    UnsupportedFormat arms.

Verified on 2026-05-13 (Linux + cpal + PipeWire). Capture stream
opened against the system default input; build failed against the
auto_null source (typed AudioError::BuildStream returned cleanly,
demonstrating the production error path); fallback to synth fired;
playback drove 24,000 frames to completion through
Rust → cpal → ALSA → pcm_pipewire → PipeWire → auto_null.
Both audio.rs tests pass.

Mobile gap (explicit, NOT closed):
  - Android Oboe path not built or run.
  - iOS AVAudioEngine path not built or run.

Surfaced finding for the decision register: DEC-011 does not pin an
audio crate. The PoC uses cpal; production code needs an owner
ruling, ideally after the mobile spike closes the gap.

Out of scope: DSP (HPF/NS/AEC/AGC), Opus encode/decode, jitter
buffer, mixer, latency measurement, bit-exact loopback, device
permission flows. These belong to chanora_audio.

Authority: PoC plan §2, DEC-011, SysDes audio subsystem.
Not product code; not promoted into chanora_audio.
2026-05-14 12:27:04 +08:00

33 lines
929 B
TOML

[package]
name = "audio-capture-playback-spike"
version = "0.1.0"
edition = "2021"
publish = false
description = "Chanora PoC: cross-platform audio capture + playback round-trip via cpal. Linux desktop verified; mobile path documented but unverified."
# Not product code. See docs/architecture/proof-of-concept-plan.md §4.
# Authority: PoC plan §2, DEC-011 (platform-native first audio), SysDes-013
# (audio subsystem), SRS audio family.
[lib]
name = "audio_capture_playback_spike"
path = "src/lib.rs"
[[bin]]
name = "audio-capture-playback-cli"
path = "src/main.rs"
[dependencies]
# `cpal` is the de facto Rust cross-platform audio crate. It speaks
# WASAPI/CoreAudio/ALSA/PipeWire/Oboe and matches the "platform-native
# first" stance of DEC-011.
cpal = "0.16"
hound = "3"
thiserror = "2"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
anyhow = "1"
[dev-dependencies]
tempfile = "3"