Skip to content

Audio passthrough fails if input sample rate does not match output sample rate #12

Description

@lyseste

Description

Audio passthrough fails to start when the input device (capture card) operates at a different sample rate than the selected audio output device. No audio is heard and the only indication is a WARN log entry. The log file shows:

WARN audio output '(device name)' does not support 48000 Hz / 2 channels

No further attempt is made to start audio. The UI also gives no indication that audio is unavailable.

Root cause

In src/audio.rs, choose_output_config() filters output configurations to only those whose supported sample rate range includes the input device's rate. If the output device reports a fixed rate (e.g. 44100 Hz) that doesn't match the input rate (48000 Hz), the function returns None and start() returns early with only a warning:

// audio.rs — start()
let output_format = match choose_output_config(&output_supported, input_rate, channels) {
    Some(config) => config,
    None => {
        warn!("audio output '{}' does not support {} Hz / {} channels", ...);
        return;
    }
};

Suggested fix

Add sample rate conversion
When no output config matches the input rate, fall back to the output's native rate and resample in the output callback. Linear interpolation is sufficient for this use case and requires no additional dependencies. The output stream runs at the output device's native rate; the callback pulls input-rate samples from the ring buffer and resamples them before writing.

Environment

  • Platform: Windows
  • Audio backend: WASAPI (via cpal 0.15)
  • Capture card: ShadowCast 3 (48000 Hz)
  • Output device: VoiceMeeter Aux Input — VB-Audio VoiceMeeter AUX VAIO (44100 Hz)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions