Skip to content

[Feature] Basic sound playback #112

@vmarcella

Description

@vmarcella

Overview

Add the ability to play loaded sound buffers through the audio device with
basic transport controls (play, pause, stop).

Current State

Audio device initialization and sound loading must be implemented first
(see related issues). No playback capability exists.

Scope

Goals:

  • Play a SoundBuffer through an AudioDevice
  • Pause and resume playback
  • Stop playback
  • Query playback state (playing, paused, stopped)
  • Support looping playback

Non-Goals:

  • Volume control
  • Pitch/speed control
  • Spatial audio
  • Multiple simultaneous sounds

Proposed API

// crates/lambda-rs/src/audio/mod.rs
pub struct SoundInstance {
  // internal handle
}

impl SoundInstance {
  pub fn play(&mut self);
  pub fn pause(&mut self);
  pub fn stop(&mut self);
  pub fn set_looping(&mut self, looping: bool);
  pub fn is_playing(&self) -> bool;
  pub fn is_paused(&self) -> bool;
}

// On AudioContext or similar
pub fn play_sound(&mut self, buffer: &SoundBuffer) -> SoundInstance;

Acceptance Criteria

  • Play a loaded sound buffer to completion
  • Pause and resume without audio artifacts
  • Stop playback and reset position
  • Loop sounds continuously when enabled
  • Example demonstrating play/pause/stop

Affected Crates

lambda-rs, lambda-rs-platform

Notes

  • Sound instances should be lightweight handles
  • Consider ring buffer for audio thread communication
  • Audio callback runs on separate thread; avoid blocking

Metadata

Metadata

Assignees

No one assigned

    Labels

    audioAll things related to audioenhancementNew feature or requestlambda-rsIssues pertaining to the core frameworklambda-rs-platformIssues pertaining to the dependency & platform wrappers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions