0.23.0 is missing three fixes that are on master (#872 queue channel shift, #886 Spatial L/R swap, ChannelVolume averaging)

Abierto
#937 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
46/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust

Línea de trabajo

Read the listed fixes #872, #886, and commit 55c103fdf, then compare their changes with the v0.23.0 tag and the reproducer in the issue. Start by running the reproducer against v0.23.0 and master to confirm the three symptoms; done means a release or backport includes all three fixes and those comparisons pass. The issue describes the bugs clearly, but coordinating a release or backport spans several changes.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

rodio 0.23.0 (published 2026-10-11) was cut from a line that diverged from master (GitHub compare: the v0.23.0 tag is behind each fix below), so three fixes already merged on master are not in the release. One program reproduces all three on 0.23.0 and shows each one fixed on master at 685e057.

Fix on master In v0.23.0? Symptom in 0.23.0
#872 (8ca8cd0f4), channel shift when appending to an empty keep-alive queue no (diverged, 45 behind) Player::connect_new followed by append plays the first 512 samples of a stereo source as mono: each L and R sample is written to both channels, at half speed (10.7 ms at 48 kHz)
#886 (6d31466ca), Spatial diff modifier swaps left and right (#884) no (diverged, 70 behind) a source on the right plays louder in the left ear once the inverse-square term stops dominating (16 units right of ears at x = ±2)
55c103fdf, ChannelVolume averaging no (diverged, 82 behind) ChannelVolume::next computes the channel mean but discards it (self.current_sample.map(...) without assignment), so stereo input to Spatial is summed: exactly 2× (+6 dB) the level of the same signal as mono
Output

0.23.0 (crates.io):

connect_new then append: first 8 samples [1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0]; frames with wrong channels in first 2000: 512
Player::new, append, then mixer.add: first 8 samples [1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0]; frames with wrong channels: 0
Spatial, source 16 m right: left 0.003086 right 0.002551 (right louder expected: false)
Spatial stereo-in (0.5,0.5): (0.742574,0.742574) vs mono-in 0.5: (0.371287,0.371287); ratio 2.000

master at 685e05765c2aff8fbb51e32cda5b18428d09ffbe:

connect_new then append: first 8 samples [1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0]; frames with wrong channels in first 2000: 0
Player::new, append, then mixer.add: first 8 samples [1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0]; frames with wrong channels: 0
Spatial, source 16 m right: left 0.001543 right 0.005102 (right louder expected: true)
Spatial stereo-in (0.5,0.5): (0.371287,0.371287) vs mono-in 0.5: (0.371287,0.371287); ratio 1.000
Reproduction

Cargo.toml: rodio = { version = "=0.23.0", default-features = false, features = ["playback"] } (or a git dependency on the master rev above).

src/main.rs
use rodio::{buffer::SamplesBuffer, mixer, source::Spatial, Player, Source};
use std::num::NonZero;

fn stereo(frames: usize) -> SamplesBuffer {
    // left = +1.0, right = -1.0 on every frame
    let samples: Vec<f32> = (0..frames * 2).map(|i| if i % 2 == 0 { 1.0 } else { -1.0 }).collect();
    SamplesBuffer::new(NonZero::new(2).unwrap(), NonZero::new(48_000).unwrap(), samples)
}

fn bad_frames(out: &[f32]) -> usize {
    out.chunks(2).filter(|f| !(f[0] == 1.0 && f[1] == -1.0)).count()
}

fn main() {
    // 1. Player attached to the mixer before the first append.
    let (mx, mut out) = mixer::mixer(NonZero::new(2).unwrap(), NonZero::new(48_000).unwrap());
    let player = Player::connect_new(&mx);
    player.append(stereo(4000));
    let v: Vec<f32> = (&mut out).take(4000).collect();
    println!("connect_new then append: first 8 samples {:?}; frames with wrong channels in first 2000: {}", &v[..8], bad_frames(&v));

    // 2. Same, but append before attaching the queue.
    let (mx, mut out) = mixer::mixer(NonZero::new(2).unwrap(), NonZero::new(48_000).unwrap());
    let (player2, queue) = Player::new();
    player2.append(stereo(4000));
    mx.add(queue);
    let v: Vec<f32> = (&mut out).take(4000).collect();
    println!("Player::new, append, then mixer.add: first 8 samples {:?}; frames with wrong channels: {}", &v[..8], bad_frames(&v));

    // 3. Spatial: source 16 m to the right of ears at x = -2 / +2.
    let src = SamplesBuffer::new(NonZero::new(1).unwrap(), NonZero::new(48_000).unwrap(), vec![1.0; 4]);
    let mut sp = Spatial::new(src, [16.0, 0.0, 0.0], [-2.0, 0.0, 0.0], [2.0, 0.0, 0.0]);
    let (l, r) = (sp.next().unwrap(), sp.next().unwrap());
    println!("Spatial, source 16 m right: left {l:.6} right {r:.6} (right louder expected: {})", r > l);

    // 4. Spatial (ChannelVolume) with stereo input 0.5 in both channels vs mono 0.5, source centred.
    let st = SamplesBuffer::new(NonZero::new(2).unwrap(), NonZero::new(48_000).unwrap(), vec![0.5, 0.5]);
    let mut sp = Spatial::new(st, [0.0, 0.0, 1.0], [-0.1, 0.0, 0.0], [0.1, 0.0, 0.0]);
    let (l, r) = (sp.next().unwrap(), sp.next().unwrap());
    let mono = SamplesBuffer::new(NonZero::new(1).unwrap(), NonZero::new(48_000).unwrap(), vec![0.5]);
    let mut spm = Spatial::new(mono, [0.0, 0.0, 1.0], [-0.1, 0.0, 0.0], [0.1, 0.0, 0.0]);
    let (ml, mr) = (spm.next().unwrap(), spm.next().unwrap());
    println!("Spatial stereo-in (0.5,0.5): ({l:.6},{r:.6}) vs mono-in 0.5: ({ml:.6},{mr:.6}); ratio {:.3}", l / ml);
    drop((player, player2));
}
Suggestion

A 0.23.x release from master, or a backport of these three, would fix them for crates.io users. Until then, a workaround for the first one on 0.23.0 is to build the player with Player::new(), append the first source, and only then mixer.add(queue). Related: #898 (users asking for a release containing the cpal 0.18 line).

Found while integrating 0.23.0 into a game engine's ECS audio path (Windows Server 2025, rustc 1.101.0-nightly 2026-10-24; release profile).

Lenguaje dominante
Rust
Estrellas
2.5k
Forks
338
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de RustAudio/rodio

Todos los issues de RustAudio/rodio

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.