[BUG] [CRITICAL] Audio format mismatch leads to distorted sound playback
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 512
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Description
### Requirements
- [x] I have searched the existing issues to ensure this bug has not already been reported.
- [x] I have provided a clear and concise description of the bug.
- [x] I have provided detailed steps to reproduce the bug.
- [x] I have included a minimal reproducible example (MRE) if applicable.
- [x] I have provided error messages and stack traces if applicable.
- [x] 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.
```csharp
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)
```csharp
```
### 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the documented example using InitializePlaybackDevice, AudioFormat, StreamDataProvider, and SoundPlayer, then reproduce the issue with audio below 44 kHz and mismatched formats. Trace how the playback device and player use their formats, and compare playback across the reported combinations. Done means supported audio formats play at normal speed without requiring a separate device for each format.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100