Re: [ecasound] int to float or float to int conversion

From: Kai Vehmanen <kvehmanen@email-addr-hidden>
Date: Mon Jan 18 2010 - 09:56:56 EET


On Sun, 6 Dec 2009, Matt Barber wrote:

> How does ecasound convert 16-bit ints to floats? It does not seem to
> be a simple divide by 38768, since a file with a range of -32768 to
> +32767 seems to map perfectly to -1.0 to +1.0 after conversion. This

see eca-sample-conversion.h:;a=blob;f=libecasound/eca-sample-conversion.h;h=f11aced93bd9ff2616c5500205d661cc8c554201;hb=HEAD

And the associated unit tests in:;a=blob;f=libecasound/eca-sample-conversion_test.h;h=fa0c52247290c4886dc98889afde9eaac0f8e70d;hb=HEAD

> is not the case when libsndfile is invoked to open the file -- there
> it looks like a division by 38768, leading to a range -1.0 to
> +0.999969

Yes, there is a slight difference. You can choose which
conversion to use:
   1) if you open sndfile files with float sample format ("-f:f32 -i
      sndfile,foo.wav" ) to libsndfile, libsndfile's conversion
      will be used
   2) if you use fixed format ("-f:s32 -i sndfile,foo.wav", then ecasound's
      conversion will be used

Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
Ecasound-list mailing list
Received on Mon Jan 18 12:15:01 2010

This archive was generated by hypermail 2.1.8 : Mon Jan 18 2010 - 12:15:01 EET