Skip to content

[Feature] Volume and pitch control #113

@vmarcella

Description

@vmarcella

Overview

Add volume (gain) and pitch (playback speed) controls to sound instances for
basic audio manipulation.

Current State

Requires basic sound playback to be implemented first. No audio property
controls exist.

Scope

Goals:

  • Set volume/gain per sound instance (0.0 to 1.0+)
  • Set pitch/playback speed per sound instance
  • Support global/master volume

Non-Goals:

  • Audio effects (reverb, echo)
  • Per-channel volume
  • Volume fading/transitions

Proposed API

impl SoundInstance {
  /// Set volume where 1.0 is normal, 0.0 is silent, >1.0 amplifies.
  pub fn set_volume(&mut self, volume: f32);
  pub fn volume(&self) -> f32;
  
  /// Set pitch where 1.0 is normal, 0.5 is half speed, 2.0 is double.
  pub fn set_pitch(&mut self, pitch: f32);
  pub fn pitch(&self) -> f32;
}

impl AudioContext {
  pub fn set_master_volume(&mut self, volume: f32);
  pub fn master_volume(&self) -> f32;
}

Acceptance Criteria

  • Volume 0.0 produces silence
  • Volume 1.0 plays at original level
  • Volume >1.0 amplifies (with clipping awareness)
  • Pitch 1.0 plays at original speed
  • Pitch changes affect both speed and frequency
  • Master volume affects all playing sounds

Affected Crates

lambda-rs, lambda-rs-platform

Notes

  • Pitch shifting via resampling is acceptable for v1
  • Consider soft clipping for volume >1.0

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