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

オープン
#937 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
46/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
rust

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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).

主要言語
Rust
スター
2.5k
フォーク
338
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

RustAudio/rodio のほかの issue

RustAudio/rodio の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。