[pulseaudio-discuss] How does automatic output resampling in Pulseaudio work?
Tanu Kaskinen
tanuk at iki.fi
Mon Feb 18 13:59:28 PST 2008
On Mon, Feb 18, 2008 at 01:19:43PM -0800, Erich Boleyn wrote:
>
> Tanu Kaskinen <tanuk at iki.fi> wrote:
>
> > On Mon, Feb 18, 2008 at 11:56:05AM -0800, Erich Boleyn wrote:
> > > When Pulseaudio converts from one format to another at the sound output
> > > (say for an ostensibly 16-bit/48-khz DAC) *and* performs the automatic
> > > output resampling (due to the normal output hardware clock imperfection
> > > issues), which one more accurately represents the real chain of events:
> > >
> > > A) 24-bit/96-khz PCM --(resampled)--> 16-bit/48-khz
> > > --(resampled)--> 16-bit/near-48-khz-real-freq
> > >
> > > B) 24-bit/96-khz PCM --(resampled)--> 16-bit/near-48-khz-real-freq
> > >
> > > I.e. is it resampled once to get to the "output format" and again at
> > > the final hardware matching stage, or is it resampled once directly to
> > > the hardware matching frequency?
> >
> > If I understood you correctly, then the answer is that there
> > is no "final hardware matching stage". In your example the
> > sound card reports that it uses sampling rate of 48000 Hz,
> > and pulseaudio trusts that it's correct information. If it's
> > not, then the sound is played slightly too fast or too
> > slowly. The small deviation is taken into account only when
> > there are multiple clocks, for example two sound cards, and
> > even then the correction is not based on actual time, but
> > just the observed difference in the clocks.
> >
> > So resampling is always done only once (afaik).
>
> Is this also true for sources received from hard input sample rates?
>
> In particular, my example is that I am sending audio via RTP to multiple
> computers, each possibly more or less in hearing distance of the other.
> (though this would apply possibly to input from a digital or other source
> on the local machine as well, since it has a fixed input rate)
Direct connecting between sources and sinks isn't supported,
yet. RTP is an exception, there the adaptive resampling
between the clock from the net and the local sound card is
implemented.
> So, you have 2 problems:
> -- The source was sent out at a particular frequency over the network,
> and you'd get bufferring problems if you didn't resample at the
> output.
> -- The deviations between the different computers will be noticable
> after a while.
In the RTP case these are solved.
> I thought pulseaudio accounted for that difference, perhaps I interpreted
> the "ability to resample the outputs to be synchronized" comments in the
> docs wrong.
I might be wrong, but I think such comments refer to
module-combine. With it you can synchronize local sound
cards, or nowadays remote cards too using
module-tunnel-sink. RTP is synchronized automatically in a
way, or rather the timing difference is constant (the
receiving machines don't communicate their local latencies,
so accurate syncing happens mostly with luck).
Disclaimer: everything I know about RTP I have learned from
this list and the #pulseaudio IRC channel. I have just one
computer, so I have never used RTP myself.
--
Tanu Kaskinen
More information about the pulseaudio-discuss
mailing list