SoX appears to be reading and writing something other than IEEE
floating-point data when dealing with w64 files. I discovered this
while attempting to use SoX to convert the w64 files produced by
TimeMachine into something more universally readable. Other
sndfile-linked applications handled these files without a hitch.
SoX would correctly read any w64 files that it produced, so checking SoX
against itself hid the problem. Other programs could not correctly read
SoX-produced w64 files.
I verified the problem by preparing a simple wave file (pcm16, 2
channel) and converting it with both SoX and sndfile:
sndfile-convert -float32 test.wav test_snd.w64
sox test.wav -f -4 test_sox.wav
Both files had the same length and identical headers, but the data were
very different.
test_snd.w64 contained 32-bit, IEEE floating-point, little-endian data
with a range of +/-1.000E0.
test_sox.w64 clearly contained something else.
The problem appears to be in the SoX-sndfile interface. Adding a few
lines to sox-14.0.1/src/sndfile.c seemed to clear things up. Here is
what I did:
--- OLD/sox-14.0.1/src/sndfile.c 2008-01-28 14:47:19.000000000 -0800
+++ NEW/sox-14.0.1/src/sndfile.c 2008-05-02 06:11:17.000000000 -0700
@@ -317,6 +317,9 @@
}
else ft->signal.rate = sf->sf_info->samplerate;
+ if ((sf->sf_info->format & SF_FORMAT_SUBMASK) == SF_FORMAT_FLOAT)
+ sf_command(sf->sf_file, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE);
+
return SOX_SUCCESS;
}
@@ -384,6 +387,9 @@
return SOX_EOF;
}
+ if ((sf->sf_info->format & SF_FORMAT_SUBMASK) == SF_FORMAT_FLOAT)
+ sf_command(sf->sf_file, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE);
+
return SOX_SUCCESS;
}
After patching the file I notice that, because SoX uses sf_write_int
instead of sf_write_float, the w64 files it creates are not
automatically normalized to +/-1.0 as the files returned by other
sndfile-linked applications tend to be. Perhaps this is a good thing.
If this issue has already been dealt with elsewhere, I apologize for
bringing it up.
Tim
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone