oboe icon indicating copy to clipboard operation
oboe copied to clipboard

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

Open tuananhdtu opened this issue 10 months ago • 2 comments

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 avatar Jan 22 '25 03:01 tuananhdtu

@flamme - would PreferredMixerAttributes help here?

philburk avatar Jan 27 '25 19:01 philburk

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.

flamme avatar Jan 27 '25 22:01 flamme