Skip to content

ChannelVolume usage causes crackling/distortion #680

@will3942

Description

@will3942

We are using ChannelVolume to output Sources in mono on multichannel devices.

We have noticed that when using ChannelVolume the audio is distorted and crackly versus when not using ChannelVolume.

Code sample for good audio:

use std::io::BufReader;

use rodio::source::ChannelVolume;

fn main() {
    let (_stream, handle) = rodio::OutputStream::try_default().unwrap();
    let sink = rodio::Sink::try_new(&handle).unwrap();

    let file = std::fs::File::open("assets/sample.mp3").unwrap();
    let decoder = rodio::Decoder::new(BufReader::new(file)).unwrap();

    sink.append(decoder);

    sink.sleep_until_end();
}

Code sample for distortion:

use std::io::BufReader;

use rodio::source::ChannelVolume;

fn main() {
    let (_stream, handle) = rodio::OutputStream::try_default().unwrap();
    let sink = rodio::Sink::try_new(&handle).unwrap();

    let file = std::fs::File::open("assets/sample.mp3").unwrap();
    let decoder = rodio::Decoder::new(BufReader::new(file)).unwrap();

    let channel_volumes = ChannelVolume::new(decoder, [1.0, 1.0].to_vec());

    sink.append(channel_volumes);

    sink.sleep_until_end();
}

Sample mp3: https://github.com/will3942/test-rodio/raw/refs/heads/main/assets/sample.mp3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions