Skip to content

[Feature] Audio streaming for large files #115

Description

@vmarcella

Overview

Add streaming playback for large audio files (music, ambient tracks) that
decodes audio on-the-fly instead of loading entire files into memory.

Current State

Sound loading loads entire files into memory. Large music files (5+ minutes)
would consume excessive RAM.

Scope

Goals:

  • Stream audio from file during playback
  • Buffer decoded audio in small chunks
  • Support seeking within streamed audio
  • Support OGG and WAV streaming

Non-Goals:

  • Network audio streaming
  • Gapless playback between tracks

Proposed API

pub struct StreamingSound {
  // internal decoder + buffer
}

impl StreamingSound {
  pub fn from_file(path: &Path) -> Result<Self, AudioError>;
  pub fn play(&mut self);
  pub fn pause(&mut self);
  pub fn stop(&mut self);
  pub fn seek(&mut self, position_seconds: f32);
  pub fn position(&self) -> f32;
  pub fn duration(&self) -> f32;
  pub fn set_volume(&mut self, volume: f32);
  pub fn set_looping(&mut self, looping: bool);
}

Acceptance Criteria

  • Stream a 5+ minute audio file with <10MB memory usage
  • Seeking works without audible glitches
  • Looping works without gaps
  • CPU usage remains reasonable during playback
  • Example streaming background music

Affected Crates

lambda-rs, lambda-rs-platform

Notes

  • Buffer size tradeoff: larger = more latency, smaller = more CPU
  • Consider 100-200ms buffer as default
  • Decoder runs on separate thread or async task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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