Skip to content

Commit 3260ec0

Browse files
committed
[update] specifications to matc implementation.
1 parent 6a5fd40 commit 3260ec0

File tree

2 files changed

+85
-54
lines changed

2 files changed

+85
-54
lines changed

docs/specs/audio-devices.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: "Audio Device Abstraction"
33
document_id: "audio-device-abstraction-2026-01-28"
44
status: "draft"
55
created: "2026-01-28T22:59:00Z"
6-
last_updated: "2026-01-31T22:33:14Z"
7-
version: "0.1.16"
6+
last_updated: "2026-02-02T22:57:02Z"
7+
version: "0.1.17"
88
engine_workspace_version: "2023.1.30"
99
wgpu_version: "26.0.1"
1010
shader_backend_default: "naga"
1111
winit_version: "0.29.10"
12-
repo_commit: "1aaa56a242939572b6ec08eda82364c16a85e59a"
12+
repo_commit: "6a5fd409c8097665ffd6e6a4a976206320ae4f80"
1313
owners: ["lambda-sh"]
1414
reviewers: ["engine", "rendering"]
1515
tags: ["spec", "audio", "lambda-rs", "platform", "cpal"]
@@ -236,7 +236,8 @@ Crate boundary
236236
Application-facing API surface
237237

238238
```rust
239-
// crates/lambda-rs/src/audio.rs
239+
// crates/lambda-rs/src/audio/devices/output.rs
240+
// crates/lambda-rs/src/audio/error.rs
240241

241242
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
242243
pub enum AudioSampleFormat {
@@ -256,6 +257,13 @@ pub struct AudioCallbackInfo {
256257
pub enum AudioError {
257258
InvalidSampleRate { requested: u32 },
258259
InvalidChannels { requested: u16 },
260+
Io {
261+
path: Option<std::path::PathBuf>,
262+
details: String,
263+
},
264+
UnsupportedFormat { details: String },
265+
InvalidData { details: String },
266+
DecodeFailed { details: String },
259267
NoDefaultDevice,
260268
UnsupportedConfig {
261269
requested_sample_rate: Option<u32>,
@@ -330,7 +338,7 @@ Features
330338
- Enables the `lambda::audio` output device surface.
331339
- Enables `lambda-rs-platform` `audio-device` internally.
332340
- `lambda-rs` umbrella feature: `audio` (default: disabled)
333-
- Composes `audio-output-device` only.
341+
- Composes `audio-output-device` and `audio-sound-buffer`.
334342

335343
### Application Interaction
336344

@@ -526,14 +534,14 @@ Features introduced by this spec
526534
- Enables `lambda::audio` output device APIs.
527535
- Enables `lambda-rs-platform` `audio-device` internally.
528536
- Umbrella feature: `audio` (default: disabled)
529-
- Composes `audio-output-device` only.
537+
- Composes `audio-output-device` and `audio-sound-buffer`.
530538
- Crate: `lambda-rs-platform`
531539
- Granular feature: `audio-device` (default: disabled)
532540
- Enables the `cpal` module and the `AudioDevice`/`AudioDeviceBuilder`
533541
surface.
534542
- Enables the `cpal` dependency as an internal implementation detail.
535543
- Umbrella feature: `audio` (default: disabled)
536-
- Composes `audio-device` only.
544+
- Composes `audio-device`, `audio-decode-wav`, and `audio-decode-vorbis`.
537545

538546
Feature gating requirements
539547

@@ -574,19 +582,19 @@ Feature gating requirements
574582

575583
- Functionality
576584
- [x] Feature flags defined (`lambda-rs`: `audio-output-device`, `audio`)
577-
(`crates/lambda-rs/Cargo.toml:22`)
585+
(`crates/lambda-rs/Cargo.toml`)
578586
- [x] Feature flags defined (`lambda-rs-platform`: `audio-device`, `audio`)
579-
(`crates/lambda-rs-platform/Cargo.toml:53`)
587+
(`crates/lambda-rs-platform/Cargo.toml`)
580588
- [x] `enumerate_output_devices` implemented and returns output devices
581-
(`crates/lambda-rs/src/audio.rs:294`)
589+
(`crates/lambda-rs/src/audio/devices/output.rs`)
582590
- [x] `AudioOutputDeviceBuilder::build` initializes default output device
583-
(`crates/lambda-rs/src/audio.rs:222`,
591+
(`crates/lambda-rs/src/audio/devices/output.rs`,
584592
`crates/lambda-rs-platform/src/audio/cpal/device.rs`)
585593
- [x] `AudioOutputDeviceBuilder::build_with_output_callback` invokes callback
586-
(`crates/lambda-rs/src/audio.rs:247`,
594+
(`crates/lambda-rs/src/audio/devices/output.rs`,
587595
`crates/lambda-rs-platform/src/audio/cpal/device.rs`)
588596
- [x] Stream created and kept alive for `AudioOutputDevice` lifetime
589-
(`crates/lambda-rs/src/audio.rs:182`,
597+
(`crates/lambda-rs/src/audio/devices/output.rs`,
590598
`crates/lambda-rs-platform/src/audio/cpal/device.rs`)
591599
- [x] Platform enumeration implemented (`lambda_platform::audio::cpal`)
592600
(`crates/lambda-rs-platform/src/audio/cpal/device.rs`)
@@ -595,27 +603,30 @@ Feature gating requirements
595603
- API Surface
596604
- [x] Public `lambda` types implemented: `AudioOutputDevice`,
597605
`AudioOutputDeviceInfo`, `AudioOutputDeviceBuilder`, `AudioCallbackInfo`,
598-
`AudioOutputWriter`, `AudioError` (`crates/lambda-rs/src/audio.rs:12`)
606+
`AudioOutputWriter`, `AudioError`
607+
(`crates/lambda-rs/src/audio/devices/output.rs`,
608+
`crates/lambda-rs/src/audio/error.rs`)
599609
- [x] Internal platform types implemented: `AudioDevice`, `AudioDeviceInfo`,
600610
`AudioDeviceBuilder`, `AudioCallbackInfo`, `AudioOutputWriter`, `AudioError`
601611
(`crates/lambda-rs-platform/src/audio/cpal/device.rs`)
602612
- [x] `lambda::audio` does not re-export `lambda-rs-platform` types
603-
(`crates/lambda-rs/src/audio.rs:10`)
613+
(`crates/lambda-rs/src/audio/devices/output.rs`,
614+
`crates/lambda-rs/src/audio/mod.rs`)
604615
- Validation and Errors
605616
- [x] Invalid builder inputs rejected (sample rate and channel count)
606617
(`crates/lambda-rs-platform/src/audio/cpal/device.rs`)
607618
- [x] Descriptive `AudioError` variants emitted on failures
608-
(`crates/lambda-rs/src/audio.rs:65`,
619+
(`crates/lambda-rs/src/audio/error.rs`,
609620
`crates/lambda-rs-platform/src/audio/cpal/device.rs`)
610621
- [x] Unsupported configurations reported via `AudioError::UnsupportedConfig`
611622
(`crates/lambda-rs-platform/src/audio/cpal/device.rs`,
612-
`crates/lambda-rs/src/audio.rs:72`)
623+
`crates/lambda-rs/src/audio/error.rs`)
613624
- Documentation and Examples
614625
- [x] `docs/features.md` updated with audio feature documentation
615-
(`docs/features.md:1`)
626+
(`docs/features.md`)
616627
- [x] Example added demonstrating audible playback (behind `audio-output-device`)
617-
(`crates/lambda-rs/examples/audio_sine_wave.rs:1`)
618-
- [x] `lambda-rs` audio facade implemented (`crates/lambda-rs/src/audio.rs:1`)
628+
(`crates/lambda-rs/examples/audio_sine_wave.rs`)
629+
- [x] `lambda-rs` audio facade implemented (`crates/lambda-rs/src/audio/mod.rs`)
619630

620631
## Verification and Testing
621632

@@ -655,6 +666,8 @@ Manual checks
655666

656667
## Changelog
657668

669+
- 2026-02-02 (v0.1.17) — Align specification file references with the current
670+
`lambda::audio` module layout and feature composition.
658671
- 2026-01-31 (v0.1.15) — Update verification command to include
659672
`audio-output-device`.
660673
- 2026-01-30 (v0.1.14) — Make `lambda-rs` audio features opt-in by default and

docs/specs/audio-file-loading.md

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ title: "Audio File Loading (SoundBuffer)"
33
document_id: "audio-file-loading-2026-01-31"
44
status: "draft"
55
created: "2026-01-31T22:07:49Z"
6-
last_updated: "2026-02-02T17:40:16Z"
7-
version: "0.2.1"
6+
last_updated: "2026-02-02T22:57:02Z"
7+
version: "0.2.2"
88
engine_workspace_version: "2023.1.30"
99
wgpu_version: "26.0.1"
1010
shader_backend_default: "naga"
1111
winit_version: "0.29.10"
12-
repo_commit: "5d43a864febd72111671a4fab701cb0e5d2538b6"
12+
repo_commit: "6a5fd409c8097665ffd6e6a4a976206320ae4f80"
1313
owners: ["lambda-sh"]
1414
reviewers: ["engine", "rendering"]
1515
tags: ["spec", "audio", "lambda-rs", "platform", "assets"]
@@ -119,8 +119,7 @@ can be converted into `lambda::audio::SoundBuffer` without exposing codec
119119
types.
120120

121121
```rust
122-
// crates/lambda-rs-platform/src/audio_decode.rs (module name selected in
123-
// implementation)
122+
// crates/lambda-rs-platform/src/audio/symphonia/mod.rs
124123

125124
#[derive(Clone, Debug, PartialEq)]
126125
pub struct DecodedAudio {
@@ -139,9 +138,8 @@ pub enum AudioDecodeError {
139138

140139
Notes
141140

142-
- The implementation MAY avoid adding a shared `DecodedAudio` module and MAY
143-
instead implement format-specific decode functions returning an equivalent
144-
internal struct.
141+
- This data model is internal to `lambda-rs-platform` and MAY change between
142+
releases.
145143
- The platform error type MUST implement `Display` and MUST NOT include vendor
146144
error types in variants.
147145

@@ -168,9 +166,13 @@ pub struct SoundBuffer {
168166
}
169167

170168
impl SoundBuffer {
169+
#[cfg(feature = "audio-sound-buffer-wav")]
171170
pub fn from_wav_file(path: &std::path::Path) -> Result<Self, AudioError>;
171+
#[cfg(feature = "audio-sound-buffer-wav")]
172172
pub fn from_wav_bytes(bytes: &[u8]) -> Result<Self, AudioError>;
173+
#[cfg(feature = "audio-sound-buffer-vorbis")]
173174
pub fn from_ogg_file(path: &std::path::Path) -> Result<Self, AudioError>;
175+
#[cfg(feature = "audio-sound-buffer-vorbis")]
174176
pub fn from_ogg_bytes(bytes: &[u8]) -> Result<Self, AudioError>;
175177

176178
pub fn sample_rate(&self) -> u32;
@@ -246,11 +248,10 @@ Crate `lambda-rs-platform` (package: `lambda-rs-platform`)
246248

247249
Feature gating rules
248250

249-
- The `lambda::audio` module MUST be compiled when either `audio-output-device`
250-
or `audio-sound-buffer` is enabled.
251-
- Format-specific entry points SHOULD be gated behind the corresponding
252-
granular features and MUST return a deterministic error if called when the
253-
required feature is disabled (if the symbol remains available).
251+
- The `lambda::audio::SoundBuffer` type MUST be compiled only when either
252+
`audio-sound-buffer` or a granular sound buffer feature is enabled.
253+
- Format-specific entry points MUST be compiled only when the corresponding
254+
granular features are enabled.
254255
- `docs/features.md` MUST be updated in the implementation change that adds
255256
these features.
256257

@@ -281,24 +282,40 @@ Recommendations
281282
## Requirements Checklist
282283

283284
- Functionality
284-
- [ ] WAV decode implemented (16-bit PCM, 24-bit PCM, 32-bit float)
285-
- [ ] OGG Vorbis decode implemented
286-
- [ ] Load-from-file and load-from-bytes supported
285+
- [x] WAV decode implemented (16-bit PCM, 24-bit PCM, 32-bit float)
286+
(`crates/lambda-rs-platform/src/audio/symphonia/mod.rs`)
287+
- [x] OGG Vorbis decode implemented
288+
(`crates/lambda-rs-platform/src/audio/symphonia/mod.rs`)
289+
- [x] Load-from-file and load-from-bytes supported
290+
(`crates/lambda-rs/src/audio/buffer.rs`)
287291
- API Surface
288-
- [ ] `SoundBuffer` public API implemented in `lambda-rs`
289-
- [ ] `lambda-rs` does not expose vendor/platform decode types
290-
- [ ] `lambda::audio` module is available when sound-buffer features enabled
292+
- [x] `SoundBuffer` public API implemented in `lambda-rs`
293+
(`crates/lambda-rs/src/audio/buffer.rs`)
294+
- [x] `lambda-rs` does not expose vendor/platform decode types
295+
(`crates/lambda-rs/src/audio/buffer.rs`)
296+
- [x] `lambda::audio::SoundBuffer` is available when sound-buffer features
297+
enabled (`crates/lambda-rs/src/audio/mod.rs`)
291298
- Validation and Errors
292-
- [ ] Unsupported formats return actionable errors
293-
- [ ] Corrupt data returns actionable errors
294-
- [ ] File I/O errors return actionable errors
299+
- [x] Unsupported formats return actionable errors
300+
(`crates/lambda-rs-platform/src/audio/symphonia/mod.rs`,
301+
`crates/lambda-rs/src/audio/error.rs`)
302+
- [x] Corrupt data returns actionable errors
303+
(`crates/lambda-rs-platform/src/audio/symphonia/mod.rs`,
304+
`crates/lambda-rs/src/audio/error.rs`)
305+
- [x] File I/O errors return actionable errors
306+
(`crates/lambda-rs/src/audio/buffer.rs`)
295307
- Documentation and Examples
296-
- [ ] `docs/features.md` updated with new features and defaults
297-
- [ ] Minimal example loads a sound file and prints metadata
308+
- [x] `docs/features.md` updated with new features and defaults
309+
(`docs/features.md`)
310+
- [x] Minimal example loads a sound file and prints metadata
311+
(`crates/lambda-rs/examples/sound_buffer_load.rs`)
298312
- Tests
299-
- [ ] Unit tests cover WAV mono and stereo
300-
- [ ] Unit tests cover OGG Vorbis mono and stereo
301-
- [ ] Test assets are stored under `crates/lambda-rs-platform/assets/audio/`
313+
- [x] Unit tests cover WAV mono and stereo
314+
(`crates/lambda-rs-platform/src/audio/symphonia/mod.rs`)
315+
- [x] Unit tests cover OGG Vorbis decode (stereo fixture)
316+
(`crates/lambda-rs-platform/src/audio/symphonia/mod.rs`)
317+
- [x] Test assets are stored under `crates/lambda-rs-platform/assets/audio/`
318+
(`crates/lambda-rs-platform/assets/audio/`)
302319

303320
For each checked item, include a reference to a commit, pull request, or file
304321
path that demonstrates the implementation.
@@ -310,13 +327,12 @@ path that demonstrates the implementation.
310327
Coverage targets
311328

312329
- WAV
313-
- mono 16-bit PCM
314-
- stereo 16-bit PCM
315-
- mono 24-bit PCM
316-
- stereo 32-bit float
330+
- mono 16-bit PCM (`tone_s16_mono_44100.wav`)
331+
- stereo 16-bit PCM (`tone_s16_stereo_44100.wav`)
332+
- mono 24-bit PCM (`tone_s24_mono_44100.wav`)
333+
- stereo 32-bit float (`tone_f32_stereo_44100.wav`)
317334
- OGG Vorbis
318-
- mono
319-
- stereo
335+
- stereo (`slash_vorbis_stereo_48000.ogg`)
320336

321337
Commands
322338

@@ -325,7 +341,7 @@ Commands
325341

326342
### Example
327343

328-
- Add `crates/lambda-rs/examples/sound_buffer_load.rs`.
344+
- Provide `crates/lambda-rs/examples/sound_buffer_load.rs`.
329345
- The example SHOULD load a file path provided via CLI args and print:
330346
- channels
331347
- sample rate
@@ -340,6 +356,8 @@ Commands
340356

341357
## Changelog
342358

359+
- 2026-02-02 (v0.2.2) — Align spec with feature-gated `SoundBuffer` surface and
360+
implemented fixtures.
343361
- 2026-01-31 (v0.2.0) — Center decoding on `symphonia` 0.5.5.
344362
- 2026-01-31 (v0.1.1) — Align spec with platform audio module layout.
345363
- 2026-01-31 (v0.1.0) — Initial draft.

0 commit comments

Comments
 (0)