[alsa-devel] alsa-lib rate plugins - float samples - patches

Takashi Iwai tiwai at suse.de
Thu Jun 30 14:48:14 CEST 2011

At Tue, 28 Jun 2011 09:11:02 +0200,
Pavel Hofman wrote:
> Dne 20.6.2011 09:35, Pavel Hofman napsal(a):
> > Hi,
> > 
> > This is probably a question for Jaroslav Kysela. The better-quality rate
> > plugins offer float resolution, but currently we are deliberately
> > loosing information by down-converting to s16 in plugin_rate API
> > (convert_s16). In rate_samplerate.c, the samples are up-converted to
> > float before calling the libsamplerate API. Speex offers float API too,
> > while we are using the int16 one.
> > 
> > There are two ways to handle this:
> > 
> > A. Implementing the generic "convert" API function for these plugins,
> > handling the sample - float conversion in each plugin individually.
> > 
> > B. Extending the pcm_rate API (pcm_rate.h) with a new optional function
> > convert_float.
> > 
> > Since the conversion from general sample format to float is not trivial
> > (using the plugin_ops.h operations), I would be inclined to suggest the
> > extension (well I have it hacked already :-) ). On the other hand, the
> > conversion routine can be located in some common code shared by all the
> > plugins involved and we could keep the existing API, using the generic
> > convert function.
> I am attaching preliminary patches. May I ask for help with adding a new
> API version number if you find it necessary? I am afraid this is beyond
> my skills.
> The patches are not checkpatched yet.
> After these patches are finished, I would like to work on implementing
> the SoX resampler algorithm which features excellent CPU
> consumption/resampling quality ratio.

Thanks for the patches.
The basic strategy looks good to me, but a few things to be considered:

- The extension of API should be done in binary-compatible way; i.e.
  append new stuff to the existing structure, not inserting in the
  middle.  In that way, you can use still old plugins.

- From the performance POV, we may need to have the built-in
  float conversion in rate plugin indeed.  Anyway, if rate plugin
  supports float, it should add FLOAT as the supported format.
  This needs changes in the parameter setup in rate plugin.
  Then it should accept the float format as is without conversions.

- The float-support has to be disabled when the float is suppressed
  via configure option.  Also this needs to be exposed somehow to the

- At best, the rate converters (plugin of plugin) should support both
  cases with and without float.



More information about the Alsa-devel mailing list