[pulseaudio-discuss] Play audio files of high sample rates without hassle
Arun Raghavan
arun at arunraghavan.net
Thu Dec 8 06:02:02 UTC 2016
On Fri, 2 Dec 2016, at 05:31 PM, Tanu Kaskinen wrote:
> On Sun, 2016-11-27 at 22:27 +0100, Erwan JACQ wrote:
> > You can use the default-sample-rate/alternate-sample-rate config values
> > as minimal sample rates.
>
> Yes, using default-sample-rate as the minimum seems reasonable. I'm not
> sure what to do with alternate-sample-rate. We can't just remove it,
> unless you also change pa_config_parse() to not stop parsing when it
> encounters unknown options, because we need to handle old configuration
> files. (Doing that pa_config_parse() change would be very welcome, by
> the way.) I suppose we can parse the option, but not use it anywhere
> (and log a warning that the option was ignored).
>
> > So if you input a 8kHz audio stream, you resample it to 48kHz or 44.1kHz
> > rather than let it to go 8Khz.
> >
> > I attached my patches.
> > They just remove the limitation that the desired sample rate should be
> > either default-sample-rate or alternate-sample-rate when the sink is
> > opened. This was just a quick hack as I don't know pulseaudio source code at
> > all. Feel free to discuss or modify them :)
> >
> > The resulting behavior is the following:
> >
> > New audio stream 88200Hz -> sink & source at 88200Hz
> > Adding a stream at 441000Hz -> sink & source don't change their sample
> > rate (still 88200Hz so). The additionnal stream is thus resampled to
> > 88200Hz
> >
> > Shutdown sink, New audio stream at 441000Hz -> sink & source at 44100Hz
> >
> > Shutdown sink, New audio stream at 8000Hz -> sink & source at 44100Hz
> > because there seems to be a lower limit (maybe 8Khz is not in the
> > supported rates of the sound card :D ).
>
> I wonder if we should keep some of the special handling of rates that
> are divisible by 8000 or 11025 (so we'd prefer 48000 Hz over 44100 Hz
> if the requested rate was 8000 Hz). Probably that's not very important.
Just as a note, this can also have an adverse effect in the opposite
direction. If you have one stream at 192 kHz (paused), all streams will
get upsampled to 192 kHz, increasing CPU usage and the amount of data
we're moving around.
To me, the sensible approach is to leave the default behaviour as is,
and add a audiophile/hi-res/whatever mode which tries to play back files
with as little resampling/conversion as possible (including not
downsampling 24-bit audio, etc.).
-- Arun
More information about the pulseaudio-discuss
mailing list