Re: [ecasound] lossless conversion broken?

From: Dan Muresan <danmbox@email-addr-hidden>
Date: Sun Oct 31 2010 - 01:11:36 EEST

This is probably getting too technical for the list...

It's not that important (in practice I observed at most 1-bit errors
with wav->wav), but I was still curious if recording is bit-exact, or
it might also flip some bits.

> does your 23+1 refer to the 'hidden' bit in IEEE-754?
> 23+1 == 24 is true, but don't forget that with floats you also have the
> exponent.

The exponent bits don't necessarily get used uniformly across the
dynamic range... It depends on what conversion formula you use. Here's
a guy who writes on it:

> The biggest positive number you can store in an int on my system is
> 2147483647 while there's no issue with much higher numbers for float.

That's the maximum signed 32-bit unsigned integer (while for audio we
probably care about 24-bit signed). But *maximum value* and
*resolution* are separate things (see below).

> Just try it.

This is *not* a realistic conversion algorithm, but if you think
floats "just work" as int's, play with this:

#include <iostream>
#include <stdint.h>

using namespace std;

int main () {
  float x;
  while ((cin >> x))
    cout << "float " << x << " -> int " << ((int32_t) x) << "\n";
  return 0;

$ g++ -o x; ./x

float 1.23457e+09 -> int 1234567936
float 1.23457e+08 -> int 123456792
float 1.07374e+09 -> int 1073741824
float 1.07374e+09 -> int 1073741824

Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
Ecasound-list mailing list
Received on Sun Oct 31 04:15:01 2010

This archive was generated by hypermail 2.1.8 : Sun Oct 31 2010 - 04:15:01 EET