-
Notifications
You must be signed in to change notification settings - Fork 2
feat(lambda-rs): Implement a SoundBuffer with support for decoding wav and ogg files.
#167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Coverage Report📊 View Full HTML Report (download artifact) Overall Coverage
Changed Files in This PR
PR Files Coverage: 80.66% (1735/2151 lines) Generated by cargo-llvm-cov · Latest main coverage Last updated: 2026-02-04 21:52:43 UTC · Commit: |
…eed new separate demo crates long term)
…Will fix in a later PR).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements sound file loading capabilities for the lambda-rs engine by adding a SoundBuffer type that can decode WAV and OGG Vorbis audio files. The implementation uses the Symphonia library wrapped in lambda-rs-platform to keep vendor details out of the public API, following the established pattern for audio device support.
Changes:
- Adds
SoundBufferwith methods to load WAV and OGG Vorbis files from disk or memory - Implements Symphonia wrapper in
lambda-rs-platformwith granular feature flags (audio-decode-wav,audio-decode-vorbis) - Adds comprehensive error handling through
AudioErrorvariants for decode failures - Includes test audio fixtures (WAV: mono/stereo, 16/24/32-bit; OGG: Vorbis stereo) stored via Git LFS
- Adds examples (
sound_buffer_load,play_slash_sound) and alambda_audioCLI tool for testing - Updates documentation including specs and feature guides
Reviewed changes
Copilot reviewed 35 out of 36 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
crates/lambda-rs/src/audio/buffer.rs |
Implements public SoundBuffer API with WAV and OGG Vorbis loading methods |
crates/lambda-rs/src/audio/error.rs |
Extends AudioError with I/O, decode, and format error variants |
crates/lambda-rs/src/audio/mod.rs |
Restructures audio module to include buffer alongside device APIs |
crates/lambda-rs/src/audio/devices/output.rs |
Refactors output device code with additional documentation |
crates/lambda-rs/Cargo.toml |
Adds granular audio-sound-buffer feature flags |
crates/lambda-rs-platform/src/audio/symphonia/mod.rs |
Implements Symphonia wrapper with format validation and error mapping |
crates/lambda-rs-platform/src/audio/cpal/ |
Moves cpal module under audio/ for better organization |
crates/lambda-rs-platform/Cargo.toml |
Adds Symphonia dependency with minimal feature set |
tools/lambda_audio/ |
New CLI tool for inspecting and playing audio files |
crates/lambda-rs/examples/ |
Adds sound_buffer_load.rs and play_slash_sound.rs examples |
docs/specs/audio-file-loading.md |
Comprehensive specification for the SoundBuffer feature |
docs/specs/audio-devices.md |
Updates device spec with new module paths and error variants |
docs/features.md |
Documents new audio decode features |
.github/workflows/ |
Updates CI to handle audio dependencies and tool exclusions |
.gitattributes |
Adds LFS tracking for audio files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Related Issues
Changes
Add Symphonia wrapper in
lambda-rs-platformfor WAV and OGG Vorbis decodingaudio-decode-wav,audio-decode-vorbis,audio-sound-buffer)AudioError) with decode-specific variantssound_buffer_loadexample demonstrating the loading APIplay_slash_soundexample demonstrating playback integrationlambda_audiotool for testing audio loading and playbackdocs/features.mdwith new audio feature documentationdocs/specs/audio-file-loading.mdspecificationType of Change
Affected Crates
lambda-rslambda-rs-platformlambda-rs-argslambda-rs-loggingtools/lambda_audioChecklist
cargo +nightly fmt --all)cargo clippy --workspace --all-targets -- -D warnings)cargo test --workspace)Testing
Commands run:
Manual verification steps (if applicable):
play_slash_soundexamplelambda_audiotool can load and play audio filesScreenshots/Recordings
Platform Testing
Additional Notes
Feature Flag Structure
The new audio features follow the existing feature flag patterns:
lambda-rs:
audio-sound-buffer-wav- WAV file loadingaudio-sound-buffer-vorbis- OGG Vorbis loadingaudio-sound-buffer- Umbrella for all sound buffer featuresaudio- Updated umbrella including output device and sound bufferlambda-rs-platform:
audio-decode-wav- Symphonia WAV decoderaudio-decode-vorbis- Symphonia Vorbis decoderSupported Formats
WAV:
OGG Vorbis:
API Design
The
SoundBuffertype provides:samples()- Access to interleaved f32 PCM datasample_rate()- Audio sample ratechannels()- Number of audio channelsduration_seconds()- Computed durationframe_count()- Number of audio framesAll decoding errors are mapped to
AudioErrorvariants without exposing Symphonia internals.