-
-
Notifications
You must be signed in to change notification settings - Fork 58
fix: Match audio playback sample rate to project settings #1486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,10 +24,10 @@ static XAudioContext() | |||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| public XAudioContext() | ||||||||||||||
| public XAudioContext(int sampleRate = 44100) | ||||||||||||||
| { | ||||||||||||||
|
||||||||||||||
| { | |
| { | |
| if (sampleRate <= 0) | |
| { | |
| throw new ArgumentOutOfRangeException(nameof(sampleRate), "Sample rate must be greater than zero."); | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -415,7 +415,8 @@ private async Task PlayAudio(Scene scene) | |||||||||||||
| { | ||||||||||||||
| if (OperatingSystem.IsWindows()) | ||||||||||||||
| { | ||||||||||||||
| using var audioContext = new XAudioContext(); | ||||||||||||||
| int sampleRate = EditViewModel.Composer.Value.SampleRate; | ||||||||||||||
|
||||||||||||||
| int sampleRate = EditViewModel.Composer.Value.SampleRate; | |
| int sampleRate = EditViewModel.Composer.Value.SampleRate; | |
| if (sampleRate <= 0) | |
| { | |
| sampleRate = 44100; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read sample rate from project settings before creating XAudioContext
On Windows playback this value still resolves to 44.1kHz because EditViewModel constructs SceneComposer without initializing SampleRate (src/Beutl/ViewModels/EditViewModel.cs:61-64), and Composer sets SampleRate = 44100 by default (src/Beutl.Engine/Audio/Composing/Composer.cs:32-35). That means new XAudioContext(sampleRate) here effectively keeps using 44100 for all projects, so 48kHz projects remain on a mismatched mastering voice and the audio-drop issue this patch targets is not actually fixed.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the constructor from
XAudioContext()toXAudioContext(int sampleRate = 44100)keeps source compatibility for this repo, but it removes the parameterless .ctor and is a binary breaking change for any already-compiled consumers/plugins. IfBeutl.Engineis intended to be consumed externally, consider keeping a parameterless constructor overload that delegates to the new one to preserve binary compatibility.