Skip to content
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

How to Set Sample Rate to 48000 in Oboe While Ensuring Low Latency? #2141

Open
tuananhdtu opened this issue Jan 22, 2025 · 2 comments
Open
Assignees
Labels

Comments

@tuananhdtu
Copy link

I am using Oboe for voice recording while simultaneously playing an MP3 file. The MP3 file is mixed with the inputData from Oboe to play music. The sample rate for MP3 playback is determined based on the device's supported sample rate, not the headphones. My device supports a maximum sample rate of 48000, but the headphones connected to the device can support up to 96000. Currently, Oboe prioritizes the highest sample rate available, especially in low-latency mode. I would like to configure the sample rate to 48000 to ensure compatibility and consistency in audio processing, regardless of the headphones' capabilities.

@tuananhdtu tuananhdtu added the bug label Jan 22, 2025
@philburk philburk assigned philburk and flamme and unassigned philburk Jan 27, 2025
@philburk philburk added question and removed bug labels Jan 27, 2025
@philburk
Copy link
Collaborator

@flamme - would PreferredMixerAttributes help here?

@flamme
Copy link
Collaborator

flamme commented Jan 27, 2025

My device supports a maximum sample rate of 48000, but the headphones connected to the device can support up to 96000. Currently, Oboe prioritizes the highest sample rate available, especially in low-latency mode.

AFAIK, oboe doesn't select the sample rate. However, the Android OS will always default select the highest sample rate to open as a hifi output so that the apps will have chance to signal at highest sample rate that the USB device supported without any conversion. It is up to the Android device to select what sample rate to open the USB device as the lower layer, such as the DSP may have the capabilities to do resampling. That means the Android device manufacturers can either select highest sample rate or 48kHz and do resampling when the Android audio framework sending data at a different sample rate.

With AudioManager.setPreferredMixerAttributes, the Android audio framework guaranteed to deliver audio data at the apps' preferred configuration(including sample rate, audio format and channel mask) if the apps stream data at the same configuration as the preferred mixer configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants