Improve audio device management and add fixed-rate mixer with FIR resampling#393
Open
PauloAguiar wants to merge 3 commits into
Open
Improve audio device management and add fixed-rate mixer with FIR resampling#393PauloAguiar wants to merge 3 commits into
PauloAguiar wants to merge 3 commits into
Conversation
Replace hardcoded audio config with device capability querying: - Use device default config instead of hardcoded 48kHz/1200-frame buffer - Read live sample rate at play time for correct resampling after device switches - Detect system default device changes and auto-reconnect - Support selecting a specific output device via SharedDeviceState - Extract SharedDeviceState for clean cross-thread device info sharing - Add device listing and selection API to AudioEngine A few simplifications in the audio pipeline
PauloAguiar
commented
Mar 21, 2026
|
|
||
| let (mut initial_result_producer, mut initial_result_consumer) = RingBuffer::new(1); | ||
|
|
||
| std::thread::spawn(move || { |
Author
There was a problem hiding this comment.
This whole logic has been pulled up to the backend which also manages device discovery and device preference changes. This is now only responsible for managing the stream.
…d using Fir Resampler
1ab7372 to
9f3d8e1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The audio mixer now always runs at 48kHz internally. When the output device uses a different sample rate (e.g. 44.1kHz), a FIR resampler (-60dB attenuation) converts the final output. This eliminates sample rate issues on device switch — sounds no longer need to be reloaded or re-resampled when switching devices.
Audio device management: Users can select their preferred output device from a dropdown in the Audio Settings window. The preference is persisted to audio_settings.ron and restored on next launch. If the saved device isn't available, the system default is used without overwriting the saved preference.
Live device list updates: The backend monitoring thread refreshes the available device list every 500ms. Device additions/removals (e.g. plugging in headphones) are reflected in the UI dropdown automatically.
Device identity by ID: Devices are identified by their stable platform ID (e.g. WASAPI endpoint ID) rather than display name, so preferences survive device renames.
Audio backend refactoring: Simplified OutputDevicePreference to only hold the user's preference and available device list. Removed Arc sample rate sharing from track handles — no longer needed with the fixed mixer rate. Cleaned up the Renderer to own its resampling logic entirely.
Debug logging: Added timestamped logging for device selection, BGM loading, ambient sound enter/leave, and device switching.