Skip to content

[Feature] AudioContext integration with runtime #117

@vmarcella

Description

@vmarcella

Overview

Create a high-level AudioContext that integrates with the Lambda runtime,
providing a unified interface for all audio operations and automatic resource
management.

Current State

N/A

Scope

Goals:

  • AudioContextBuilder following existing patterns
  • Automatic device initialization
  • Resource handle management (similar to RenderContext)
  • Integration with component lifecycle
  • Thread-safe audio command submission

Non-Goals:

  • Component-specific audio helpers
  • Audio asset integration

Proposed API

// crates/lambda-rs/src/audio/mod.rs
pub struct AudioContext {
  // device, mixer, resources
}

pub struct AudioContextBuilder {
  label: Option<String>,
  max_voices: usize,
}

impl AudioContextBuilder {
  pub fn new() -> Self;
  pub fn with_label(self, label: &str) -> Self;
  pub fn with_max_voices(self, count: usize) -> Self;
  pub fn build(self) -> Result<AudioContext, AudioError>;
}

impl AudioContext {
  pub fn load_sound(&mut self, path: &Path) -> Result<SoundId, AudioError>;
  pub fn play(&mut self, sound: SoundId) -> SoundInstance;
  pub fn set_master_volume(&mut self, volume: f32);
  // ...
}

Acceptance Criteria

  • AudioContext builds successfully with defaults
  • Sounds loaded via context are managed (no manual cleanup)
  • Context can be passed to components like RenderContext
  • Graceful shutdown releases audio resources
  • Example showing AudioContext with ApplicationRuntime

Affected Crates

lambda-rs

Notes

  • Consider making AudioContext optional (not all apps need audio)
  • May require runtime builder modification to include audio

Metadata

Metadata

Assignees

No one assigned

    Labels

    audioAll things related to audioenhancementNew feature or requestlambda-rsIssues pertaining to the core framework

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions