Skip to content

[BUG] [CRITICAL] Audio format mismatch leads to distorted sound playback #106

@christallire

Description

@christallire

Requirements

  • I have searched the existing issues to ensure this bug has not already been reported.
  • I have provided a clear and concise description of the bug.
  • I have provided detailed steps to reproduce the bug.
  • I have included a minimal reproducible example (MRE) if applicable.
  • I have provided error messages and stack traces if applicable.
  • I have completed the environment information.

1. Describe the Bug

Audio file and playback device format mismatch leads to distorted sound playback.
I need to create playback device for file's format unless I got distorted (fast or slow) sound play.

2. Steps to Reproduce

Just run the code with less than 44khz audio

3. Expected Behavior

I get "normal" sound play whatever format I choose.

4. Current Behavior

I get "distorted" sound play IF playback device format mismatches.

5. Minimal Reproducible Example (MRE)

This code is from the official documentation.

var engine = new MiniAudioEngine();
var format = AudioFormat.DvdHq;
using var playbackDevice = engine.InitializePlaybackDevice(null, format);

// Create a SoundPlayer
using var dataProvider = new StreamDataProvider(engine, File.OpenRead("audio.wav")); // Auto-detects format
var player = new SoundPlayer(engine, format, dataProvider);

// Add components to the device's MasterMixer
playbackDevice.MasterMixer.AddComponent(player);

// Start the device to enable its audio stream
playbackDevice.Start();
player.Play();

6. Error Messages and Stack Trace (if applicable)

SoundFlow Version

1.4.0

.NET Version

.NET 10

Operating System

Windows 11

Architecture

x64

Audio Backend Used (if known)

No response

Specific Audio Hardware (if relevant)

No response

8. Affected Components/Modules (if known)

No response

9. Impact

incorrect audio output

10. Possible Workaround (if known)

create a playback device per audio format (which is not ideal..)

11. Additional Context

SoundPlayer's format has no effect on this. and API regarding the format is very confusing by itself. I think it's not common to play distorted sound intentionally in this way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions