shithub: aacenc

Download patch

ref: 5cea228a755a35b79ebc20b211dc4ee236c19fd9
parent: 8c8ff056773d89ab17aa252d449d8ca6d8d6d66d
author: menno <menno>
date: Wed Feb 13 07:42:02 EST 2002

Use latest version of libsndfile

diff: cannot open a/common/libsndfile/doc//null: file does not exist: 'a/common/libsndfile/doc//null' diff: cannot open a/common/libsndfile/examples//null: file does not exist: 'a/common/libsndfile/examples//null' diff: cannot open a/common/libsndfile/m4//null: file does not exist: 'a/common/libsndfile/m4//null' diff: cannot open a/common/libsndfile/tests//null: file does not exist: 'a/common/libsndfile/tests//null'
--- a/common/libsndfile/AUTHORS
+++ b/common/libsndfile/AUTHORS
@@ -1,12 +1,16 @@
-The main author of libsndfile is Erik de Castro Lopo <erikd@zip.com.au>.
+The main author of libsndfile is Erik de Castro Lopo <erikd AT zip DOT com DOT au>.
 
 The code in the src/GSM610 directory was written by Jutta Degener 
-<jutta@cs.tu-berlin.de> and Carsten Bormann <cabo@cs.tu-berlin.de>.
-They should not be contacted in relation to libsndfile or the GSM 6.10
-code that is part of libsndfile. Their original code can be found at:
+<jutta AT cs DOT tu-berlin DOT de> and Carsten Bormann 
+<cabo AT cs DOT tu-berlin DOT de>. They should not be contacted in relation to 
+libsndfile or the GSM 6.10 code that is part of libsndfile. Their original code 
+can be found at:
 
     http://kbs.cs.tu-berlin.de/~jutta/toast.html
-	
+
+Code in the src/G72x directory was released by Sun Microsystems, Inc. to the 
+public domain. Minor modifications were required to integrate these files 
+into libsndfile. The changes are listed in src/G72x/ChangeLog.
 
 
 
--- a/common/libsndfile/ChangeLog
+++ b/common/libsndfile/ChangeLog
@@ -1,96 +1,622 @@
-2000-10-16  Erik de Castro Lopo  <erikd@zip.com.au>
+2001-11-11  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
-    * src/sndfile.c src/au.c
-	Fixed bug which prevented writing of G723 24kbps AU files.
+	* examples/sfplay_beos.cpp
+	Added BeOS version of sfplay.c. This needs to be compiled using a C++
+	compiler so is therefore not built by default. Thanks to Marcus Overhagen
+	for providing this.
+
+2001-11-11  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+	* src/*.[ch]
+	Removed all usage of off_t which is not part of the ISO C standard. All places 
+	which were using it are now using type long which is the type of the offset 
+	parameter for the fseek function.
+	This should fix problems on BeOS, MacOS and *BSD like systems which were failing
+	"make check" because sizeof (long) != sizeof (off_t).
+
+2001-11-10  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+	* examples/sfplay.c
+	New example file showing how libsndfile can be used to read and play a sound file.
+	At the moment on Linux is supported. Others will follow in the near future.
+
+2001-11-08  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/au.c src/sndfile.au
+	Added support for 32 bit float data in big and little endian AU files.
 	
-	* tests/lossy_comp_test.c
-	Corrrection to options for G723 tests.
+	* tests/write_read_test.c
+	Added tests for 32 bit float data in AU files.
 
-    * configure.in
+2001-11-06  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * tests/lossy_comp_test.c
+	Finalised testing of stereo files where possible.
+
+2001-11-05  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/wav_ms_adpcm.c
+	Fixed bug in writing stereo MS ADPCM WAV files. Thanks to Xu Xin for pointing
+	out this problem.
+
+2001-10-24  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/wav_ms_adpcm.c
+	Modified function srate2blocksize () to handle 44k1Hz stereo files.
+
+2001-10-24  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * tests/lossy_comp_test.c
+	Modified this test program so that for stereo capable files, test stereo mode 
+	instead of mono.
+
+2001-10-06  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/common.h 
+    Win32 has _snprintf and _vsnprintf but not snprintf and vsnprintf. Added a
+	conditional #define to fix this.
+
+2001-10-04  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/voc.c
+    Changed the TYPE_xxx enum names to VOC_TYPE_xxx to prevent name clashes
+    on MacOS with CodeWarrior 6.0.
+
+    * MacOS/MacOS-readme.txt 
+    Updated the compile instructions. Probably still need work as I don't have
+    access to a Mac.
+
+2001-10-01  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/wav.c src/aiff.c common.c
+    Changed all references to snprintf to LSF_SNPRINTF and all vsnprintf to 
+    LSF_VSNPRINTF. LSF_VSNPRINTF and LSF_VSNPRINTF are defined in common.h.
+
+    * src/common.h
+    Added checking of HAVE_SNPRINTF and HAVE_VSNPRINTF and defining LSF_VSNPRINTF 
+    and LSF_VSNPRINTF to appropriate values.
+
+    * src/missing.c
+    New file containing a minimal implementation of snprintf and vsnprintf functions 
+    named missing_snprintf and missing_vsnprintf respectively. These are only 
+    compliled into the binary if snprintf and/or vsnprintf are not available.
+
+2001-09-29  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/ircam.c 
+    New file to handle Berkeley/IRCAM/CARL files.
+
+    * src/sndfile.c src/common.h
+    Modified for IRCAM handling.
+
+    * tests/*.c
+    Added tests for IRCAM files.
+
+2001-09-27  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/wav.c
+    Apparently microsoft windows (tm) doesn't like ulaw and Alaw WAV files with 
+    20 byte format chunks (contrary to ms's own documentation). Fixed the WAV 
+    header writing code to generate smaller ms compliant ulaw and Alaw WAV files.
+
+2001-09-17  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * tests/stdio_test.sh tests/stdio_test.c
+    Shell script was rewritten as a C program due to incompatibilities of the sh
+    shell on Linux and Solaris.
+
+2001-09-16  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * tests/stdio_test.sh tests/stdout_test.c tests/stdin_test.c
+    New test programs to verify the correct operation of reading from stdin and 
+    writing to stdout.
+
+    * src/sndfile.c wav.c au.c nist.c paf.c
+    Fixed a bugs uncovered by the new test programs above.
+
+2001-09-15  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/sndfile.c wav.c
+    Fixed a bug preventing reading a file from stdin. Found by T. Narita.
+
+2001-09-12  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/common.h
+    Fixed a problem on OpenBSD 2.9 which was causing sf_seek() to fail on IMA WAV
+    files. Root cause was the declaration of the func_seek typedef not matching the 
+    functions it was actually being used to point to. In OpenBSD sizeof (off_t) != 
+    sizeof (int). Thanks to Heikki Korpela for allowing me to log into his OpenBSD
+    machine to debug this problem.
+
+2001-09-03  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/sndfile.c 
+    Implemented sf_command ("norm float").
+
+    * src/*.c
+    Implemented handling of sf_command ("norm float"). Float normalization can now
+    be turned on and off.
+
+    * tests/double_test.c
+    Renamed to floating_point_test.c. Modified to include tests for all scaled reads 
+    and writes of floats and doubles.
+
+    * src/au_g72x.c
+    Fixed bug in normalization code found with improved floating_point_test program.
+
+    * src/wav.c
+    Added code for parsing 'INFO' and 'LIST' chunks. Will be used for extract text 
+    annotations from WAV files.
+
+    * src/aiff.c
+    Added code for parsing '(c) ' and 'ANNO' chunks. Will be used for extract text 
+    annotations from WAV files.
+
+2001-09-02  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * examples/sf_info.c example/Makefile.am
+    Renamed to sndfile_info.c. The program sndfile_info will now be installed when the 
+    library is installed.
+
+    * src/floatcast.h
+    New file defining floating point to short and int casts. These casts will
+    eventually replace all flot and double casts to short and int. See comments at
+    the top of the file for the reasoning.
+    
+    * src/*.c
+    Changed all default float and double casts to short or int with macros defined
+    in floatcast.h. At the moment these casts do nothing. They will be replaced 
+    with faster float to int cast operations in the near future.
+
+2001-08-31  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+    
+    * tests/command_test.c
+    New file for testing sf_command () functionality.
+
+    * src/sndfile.c
+    Revisiting of error return values of some functions.
+    Started implementing sf_command () a new function will allow on-the-fly modification
+    of library behaviour, or instance, sample value scaling.
+
+    * src/common.h
+    Added hook for format specific sf_command () calls to SNDFILE struct.
+    
+    * doc/api.html
+    Updated and errors corrected.
+    
+    * doc/command.html
+    New documentation file explaining new sf_command () function.
+
+2001-08-11  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+    
+    * src/sndfile.c
+    Fixed error return values from sf_read*() and sf_write*(). There were numerous
+    instances of -1 being returned through size_t. These now all set error int the
+    SF_PRIVATE struct and return 0. Thanks to David Viens for spotting this.
+
+2001-08-01  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+    
+    * src/common.c
+    Fixed use of va_arg() calls that were causing warning messages with the latest
+    version of gcc (thanks Maurizio Umberto Puxeddu).
+
+2001-07-25  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+    
+    * src/*.c src/sfendian.h 
+    Moved definition of MAKE_MARKER macro to sfendian.h
+
+2001-07-23  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+    
+    * src/sndfile.c
+    Modified sf_get_lib_version () so that version string will be visible using the
+    Unix strings command.
+
+    * examples/Makefile.am examples/sfinfo.c
+    Renamed sfinfo program and source code to sf_info. This prevents a name clash
+    with the program included with libaudiofile.
+
+2001-07-22  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * tests/read_seek_test.c tests/lossy_comp_test.c
+    Added tests for sf_read_float () and sf_readf_float ().
+
+    * src/voc.c
+    New files for handling Creative Voice files (not complete).
+
+    * src/samplitude.c
+    New files for handling Samplitude files (not complete).
+ 
+2001-07-21  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/aiff.c src/au.c src/paf.c src/svx.c src/wav.c
+    Converted these files to using psf_binheader_readf() function. Will soon be ready
+    to make reading writing from pipes work reliably.
+
+    * src/*.[ch]
+    Added code for sf_read_float () and sf_readf_float () methods of accessing 
+    file data.
+    
+2001-07-20  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/paf.c src/wav_gsm610.c
+    Removed two printf()s which had escaped notice for some time (thanks Sigbj�rn 
+    Skj�ret).
+
+2001-07-19  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/wav_gsm610.c
+    Fixed a bug which prevented GSM 6.10 encoded WAV files generated by libsndfile from 
+    being played in Windoze (thanks klay).
+
+2001-07-18  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/common.[ch]
+    Implemented psf_binheader_readf() which will do for file header reading what
+    psf_binheader_writef() did for writing headers. Will eventually allow
+    libsndfile to read and write from pipes, including named pipes.
+
+2001-07-16  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * MacOS/config.h Win32/config.h
+    Attempted to bring these two files uptodate with src/config.h. As I don't have
+    access to either of these systems support for them may be completely broken.
+
+2001-06-18  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/float32.c
+    Fixed bug for big endian processors that can't read 32 bit IEEE floats. Now tested 
+    on Intel x86 and UltraSparc processors.
+
+2001-06-13  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/aiff.c
+    Modified to allow REX files (from Propellorhead's Recycle and Reason programs) to 
+    be read.
+    REX files are basically an AIFF file with slightly unusual sequence of chunks
+    (AIFF files are supposed to allow any sequence) and some extra  application 
+    specific information. 
+    Not yet able to write a REX file as the details of the application specific
+    data is unknown.
+
+2001-06-12  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/wav.c
+    Fixed endian bug when reading PEAK chunk on big endian machines.
+
+    * src/common.c
+    Fixed endian bug when reading PEAK chunk on big endian machines with 
+    --enable-force-broken-float configure option.
+    Fix psf_binheader_writef for (FORCE_BROKEN_FLOAT ||______)
+
+2001-06-07  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * configure.in src/config.h.in
+    Removed old CAN_READ_WRITE_x86_IEEE configure variable now that float capabilities
+    are detected at run time.
+    Added FORCE_BROKEN_FLOAT to allow testing of broken float code on machines where
+    the processor can in fact handle floats correctly. 
+    
+    * src/float32.c
+    Rejigged code reading and writing of floats on broken processors.
+    
+    * m4/
+    Removed this directory and all its files as they are no longer needed.
+
+2001-06-05  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * tests/peak_chunk_test.c
+    New test to validate reading and writing of peak chunk.
+    
+    * examples/sfconvert
+    Added -float32 option.
+
+    * src/*.c
+    Changed all error return values to negative values (ie the negative of what they
+    were). 
+    
+    * src/sndfile.c tests/error_test.c
+    Modified to take account of the previous change.
+
+2001-06-04  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/float32.c
+    File renamed from wav_float.c and renamed function to something more general.
+    Added runtime detection of floating point capabilities. 
+    Added recording of peaks during write for generation of PEAK chunk. 
+    
+    * src/wav.c src/aiff.c
+    Added handing for PEAK chunk for floating point files. PEAK is read when the
+    file headers are read and generated when the file is closed. Logic is in place
+    for adding PEAK chunk to end of file when writing to a pipe (reading and writing 
+    from/to pipe to be implemented soon).
+
+    * src/sndfile.c
+    Modified sf_signal_max () to use PEAK values if present.
+
+2001-06-03  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/*.c
+    Added pcm_read_init () and pcm_write_init () to src/pcm.c and removed all other calls
+    to functions in this file from the filetype specific files.
+    
+    * src/*.c
+    Added alaw_read_init (), alaw_write_int (), ulaw_read_init () and ulaw_write_init () 
+    and removed all other calls to functions in alaw.c and ulaw.c from the filetype 
+    specific files.
+    
+    * tests/write_read_test.c
+    Added tests to validate sf_seek () on all file types.
+
+    * src/raw.c
+    Implemented raw_seek () function to fix a bug where sf_seek (file, 0, SEEK_SET) on a 
+    RAW file failed.
+
+    * src/paf.c
+    Fixed a bug in paf24_seek () found due to added seeks tests in tests/write_read_test.c
+
+2001-06-01  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * tests/read_seek_test.c
+    Fixed a couple of broken binary files.
+
+    * src/aiff.c src/wav.c
+    Added handling of PEAK chunks on file read.
+
+2001-05-31  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * check_libsndfile.py
+    New file for the regression testing of libsndfile. 
+    check_libsndfile.py is a Python script which reads in a file containing 
+    filenames of audio files. Each file is checked by running the examples/sfinfo 
+    program on them and checking for error or warning messages in the libsndfile 
+    log buffer.
+
+    * check_libsndfile.list
+    This is an example list of audio files for use with check_libsndfile.py
+
+    * tests/lossy_comp_test.c
+    Changed the defined value of M_PI for math header files which don't have it.
+    This fixed validation test failures on MetroWerks compilers. Thanks to Lord 
+    Praetor Satanus of Acheron for bringing this to my attention.
+
+2001-05-30  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/common.[ch]
+    Removed psf_header_setf () which was no longer required after refactoring
+    and simplification of header writing.
+    Added 'z' format specifier to psf_binheader_writef () for zero filling header 
+    with N bytes. Used by paf.c and nist.c
+
+    * tests/check_log_buffer.c
+    New file implementing check_log_buffer () which reads the log buffer of a SNDFILE*
+    object and searches for error and warning messages. Calls exit () if any are found.
+
+    * tests/*.c 
+    Added calls to check_log_buffer () after each call to sf_open_XXX ().
+
+2001-05-29  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/wav.c src/wav_ms_adpcm.c src/wav_gsm610.c
+    Major rehack of header writing using psf_binheader_writef ().
+
+2001-05-28  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/wav.c src/wav_ima_adpcm.c
+    Major rehack of header writing using psf_binheader_writef ().
+
+2001-05-27  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/wav.c
+    Changed return type of get_encoding_str () to prevent compiler warnings on
+    Mac OSX.
+
+    * src/aiff.c src/au.c
+    Major rehack of header writing using psf_binheader_writef ().
+
+2001-05-25  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/common.h src/common.c
+    Added comments.
+    Name of log buffer changed from strbuffer to logbuffer.
+    Name of log buffer index variable changed from strindex to logindex.
+
+    * src/*.[ch]
+    Changed name of internal logging function from psf_sprintf () to psf_log_printf ().
+    Changed name of internal header generation functions from psf_[ab]h_printf () to 
+    psf_asciiheader_printf () and psf_binheader_writef ().
+    Changed name of internal header manipulation function psf_hsetf () to 
+    psf_header_setf (). 
+
+2001-05-24  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/nist.c
+    Fixed reading and writing of sample_byte_format header. "01" means little endian 
+    and "10" means big endian regardless of bit width.
+
+    * configure.in
+    Detect Mac OSX and disable -Wall and -pedantic gcc options. Mac OSX is way screwed
+    up and spews out buckets of warning messages from the system headers.
+    Added --disable-gcc-opt configure option (sets gcc optimisation to -O0 ) for 
+    easier debugging.
+    Made decision to harmonise source code version number and .so library version
+    number. Future releases will stick to this rule.
+
+    * doc/new_file_type.HOWTO
+    New file to document the addition of new file types to libsndfile.
+
+2001-05-23  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/nist.c
+    New file for reading/writing Sphere NIST audio file format.
+    Originally requested by Elis Pomales in 1999. 
+    Retrieved from unstable (and untouched for 18 months) branch of libsndfile.
+    Some vital information gleaned from the source code to Bill Schottstaedt's sndlib 
+    library : ftp://ccrma-ftp.stanford.edu/pub/Lisp/sndlib.tar.gz
+    Currently reading and writing 16, 24 and 32 bit, big-endian and little endian, 
+    stereo and mono files. 
+
+    * src/common.h src/common.c
+    Added psf_ah_printf () function to help construction of ASCII headers (ie NIST).
+
+    * configure.in
+    Added test for vsnprintf () required by psf_ah_printf ().
+
+    * tests/write_read_test.c
+    Added tests for supported NIST files.
+
+2001-05-22  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * tests/write_read_test.c
+    Added tests for little endian AIFC files.
+
+    * src/aiff.c
+    Minor re-working of aiff_open_write ().
+    Added write support for little endian PCM encoded AIFC files.
+
+2001-05-13  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/aiff.c
+    Minor re-working of aiff_open_read ().
+    Added read support for little endian PCM encoded AIFC files from the Mac OSX CD ripper 
+    program. Guillaume Lessard provided a couple of sample files and a working patch. 
+    The patch was not used as is but gave a good guide as to what to do. 
+
+2001-05-13  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/aiff.c
+    Added support for little endian encoded AIFC files. Guillaume Lessard provided a couple
+    of sample files and a working patch. The patch was not used as is but gave a good guide
+    as to what to do. 
+
+2001-05-11  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/sndfile.h
+    Fixed comments about endian-ness of WAV and AIFF files. Guillaume Lessard pointed 
+    out the error.
+
+2001-04-23  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * examples/make_sine.c
+    Re-write of this example using sample rate and required frequency in Hz.
+
+2001-02-11  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/sndfile.c
+    Fixed bug that prevented known file types from being read as RAW PCM data.
+
+2000-12-16  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/aiff.c
+    Added handing of COMT chunk.
+
+2000-11-16  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * examples/sfconvert.c
+    Fixed bug in normalisatio code. Pointed out by Johnny Wu.
+
+2000-11-08  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * Win32/config.h
+    Fixed the incorrect setting of HAVE_ENDIAN_H parameter. Win32 only issue.
+
+2000-10-27  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * tests/Makefile.am
+    Added -lm for write_read_test_LDADD.
+
+2000-10-16  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * src/sndfile.c src/au.c
+    Fixed bug which prevented writing of G723 24kbps AU files.
+
+    * tests/lossy_comp_test.c
+    Corrrection to options for G723 tests.
+
+    * configure.in
     Added --disable-gcc-pipe option for DJGPP compiler (gcc on MS-DOS) which 
-	doesn't allow gcc -pipe option.
+    doesn't allow gcc -pipe option.
 
-2000-09-03  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-09-03  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
-	* src/ulaw.c src/alaw.c src/wav_imaadpcm.c src/msadpcm.c src/wav_gsm610.c
-	Fixed normailsation bugs shown up by new double_test program.
+    * src/ulaw.c src/alaw.c src/wav_imaadpcm.c src/msadpcm.c src/wav_gsm610.c
+    Fixed normailsation bugs shown up by new double_test program.
 
-2000-08-31  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-08-31  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/pcm.c
     Fixed bug in normalisation code (spotted by Steve Lhomme).
 
     * tests/double_test.c
-	New file to test scaled and unscaled sf_read_double() and sf_write_double()
-	functions.
+    New file to test scaled and unscaled sf_read_double() and sf_write_double()
+    functions.
 
-2000-08-28  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-08-28  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * COPYING
     Changed to the LGPL COPYING file (spotted by H. S. Teoh).
 
-2000-08-21  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-08-21  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/sndfile.h
     Removed prototype of unimplemented function sf_get_info(). Added prototype for
     sf_error_number() Thanks to Sigbj�rn Skj�ret for spotting these.
 
-2000-08-18  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-08-18  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/newpcm.h
     New file to contain a complete rewrite of the PCM data handling.
 
-2000-08-15  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-08-15  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/sndfile.c
     Fixed a leak of FILE* pointers in sf_open_write(). Thanks to Sigbj�rn Skj�ret
     for spotting this one.
 
-2000-08-15  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-08-15  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/sndfile.c
     Fixed a leak of FILE* pointers in sf_open_read(). Thanks to Sigbj�rn Skj�ret
     for spotting this one.
 
-2000-08-13  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-08-13  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/au_g72x.c src/G72x/g72x.c
     Added G723 encoded AU file support.
-    
+
     * tests/lossy_comp_test.c
     Added tests for G721 and G723 encoded AU files.
 
-2000-08-06  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-08-06  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * all files
     Changed the license to LGPL. Albert Faber who had copyright on Win32/unistd.h
     gave his permission to change the license on that file. All other files were
-    either copyright erikd@zip.com.au or copyright under a GPL/LGPL compatible
+    either copyright erikd AT zip DOT com DOT au or copyright under a GPL/LGPL compatible
     license.
 
-2000-08-06  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-08-06  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * tests/lossy_comp_test.c
     Fixed incorrect error message.
-    
+
     * src/au_g72x.c src/G72x/*
     G721 encoded AU files now working.
-    
+
     * Win32/README-Win32.txt
     Replaced this file with a new one which gives a full explanation
     of how to build libsndfile under Win32. Thanks to Mike Ricos.
 
-2000-08-05  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-08-05  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/*.[ch]
     Removed double leading underscores from the start of all variable and
     function names. Identifiers with a leading underscores are reserved
     for use by the compiler.
-    
+
     * src/au_g72x.c src/G72x/*
     Continued work on G721 encoded AU files.
 
-2000-07-12  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-07-12  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/G72x/*
     New files for reading/writing G721 and G723 ADPCM audio. These files 
@@ -98,42 +624,42 @@
     free software licence.
     Extensive changes to this code to make it fit in with libsndfile.
     See the ChangeLog in this directory for details.
-    
+
     * src/au_g72x.c
     New file for G721 encoded AU files.
-    
-2000-07-08  Erik de Castro Lopo  <erikd@zip.com.au>
 
+2000-07-08  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * libsndfile.spec.in
     Added a spec file for making RPMs. Thanks to Josh Green for supplying this.
 
-2000-06-28  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-06-28  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/sndfile.c src/sndfile.h
     Add checking for and handling of header-less u-law encoded AU/SND files.
     Any file with a ".au" or ".snd" file extension and without the normal
     AU file header is treated as an 8kHz, u-law encoded file.
-    
+
     * src/au.h
     New function for opening a headerless u-law encoded file for read.
-    
-2000-06-04  Erik de Castro Lopo  <erikd@zip.com.au>
 
+2000-06-04  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * src/paf.c
     Add checking for files shorter than minimal PAF file header length.
 
-2000-06-02  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-06-02  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * tests/write_read_test.c
     Added extra sf_perror() calls when sf_write_XXXX fails.
 
-2000-05-29  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-05-29  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/common.c
     Modified usage of va_arg() macro to work correctly on PowerPC 
     Linux. Thanks to Kyle Wheeler for giving me ssh access to his 
     machine while I was trying to track this down.
-    
+
     * configure.in src/*.[ch]
     Sorted out some endian-ness issues brought up by PowerPC Linux.
 
@@ -140,51 +666,51 @@
     * tests/read_seek_test.c
     Added extra debugging for when tests fail.
 
-2000-05-18  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-05-18  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/wav.c
     Fixed bug in GSM 6.10 handling for big-endian machines. Thanks
     to Sigbj�rn Skj�ret for reporting this.
-    
-2000-04-25  Erik de Castro Lopo  <erikd@zip.com.au>
 
+2000-04-25  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * src/sndfile.c src/wav.c src/wav_gsm610.c
     Finallised writing of GSM 6.10 WAV files.
-    
+
     * tests/lossy_comp_test.c
     Wrote new test code for GSM 6.10 files. 
-    
+
     * examples/sfinfo.c
     Fixed incorrect format in printf() statement.
 
-2000-04-06  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-04-06  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/sndfile.h.in
     Fixed comments about sf_perror () and sf_error_str ().
 
-2000-03-14  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-03-14  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * configure.in
     Fixed --enable-justsrc option.
 
-2000-03-07  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-03-07  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * wav.c
     Fixed checking of bytespersec field of header. Still some weirdness
     with some files.
 
-2000-03-05  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-03-05  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * tests/lossy_comp_test.c
     Added option to test PCM WAV files (sanity check).
     Fixed bug in sf_seek() tests.
 
-2000-02-29  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-02-29  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/sndfile.c src/wav.c
     Minor changes to allow writing of GSM 6.10 WAV files.
 
-2000-02-28  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-02-28  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * configure.in Makefile.am src/Makefile.am
     Finally got around to figuring out how to build a single library from 
@@ -191,44 +717,44 @@
     multiple source directories.
     Reading GSM 6.10 files now seems to work.
 
-2000-01-03  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-01-03  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/wav.c
     Added more error reporting in read_fmt_chunk().
 
-1999-12-21  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-12-21  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * examples/sfinfo.c
     Modified program to accept multiple filenames from the command line.
 
-1999-11-27  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-11-27  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/wav_ima_adpcm.c
     Moved code around in preparation to adding ability to read/write IMA ADPCM
     encoded AIFF files.
 
-1999-11-16  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-11-16  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/common.c
     Fixed put_int() and put_short() macros used by _psf_hprintf() which were 
     causing seg. faults on Sparc Solaris.
 
-1999-11-15  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-11-15  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/common.c
     Added string.h to includes. Thanks to Sigbjxrn Skjfret.
-    
+
     * src/svx.c
     Fixed __svx_close() function to ensure FORM and BODY chunks are correctly
     set.
 
-1999-10-01  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-10-01  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/au.c
     Fixed handling of incorrect size field in AU header on read. Thanks to 
     Christoph Lauer for finding this problem.
 
-1999-09-28  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-09-28  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/aiff.c
     Fixed a bug with incorrect SSND chunk length being written. This also lead
@@ -235,7 +761,7 @@
     to finding an minor error in AIFF header parsing. Thanks to Dan Timis for 
     pointing this out.
 
-1999-09-24  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-09-24  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/paf.c
     Fixed a bug with reading and writing 24 bit stereo PAF files. This problem
@@ -242,23 +768,23 @@
     came to light when implementing tests for the new functions which operate
     in terms of frames rather than items.
 
-1999-09-23  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-09-23  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/sndfile.c
     Modified file type detection to use first 12 bytes of file rather than 
     file name extension. Required this because NIST files use the same 
     filename extension as Microsoft WAV files.
-    
+
     * src/sndfile.c src/sndfile.h
     Added short, int and double read/write functions which work in frames rather 
     than items. This was originally suggested by Maurizio Umberto Puxeddu
-    
-1999-09-22  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-09-22  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * src/svx.c
     Finished off implementation of write using __psf_hprintf().
 
-1999-09-21  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-09-21  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/common.h
     Added a buffer to SF_PRIVATE for writing the header. This is required
@@ -269,14 +795,14 @@
     * src/common.c
     Implemented __psf_hprintf() function. This is an internal function
     which is documented briefly just above the code.
-    
-1999-09-05  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-09-05  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * src/sndfile.c
     Fixed a bug in sf_write_raw() where it was returning incorrect values
     (thanks to Richard Dobson for finding this one). Must put in a test 
     routine for sf_read_raw and sf_write_raw.
-    
+
     * src/aiff.c
     Fixed default FORMsize in __aiff_open_write ().
 
@@ -285,11 +811,11 @@
     contain a NAME header chunk. Both sf_open_read() and sf_open_write()
     copy the file name (less the leading path information) to the
     filename field.
-    
+
     * src/svx.c
     Started implementing writing of files.
 
-1999-08-04  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-08-04  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/svx.c
     New file for reading/writing 8SVX and 16SVX files.
@@ -296,28 +822,28 @@
 
     * src/sndfile.[ch] src/common.h
     Changes for SVX files.
-    
+
     * src/aiff.c
     Fixed header parsing when unknown chunk is found.
-    
-1999-08-01  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-08-01  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * src/paf.c
     New file for reading/writing Ensoniq PARIS audio file format.
-    
+
     * src/sndfile.[ch] src/common.h
     Changes for PAF files.
-    
+
     * src/sndfile.[ch]
     Added stuff for sf_get_lib_version() function.
 
 
-1999-07-31  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-07-31  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/sndfile.h MacOS/config.h
     Fixed minor MacOS configuration issues.
 
-1999-07-30  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-07-30  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * MacOS/
     Added a new directory for the MacOS config.h file and the
@@ -327,12 +853,12 @@
     Fixed calculation of datalength when reading SSND chunk. Thanks to
     Sigbj�rn Skj�ret for pointing out this error.
 
-1999-07-29  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-07-29  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/sndfile.c src/sndfile.h src/raw.c
     Further fixing of #includes for MacOS.
 
-1999-07-25  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-07-25  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/wav.c src/aiff.c
     Added call to ferror () in main header parsing loop of __XXX_open_read
@@ -339,10 +865,10 @@
     functions. This should fix problems on platforms (MacOS, AmigaOS) where 
     fseek()ing or fread()ing beyond the end of the file puts the FILE*
     stream in an error state until clearerr() is called.
-    
+
     * tests/write_read_test.c
     Added tests for RAW header-less PCM files.
-    
+
     * src/common.h
     Moved definition of struct tribyte to pcm.c which is the only place
     which needs it.
@@ -353,74 +879,74 @@
 
     * src/au.c
     Removed <sys/stat.h> from list of #includes (not being used).
-    
+
     * src/sndfile.c
     Added MacOS specific #ifdef to replace <sys/stat.h>.
-    
+
     * src/sndfile.h
     Added MacOS specific #ifdef to replace <sys/stat.h>.
-    
+
     * src/sndfile.h
     Added MacOS specific typedef for off_t.
-    
+
     * MacOS-readme.txt
     New file with instructions for building libsndfile under MacOS. Thanks
     to Ben "Jacobs" for supplying these instructions.
-    
-1999-07-24  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-07-24  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * configure.in
     Removed sndfile.h from generated file list as there were no longer
     any autoconf substitutions being made.
-    
+
     * src/raw.c
     New file for handling raw header-less PCM files. In order to open these
     for read, the user must specify format, pcmbitwidth and channels in the
     SF_INFO struct when calling sf_open_read ().
-    
+
     * src/sndfile.c
     Added support for raw header-less PCM files.    
-    
-1999-07-22  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-07-22  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * examples/sfinfo.c
     Removed options so the sfinfo program always prints out all the information.
-    
-1999-07-19  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-07-19  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * src/alaw.c
     New file for A-law encoding (similar to u-law).
-    
+
     * tests/alaw_test.c
     New test program to test the A-law encode/decode lookup tables.
-    
+
     * tests/lossy_comp_test.c
     Added tests for a-law encoded WAV, AU and AULE files.
-    
-1999-07-18  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-07-18  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * src/sndfile.c src/au.c
     Removed second "#include <unistd.h>". Thanks to Ben "Jacobs" for pointing
     this out.
 
-1999-07-18  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-07-18  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * tests/ulaw_test.c
     New test program to test the u-law encode/decode lookup tables.
 
-1999-07-16  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-07-16  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/sndfile.h
     Made corrections to comments on the return values from sf_seek ().
-    
+
     * src/sndfile.c
     Fixed boundary condition checking bug and accounting bug in sf_read_raw ().
 
-1999-07-15  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-07-15  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/au.c src/ulaw.c
     Finished implementation of u-law encoded AU files.
-    
+
     * src/wav.c
     Implemented reading and writing of u-law encoded WAV files.
 
@@ -429,26 +955,26 @@
     will now be used to test Ulaw and Alaw encoding as well as APDCM.
     Added tests for Ulaw encoded WAV files.
 
-1999-07-14  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-07-14  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * tests/adpcm_test.c
     Initialised amp variable in gen_signal() to remove compiler warning.
-    
-1999-07-12  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-07-12  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * src/aiff.c
     In __aiff_open_read () prevented fseek()ing beyond end of file which 
     was causing trouble on MacOS with the MetroWerks compiler. Thanks to
     Ben "Jacobs" for pointing this out.
-    
+
     *src/wav.c
     Fixed as above in __wav_open_read ().
 
-1999-07-01    Erik de Castro Lopo  <erikd@zip.com.au>
+1999-07-01    Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/wav_ms_adpcm.c
     Implemented MS ADPCM encoding. Code cleanup of decoder.
-    
+
     * tests/adpcm_test.c
     Added tests for MS ADPCM WAV files.
 
@@ -455,13 +981,13 @@
     * src/wav_ima_adpcm.c
     Fixed incorrect parameter in call to srate2blocksize () from
     __ima_writer_init ().
-    
-1999-06-23  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-06-23  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * tests/read_seek_test.c
     Added test for 8 bit AIFF files.
 
-1999-06-18  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-06-18  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * tests/write_read_test.c
     Removed test for IMA ADPCM WAV files which is now done in adpcm_test.c
@@ -468,11 +994,11 @@
 
     * configure.in
     Added -Wconversion to CFLAGS. 
-    
+
     * src/*.c tests/*.c examples/*.c
     Fixed all warnings resulting from use of -Wconversion. 
 
-1999-06-17  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-06-17  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/wav.c
     Added fact chunk handling on read and write for all non WAVE_FORMAT_PCM
@@ -482,27 +1008,27 @@
     Changed block alignment to be dependant on sample rate. This should make
     WAV files created with libsndfile compatible with the MS Windows media
     players.
-    
+
     * tests/adpcm_test.c
     Reimplemented adpcm_test_short and implemented adpcm_test_int and adpcm_test_double.
     Now have full testing of IMA ADPCM WAV file read, write and seek.
 
-1999-06-15  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-06-15  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/wav_float.c
     Fixed function prototype for x86f2d_array () which was causing ocassional 
     seg. faults on Sparc Solaris machines.
 
-1999-06-14  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-06-14  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/aiff.c
     Fixed bug in __aiff_close where the length fields in the header were
     not being correctly calculated before writing.
-    
+
     * tests/write_read_test.c
     Modified to detect the above bug in WAV, AIFF and AU files.
 
-1999-06-12    Erik de Castro Lopo     <erikd@zip.com.au>
+1999-06-12    Erik de Castro Lopo     <erikd AT zip DOT com DOT au>
 
     * Win32/*
     Added a contribution from Albert Faber to allow libsndfile to compile
@@ -509,40 +1035,40 @@
     under Win32 systems. libsndfile will now be used as part of LAME the
     the MPEG 1 Layer 3 encoder (http://internet.roadrunner.com/~mt/mp3/).
 
-1999-06-11    Erik de Castro Lopo  <erikd@zip.com.au>
+1999-06-11    Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * configure.in
     Changed to reflect previous changes.
-    
+
     * src/wav_ima_adpcm.c
     Fixed incorrect calculation of bytespersec header field (IMA ADPCM only).
-    
+
     Fixed bug when writing from int or double data to IMA ADPCM file. Will need 
     to write test code for this.
-    
+
     Fixed bug in __ima_write () whereby the length of the current block was 
     calculated incorrectly. Thanks to Jongcheon Park for pointing this out.
 
-1999-03-27  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-03-27  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/*.c
     Changed all read/write/lseek function calls to fread/fwrite/
     fseek/ftell and added error checking of return values from
     fread and fwrite in critical areas of the code.
-    
+
     * src/au.c
     Fixed incorrect datasize element in AU header on write.
-    
+
     * tests/error_test.c
     Add new test to check all error values have an associated error
     string. This will avoid embarrassing real world core dumps.
 
-1999-03-23  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-03-23  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/wav.c src/aiff.c
     Added handling for unknown chunk markers in the file. 
 
-1999-03-22  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-03-22  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/sndfile.c
     Filled in missing error strings in SndfileErrors array. Missing entries 
@@ -549,7 +1075,7 @@
     can cause core dumps when calling sf_error-str (). Thanks to Sam 
     <mrsam at-sign geocities.com> for finding this problem.
 
-1999-03-21  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-03-21  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/wav_ima_adpcm.c
     Work on wav_ms_adpcm.c uncovered a bug in __ima_read () when reading 
@@ -556,16 +1082,16 @@
     stereo files. Caused by not adjusting offset into buffer of decoded
     samples for 2 channels. A similar bug existed in __ima_write ().
     Need a test for stereo ADPCM files.
-    
+
     * src/wav_ms_adpcm.c
     Decoder working correctly.
-    
-1999-03-18  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-03-18  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * configure.in Makefile.am
     Added --enable-justsrc configuration variable sent by Sam
     <mrsam at-sign geocities.com>.
-    
+
     * src/wav_ima_adpcm.c
     Fixed bug when reading beyond end of data section due to not
     checking pima->blockcount.
@@ -572,7 +1098,7 @@
     This uncovered __ima_seek () bug due to pima->blockcount being set 
     before calling __ima_init_block ().
 
-1999-03-17  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-03-17  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/wav.c
     Started implementing MS ADPCM decoder. 
@@ -580,7 +1106,7 @@
     encoder seems to add an extra byte. Why not just give an even data
     length? 
 
-1999-03-16  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-03-16  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/wav.c
     Split code out of wav.c to create wav_float.c and wav_ima_adpcm.c.
@@ -587,7 +1113,7 @@
     This will make it easier to add and debug other kinds of WAV files
     in future.
 
-1999-03-14  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-03-14  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * tests/
     Added adpcm_test.c which implements test functions for
@@ -595,18 +1121,18 @@
 
     * src/wav.c
     Fixed many bugs in IMA ADPCM encoder and decoder. 
-    
-1999-03-11  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-03-11  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * src/wav.c
     Finished implementing IMA ADPCM encoder and decoder (what a bitch!). 
-    
-1999-03-03  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-03-03  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * src/wav.c
     Started implementing IMA ADPCM decoder. 
 
-1999-03-02  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-03-02  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/sndfile.c
     Fixed bug where the sf_read_XXX functions were returning a 
@@ -619,7 +1145,7 @@
     Added extra chunk to all test WAV files to test that reading
     stops at end of 'data' chunk.
 
-1999-02-21  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-02-21  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * tests/write_read_test.c
     Added tests for little DEC endian AU files.
@@ -626,12 +1152,12 @@
 
     * src/au.c
     Add handling for DEC format little endian AU files.
-     
-1999-02-20  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-02-20  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * src/aiff.c src/au.c src/wav.c
     Add __psf_sprintf calls during header parsing.
-     
+
     * src/sndfile.c src/common.c
     Implement sf_header_info (sndfile.c) function and __psf_sprintf (common.c).
 
@@ -640,12 +1166,12 @@
 
     * src/au.c src/aiff.c
     Add handling of 8 bit PCM data format.
-     
+
     * src/aiff.c
     On write, set blocksize in SSND chunk to zero like everybody else.
-    
-1999-02-16  Erik de Castro Lopo  <erikd@zip.com.au>
 
+1999-02-16  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * src/pcm.c:
     Fixed bug in let2s_array (cptr was not being initialised).
 
@@ -653,22 +1179,22 @@
     Fixed bug in sf_read_raw and sf_write_raw. sf_seek should
     now work when using these functions.
 
-1999-02-15  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-02-15  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * tests/write_read_test.c:
     Force test_buffer array to be double aligned. Sparc Solaris
     requires this.
 
-1999-02-14  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-02-14  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/pcm.c:
     Fixed a bug which was causing errors in the reading
     and writing of 24 bit PCM files.
-    
+
     * doc/api.html
     Finished of preliminary documentaion.
 
-1999-02-13  Erik de Castro Lopo  <erikd@zip.com.au>
+1999-02-13  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * src/aiff.c:
     Changed reading of 'COMM' chunk to avoid reading an int
--- a/common/libsndfile/MacOS/MacOS-readme.txt
+++ b/common/libsndfile/MacOS/MacOS-readme.txt
@@ -1,5 +1,5 @@
-BUILDING LIBSNDFILE FOR MACINTOSH
----------------------------------
+BUILDING LIBSNDFILE FOR MACINTOSH (Pre Mac OSX)
+-----------------------------------------------
 
 These instructions are current as of libsndfile 0.0.16, and assume the
 following development environment:
@@ -15,8 +15,8 @@
 1. using CodeWarrior, create a new "Empty Project"
 
 2. obtain the libsndfile source distribution (see homepage URL below);
-   add all ".c" files found in the top level of the "src" folder to the
-   project
+   add all ".c" files found in the top level of the "src", "src/GSM610" and 
+   "src/G72x" folders to the project
 
 3. starting from the factory defaults, adjust the following project
    settings:
@@ -27,7 +27,7 @@
         file name = "libsndfile"
 
 4. grab the "config.h" file from the MacOS directory and replace the default
-   config.h file
+   config.h file in the "src" directory
 
 5. Make the project
 
--- a/common/libsndfile/MacOS/Makefile.in
+++ b/common/libsndfile/MacOS/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
 
 # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
@@ -66,11 +66,9 @@
 AS = @AS@
 CC = @CC@
 DLLTOOL = @DLLTOOL@
-LD = @LD@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
 MAKEINFO = @MAKEINFO@
-NM = @NM@
 OBJDUMP = @OBJDUMP@
 PACKAGE = @PACKAGE@
 RANLIB = @RANLIB@
@@ -87,7 +85,7 @@
 
 DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
-TAR = gtar
+TAR = tar
 GZIP_ENV = --best
 all: all-redirect
 .SUFFIXES:
@@ -110,7 +108,7 @@
 	@for file in $(DISTFILES); do \
 	  d=$(srcdir); \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$/$$file $(distdir)/$$file; \
+	    cp -pr $$d/$$file $(distdir)/$$file; \
 	  else \
 	    test -f $(distdir)/$$file \
 	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
--- a/common/libsndfile/MacOS/config.h
+++ b/common/libsndfile/MacOS/config.h
@@ -15,7 +15,7 @@
 
 /* Define to `unsigned' if <sys/types.h> doesn't define.  */
 /* #undef size_t */
-
+
 /* Define if you have the ANSI C header files.  */
 #define STDC_HEADERS 1
 
@@ -23,29 +23,16 @@
 #ifdef __MWERKS__
 #ifdef _WIN32
 #define GUESS_BIG_ENDIAN 0
-#else
-#define GUESS_BIG_ENDIAN 1
-#endif
-#endif
-
-/* Set to 1 if the processor is little endian, otherwise set to 0.  */
-#ifdef __MWERKS__
-#ifdef _WIN32
 #define GUESS_LITTLE_ENDIAN 1
 #else
+#define GUESS_BIG_ENDIAN 1
 #define GUESS_LITTLE_ENDIAN 0
 #endif
 #endif
 
-/* Set to 1 if the processor can read and write Intel x86 32 bit floats.  */
+/* Set to 1 to force the use of code for processors with broken floats */
 /* Otherwise set it to 0.  */
-#ifdef __MWERKS__
-#ifdef _WIN32
-#define CAN_READ_WRITE_x86_IEEE 1
-#else
-#define CAN_READ_WRITE_x86_IEEE 0
-#endif
-#endif
+#define	FORCE_BROKEN_FLOAT 0
 
 /* The number of bytes in a double.  */
 #define SIZEOF_DOUBLE 8
@@ -89,6 +76,12 @@
 /* Define if you have the malloc function.  */
 #define HAVE_MALLOC 1
 
+/* Define if you have the snprintf function.  */
+#define HAVE_SNPRINTF 1
+
+/* Define if you have the vsnprintf function.  */
+#define HAVE_VSNPRINTF 1
+
 /* Define if you have the <endian.h> header file.  */
 #define HAVE_ENDIAN_H 1
 
@@ -96,5 +89,5 @@
 #define PACKAGE "libsndfile"
 
 /* Version number of package */
-#define VERSION "0.0.21"
+#define VERSION "0.0.26"
 
--- a/common/libsndfile/Makefile.am
+++ b/common/libsndfile/Makefile.am
@@ -1,3 +1,5 @@
-DIST_SUBDIRS = src examples doc tests Win32 MacOS m4
+DIST_SUBDIRS = src examples doc tests Win32 MacOS
 SUBDIRS = @subdirs@
-EXTRA_DIST = reconf acconfig.h libsndfile.spec.in libsndfile.spec
+EXTRA_DIST = reconf acconfig.h libsndfile.spec.in libsndfile.spec \
+			 check_libsndfile.py
+
--- a/common/libsndfile/Makefile.in
+++ b/common/libsndfile/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
 
 # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
@@ -66,11 +66,9 @@
 AS = @AS@
 CC = @CC@
 DLLTOOL = @DLLTOOL@
-LD = @LD@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
 MAKEINFO = @MAKEINFO@
-NM = @NM@
 OBJDUMP = @OBJDUMP@
 PACKAGE = @PACKAGE@
 RANLIB = @RANLIB@
@@ -78,9 +76,10 @@
 VERSION = @VERSION@
 subdirs = @subdirs@
 
-DIST_SUBDIRS = src examples doc tests Win32 MacOS m4
+DIST_SUBDIRS = src examples doc tests Win32 MacOS
 SUBDIRS = @subdirs@
-EXTRA_DIST = reconf acconfig.h libsndfile.spec.in libsndfile.spec
+EXTRA_DIST = reconf acconfig.h libsndfile.spec.in libsndfile.spec 			 check_libsndfile.py
+
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = ./src/config.h
@@ -93,7 +92,7 @@
 
 DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
-TAR = gtar
+TAR = tar
 GZIP_ENV = --best
 all: all-redirect
 .SUFFIXES:
@@ -107,7 +106,7 @@
 $(ACLOCAL_M4):  configure.in 
 	cd $(srcdir) && $(ACLOCAL)
 
-config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+config.status: $(srcdir)/configure.in $(CONFIG_STATUS_DEPENDENCIES)
 	$(SHELL) ./config.status --recheck
 $(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
 	cd $(srcdir) && $(AUTOCONF)
@@ -272,7 +271,7 @@
 	@for file in $(DISTFILES); do \
 	  d=$(srcdir); \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$/$$file $(distdir)/$$file; \
+	    cp -pr $$d/$$file $(distdir)/$$file; \
 	  else \
 	    test -f $(distdir)/$$file \
 	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
--- a/common/libsndfile/NEWS
+++ b/common/libsndfile/NEWS
@@ -1,3 +1,39 @@
+Version 0.0.26 (2001-09-30)
+  * Offical release.
+  * Changed how A-law and u-law WAV file headers are written to allow files generated
+    by libsndfile to be read by M$ windoze.
+  * Added IRCAM file support.
+  * Minor bug fixes.
+  * This will be the last release in the 0.0.X development stream apart from bug fixes.
+    A new deveopement stream with minor interface changes in already in development.
+
+Version 0.0.25 (2001-09-24)
+  * Offical release.
+  * Added sf_command () interface which allows switching normalisation on and off for
+    sf_read/write_float () methods.  
+  * Minor bug fixes.
+  * This will be the last release in the 0.0.X development stream apart from bug fixes.
+    A new deveopement stream with minor interface changes in already in development.
+
+Version 0.0.24 (2001-08-19)
+  * Offical release.
+  * Massive refactoring of header reading code for all file formats.
+  * Added sf_read_float () and sf_write_float () interfaces.
+  * Minor bug fixes.
+
+Version 0.0.23 (2001-07-06)
+  * Offical release.
+  * Massive refactoring of header writing code for all file formats.
+  * Added support for Sphere NIST.
+  * Added support for 32 bit float AIFF and little endian AIFF files (Mac OSX).
+  * Added read and write support for the PEAK chunk in 32 bit float AIFF and WAV files.
+  * Added support for REX files (Propellorheads Reason).
+  * Minor bug fixes.
+
+Version 0.0.22 (2000-10-17)
+  * Offical release.
+  * Bug fix in G723 AU file handling.
+
 Version 0.0.21 (2000-08-16)
   * Offical release.
   * AU files without the normal AU file header are now recognised as headerless
@@ -5,6 +41,7 @@
   * Added handling for G721 4bit APDCM encoded AU files.
   * Added handling for G723 3bit APDCM encoded AU files.
   * Improved Win32 compiling and use instructions from Mike Ricos.
+  * License change from GPL to LGPL.
 
 Version 0.0.20 (2000-05-30)
   * Offical release.
--- a/common/libsndfile/README
+++ b/common/libsndfile/README
@@ -1,4 +1,4 @@
-This is libsndfile, 0.0.16
+This is libsndfile, 0.0.26
 
 libsndfile is a library of C routines for reading and writing 
 files containing sampled audio data. 
@@ -29,6 +29,8 @@
 Bormann. Their original code can be found at :
     http://kbs.cs.tu-berlin.de/~jutta/toast.html
 
+The src/G72x directory contains code written and released by Sum Microsystems
+under a suitably free license.
 
 OTHER PLATFORMS
 ---------------
@@ -44,15 +46,16 @@
 create an approriate config.h file in the src/ directory with correct
 values for the following #defines  (this would work for AmigaOS) :
 
-#define __BIG_ENDIAN__ 1
-#define __LITTLE_ENDIAN__ 0
-#define CAN_READ_WRITE_x86_IEEE 0
+#define HAVE_ENDIAN_H 0
+#define GUESS_BIG_ENDIAN 1
+#define GUESS_LITTLE_ENDIAN 0
+#define FORCE_BROKEN_FLOAT 0
 
 
 CONTACTS
 --------
 
-libsndfile was written by Erik de Castro Lopo (erikd@zip.com.au).  
+libsndfile was written by Erik de Castro Lopo (erikd AT zip DOT com DOT au).  
 The libsndfile home page is at :
 
 	http://www.zip.com.au/~erikd/libsndfile/
--- a/common/libsndfile/TODO
+++ b/common/libsndfile/TODO
@@ -1,12 +1,10 @@
-Here's a list of what I (erikd@zip.com.au) think needs to be done. The
-list is by no means comprehensive and people are encouraged to email
-me with suggestions. 
+Here's a list of what I (erikd AT zip DOT com DOT au) think needs to be 
+done. The list is by no means exhaustive and people are encouraged to 
+email me with suggestions. 
 
   o Add pipe in/out capabilities. libsndfile should be able to read 
 	its input from a pipe and write its output to a pipe.
 
-  o Add autoconf type tests for IEEE read/write compatibility.
-        
   o Add checks of the error state after fseek???? Use ferror ().
 
   o Modify tests/lossy_comp_test.c to add tests for stereo files.
@@ -15,9 +13,9 @@
 
   o Improve testing routines. Must test all combinations of inputs
     and outputs.
-  
+
   o Test sf_seek function on write???
-  
+
   o Get hold of a couple of Sun/Next AU files containing 32 and 64 bit 
     floating point data write code to read and write them (well at least
     the 32 bit ones).
@@ -28,16 +26,16 @@
   o Add support for accessing sound formats with multiple audio
     data sections (ie samples within tracker files, Soundfont II and 
     multi-sample sampler formats). 
-    
+
   o Add an interface to allow reading and writing of sample loop points 
     and other info within AIFF and other file formats. This must be a 
     general solution.
 
   o Improve documentation. Is HTML documentation good enough?
-  
+
   o Look into the possibility of optional sample rate convert on file 
     read.
-    
+
 As I am the person who knows libsndfile best, I can probably implement 
 any new features faster than anybody else (and you can spend your time
 writing applications with libsndfile). All I need is some 
@@ -45,4 +43,4 @@
 me documentation and sample files. I would much rather pull them off
 the web than have them clogging up my email inbox.
 
-    
+
--- a/common/libsndfile/Win32/Makefile.in
+++ b/common/libsndfile/Win32/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
 
 # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
@@ -66,11 +66,9 @@
 AS = @AS@
 CC = @CC@
 DLLTOOL = @DLLTOOL@
-LD = @LD@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
 MAKEINFO = @MAKEINFO@
-NM = @NM@
 OBJDUMP = @OBJDUMP@
 PACKAGE = @PACKAGE@
 RANLIB = @RANLIB@
@@ -88,7 +86,7 @@
 
 DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
-TAR = gtar
+TAR = tar
 GZIP_ENV = --best
 all: all-redirect
 .SUFFIXES:
@@ -111,7 +109,7 @@
 	@for file in $(DISTFILES); do \
 	  d=$(srcdir); \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$/$$file $(distdir)/$$file; \
+	    cp -pr $$d/$$file $(distdir)/$$file; \
 	  else \
 	    test -f $(distdir)/$$file \
 	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
--- a/common/libsndfile/Win32/config.h
+++ b/common/libsndfile/Win32/config.h
@@ -15,7 +15,7 @@
 
 /* Define to `unsigned' if <sys/types.h> doesn't define.  */
 /* #undef size_t */
-
+
 /* Define if you have the ANSI C header files.  */
 #define STDC_HEADERS 1
 
@@ -25,9 +25,9 @@
 /* Set to 1 if the processor is little endian, otherwise set to 0.  */
 #define GUESS_LITTLE_ENDIAN 1
 
-/* Set to 1 if the processor can read and write Intel x86 32 bit floats.  */
+/* Set to 1 to force the use of code for processors with broken floats */
 /* Otherwise set it to 0.  */
-#define CAN_READ_WRITE_x86_IEEE 1
+#define FORCE_BROKEN_FLOAT 0
 
 /* The number of bytes in a double.  */
 #define SIZEOF_DOUBLE 8
@@ -71,6 +71,12 @@
 /* Define if you have the malloc function.  */
 #define HAVE_MALLOC 1
 
+/* Define if you have the snprintf function.  */
+#define HAVE_SNPRINTF 0
+
+/* Define if you have the vsnprintf function.  */
+#define HAVE_VSNPRINTF 0
+
 /* Define if you have the <endian.h> header file.  */
 #define HAVE_ENDIAN_H 0
 
@@ -78,5 +84,5 @@
 #define PACKAGE "libsndfile"
 
 /* Version number of package */
-#define VERSION "0.0.21"
+#define VERSION "0.0.26"
 
--- a/common/libsndfile/Win32/libsndfile.dsp
+++ b/common/libsndfile/Win32/libsndfile.dsp
@@ -25,7 +25,7 @@
 # PROP AllowPerConfigDependencies 0
 # PROP Scc_ProjName ""
 # PROP Scc_LocalPath ""
-CPP=cl.exe
+CPP=xicl6.exe
 RSC=rc.exe
 
 !IF  "$(CFG)" == "libsndfile - Win32 Release"
@@ -40,14 +40,14 @@
 # PROP Output_Dir "Release"
 # PROP Intermediate_Dir "Release"
 # PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\win32" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
 # ADD BASE RSC /l 0x413 /d "NDEBUG"
 # ADD RSC /l 0x413 /d "NDEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LIB32=link.exe -lib
+LIB32=xilink6.exe -lib
 # ADD BASE LIB32 /nologo
 # ADD LIB32 /nologo
 
@@ -63,14 +63,14 @@
 # PROP Output_Dir "Debug"
 # PROP Intermediate_Dir "Debug"
 # PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\win32" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /GZ /c
 # ADD BASE RSC /l 0x413 /d "_DEBUG"
 # ADD RSC /l 0x413 /d "_DEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
-LIB32=link.exe -lib
+LIB32=xilink6.exe -lib
 # ADD BASE LIB32 /nologo
 # ADD LIB32 /nologo
 
@@ -85,90 +85,30 @@
 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
 # Begin Source File
 
-SOURCE=..\src\GSM610\add.c
-# End Source File
-# Begin Source File
-
 SOURCE=..\src\aiff.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\alaw.c
-# End Source File
-# Begin Source File
-
 SOURCE=..\src\au.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\au_g72x.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\GSM610\code.c
-# End Source File
-# Begin Source File
-
 SOURCE=..\src\common.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\GSM610\decode.c
+SOURCE=..\src\float32.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\G72x\g721.c
+SOURCE=..\src\ircam.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\G72x\g723_16.c
+SOURCE=..\src\nist.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\G72x\g723_24.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\G72x\g723_40.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\G72x\g72x.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\GSM610\gsm_create.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\GSM610\gsm_decode.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\GSM610\gsm_destroy.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\GSM610\gsm_encode.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\GSM610\gsm_option.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\GSM610\long_term.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\GSM610\lpc.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\newpcm.c
-# End Source File
-# Begin Source File
-
 SOURCE=..\src\paf.c
 # End Source File
 # Begin Source File
@@ -177,22 +117,14 @@
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\GSM610\preprocess.c
-# End Source File
-# Begin Source File
-
 SOURCE=..\src\raw.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\GSM610\rpe.c
+SOURCE=..\src\samplitude.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\GSM610\short_term.c
-# End Source File
-# Begin Source File
-
 SOURCE=..\src\sndfile.c
 # End Source File
 # Begin Source File
@@ -201,32 +133,12 @@
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\GSM610\table.c
+SOURCE=..\src\voc.c
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\ulaw.c
-# End Source File
-# Begin Source File
-
 SOURCE=..\src\wav.c
 # End Source File
-# Begin Source File
-
-SOURCE=..\src\wav_float.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\wav_gsm610.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\wav_ima_adpcm.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\wav_ms_adpcm.c
-# End Source File
 # End Group
 # Begin Group "Header Files"
 
@@ -233,10 +145,6 @@
 # PROP Default_Filter "h;hpp;hxx;hm;inl"
 # Begin Source File
 
-SOURCE=..\src\alaw.h
-# End Source File
-# Begin Source File
-
 SOURCE=..\src\au.h
 # End Source File
 # Begin Source File
@@ -253,15 +161,15 @@
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\G72x\g72x.h
+SOURCE=..\src\floatcast.h
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\GSM610\gsm.h
+SOURCE=..\src\G72x\g72x.h
 # End Source File
 # Begin Source File
 
-SOURCE=..\src\pcm.h
+SOURCE=..\src\GSM610\gsm.h
 # End Source File
 # Begin Source File
 
@@ -282,10 +190,6 @@
 # Begin Source File
 
 SOURCE=..\src\sndfile.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\src\ulaw.h
 # End Source File
 # Begin Source File
 
--- a/common/libsndfile/Win32/libsndfile.dsw
+++ b/common/libsndfile/Win32/libsndfile.dsw
@@ -3,7 +3,7 @@
 
 ###############################################################################
 
-Project: "libsndfile"=".\libsndfile.dsp" - Package Owner=<4>
+Project: "libsndfile"=.\libsndfile.dsp - Package Owner=<4>
 
 Package=<5>
 {{{
--- a/common/libsndfile/acconfig.h
+++ b/common/libsndfile/acconfig.h
@@ -282,7 +282,7 @@
 /* Set to 1 if the processor is little endian, otherwise set to 0.  */
 #undef	GUESS_LITTLE_ENDIAN
 
-/* Set to 1 if the processor can read and write Intel x86 32 bit floats.  */
+/* Set to 1 to force the use of code for processors with broken floats */
 /* Otherwise set it to 0.  */
-#undef	CAN_READ_WRITE_x86_IEEE
+#undef	FORCE_BROKEN_FLOAT
 
--- a/common/libsndfile/aclocal.m4
+++ b/common/libsndfile/aclocal.m4
@@ -1,4 +1,4 @@
-dnl aclocal.m4 generated automatically by aclocal 1.4
+dnl aclocal.m4 generated automatically by aclocal 1.4-p4
 
 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -139,7 +139,7 @@
 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
 DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
-$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
+$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
 || AC_MSG_ERROR([libtool configure failed])
 
 # Reload cache, that may have been modified by ltconfig
@@ -171,6 +171,11 @@
 AC_REQUIRE([AC_PROG_LN_S])dnl
 dnl
 
+case "$target" in
+NONE) lt_target="$host" ;;
+*) lt_target="$target" ;;
+esac
+
 # Check for any special flags to pass to ltconfig.
 libtool_flags="--cache-file=$cache_file"
 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
@@ -189,7 +194,7 @@
 
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
-case "$host" in
+case "$lt_target" in
 *-*-irix6*)
   # Find out which ABI we are using.
   echo '[#]line __oline__ "configure"' > conftest.$ac_ext
@@ -405,7 +410,6 @@
   AC_MSG_RESULT(no)
 fi
 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
-AC_SUBST(LD)
 AC_PROG_LD_GNU
 ])
 
@@ -451,7 +455,6 @@
 fi])
 NM="$ac_cv_path_NM"
 AC_MSG_RESULT([$NM])
-AC_SUBST(NM)
 ])
 
 # AC_CHECK_LIBM - check for math library
@@ -458,7 +461,7 @@
 AC_DEFUN(AC_CHECK_LIBM,
 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
 LIBM=
-case "$host" in
+case "$lt_target" in
 *-*-beos* | *-*-cygwin*)
   # These system don't have libm
   ;;
@@ -473,13 +476,15 @@
 ])
 
 # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
-# the libltdl convenience library, adds --enable-ltdl-convenience to
-# the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
-# is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
-# to be `${top_builddir}/libltdl'.  Make sure you start DIR with
-# '${top_builddir}/' (note the single quotes!) if your package is not
-# flat, and, if you're not using automake, define top_builddir as
-# appropriate in the Makefiles.
+# the libltdl convenience library and INCLTDL to the include flags for
+# the libltdl header and adds --enable-ltdl-convenience to the
+# configure arguments.  Note that LIBLTDL and INCLTDL are not
+# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If DIR is not
+# provided, it is assumed to be `libltdl'.  LIBLTDL will be prefixed
+# with '${top_builddir}/' and INCLTDL will be prefixed with
+# '${top_srcdir}/' (note the single quotes!).  If your package is not
+# flat and you're not using automake, define top_builddir and
+# top_srcdir appropriately in the Makefiles.
 AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
   case "$enable_ltdl_convenience" in
   no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
@@ -486,18 +491,20 @@
   "") enable_ltdl_convenience=yes
       ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
   esac
-  LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
-  INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
+  LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
+  INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
 ])
 
 # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
-# the libltdl installable library, and adds --enable-ltdl-install to
-# the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
-# is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
-# to be `${top_builddir}/libltdl'.  Make sure you start DIR with
-# '${top_builddir}/' (note the single quotes!) if your package is not
-# flat, and, if you're not using automake, define top_builddir as
-# appropriate in the Makefiles.
+# the libltdl installable library and INCLTDL to the include flags for
+# the libltdl header and adds --enable-ltdl-install to the configure
+# arguments.  Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is
+# AC_CONFIG_SUBDIRS called.  If DIR is not provided and an installed
+# libltdl is not found, it is assumed to be `libltdl'.  LIBLTDL will
+# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed
+# with '${top_srcdir}/' (note the single quotes!).  If your package is
+# not flat and you're not using automake, define top_builddir and
+# top_srcdir appropriately in the Makefiles.
 # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
 AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
   AC_CHECK_LIB(ltdl, main,
@@ -510,8 +517,8 @@
   ])
   if test x"$enable_ltdl_install" = x"yes"; then
     ac_configure_args="$ac_configure_args --enable-ltdl-install"
-    LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
-    INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
+    LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
+    INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
   else
     ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
     LIBLTDL="-lltdl"
--- /dev/null
+++ b/common/libsndfile/check_libsndfile.py
@@ -1,0 +1,67 @@
+#!/usr/bin/env python 
+
+import commands, os, string, sys 
+
+# This program tests libsndfile against a user provided list of audio files. 
+# The list is provided as a text file. 
+# 
+
+_EXE_NAME = 'examples/sndfile_info'
+
+
+def dump_status_output_exit (status, output, msg = None): 
+	if msg: 
+		print msg 
+	print "Status :", status 
+	print output 
+	sys.exit (0) 
+
+def sfinfo_check_ok (filename): 
+	cmd = '%s %s' % (_EXE_NAME, filename) 
+	(status, output) = commands.getstatusoutput (cmd) 
+	if status: 
+		dump_status_output_exit (status, output, "Bad status. Dumping") 
+	if string.find (output, "should") > 0: 
+		dump_status_output_exit (status, output, "Found `should'. Dumping") 
+	if string.find (output, "*") > 0: 
+		dump_status_output_exit (status, output, "Found `*'. Dumping") 
+	return 
+
+def sfinfo_check_not_crash (filename): 
+	print filename 
+	 
+_USAGE = """ 
+This is the usage message. 
+
+""" 
+
+if len (sys.argv) != 2: 
+	print _USAGE 
+	sys.exit (0) 
+
+
+if not os.path.isfile (_EXE_NAME): 
+	print "Could not find required program :", _EXE_NAME 
+	sys.exit (0) 
+
+list_file = open (sys.argv [1]) 
+
+while 1: 
+	line = list_file.readline () 
+	if not line: 
+		break  
+	line = string.strip (line)
+	if len (line) < 1:
+		continue 
+	if line [0] == '#':
+		continue 
+	print line
+	if os.path.isfile (line): 
+		sfinfo_check_ok (line) 
+	else: 
+		print "Bad file name : ", line 
+		sys.exit (0) 
+
+list_file.close () 
+
+print "Finished. No errors found." 
--- a/common/libsndfile/config.guess
+++ b/common/libsndfile/config.guess
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
 #   Free Software Foundation, Inc.
 #
 # This file is free software; you can redistribute it and/or modify it
@@ -23,8 +23,7 @@
 # the same distribution terms that you use for the rest of that program.
 
 # Written by Per Bothner <bothner@cygnus.com>.
-# The master version of this file is at the FSF in /home/gd/gnu/lib.
-# Please send patches to the Autoconf mailing list <autoconf@gnu.org>.
+# Please send patches to <config-patches@gnu.org>.
 #
 # This script attempts to guess a canonical system name similar to
 # config.sub.  If it succeeds, it prints the system name on stdout, and
@@ -68,6 +67,43 @@
 # Note: order is significant - the case branches are not exclusive.
 
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+	# Netbsd (nbsd) targets should (where applicable) match one or
+	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+	# switched to ELF, *-*-netbsd* would select the old
+	# object file format.  This provides both forward
+	# compatibility and a consistent mechanism for selecting the
+	# object file format.
+	# Determine the machine/vendor (is the vendor relevant).
+	case "${UNAME_MACHINE}" in
+	    amiga) machine=m68k-cbm ;;
+	    arm32) machine=arm-unknown ;;
+	    atari*) machine=m68k-atari ;;
+	    sun3*) machine=m68k-sun ;;
+	    mac68k) machine=m68k-apple ;;
+	    macppc) machine=powerpc-apple ;;
+	    hp3[0-9][05]) machine=m68k-hp ;;
+	    ibmrt|romp-ibm) machine=romp-ibm ;;
+	    *) machine=${UNAME_MACHINE}-unknown ;;
+	esac
+	# The Operating System including object format.
+	if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+		| grep __ELF__ >/dev/null
+	then
+	    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+	    # Return netbsd for either.  FIX?
+	    os=netbsd
+	else
+	    os=netbsdelf
+	fi
+	# The OS release
+	release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+	# contains redundant information, the shorter form:
+	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+	echo "${machine}-${os}${release}"
+	exit 0 ;;
     alpha:OSF1:*:*)
 	if test $UNAME_RELEASE = "V4.0"; then
 		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
@@ -77,41 +113,51 @@
 	# A Xn.n version is an unreleased experimental baselevel.
 	# 1.2 uses "1.2" for uname -r.
 	cat <<EOF >$dummy.s
+	.data
+\$Lformat:
+	.byte 37,100,45,37,120,10,0	# "%d-%x\n"
+
+	.text
 	.globl main
+	.align 4
 	.ent main
 main:
-	.frame \$30,0,\$26,0
-	.prologue 0
-	.long 0x47e03d80 # implver $0
-	lda \$2,259
-	.long 0x47e20c21 # amask $2,$1
-	srl \$1,8,\$2
-	sll \$2,2,\$2
-	sll \$0,3,\$0
-	addl \$1,\$0,\$0
-	addl \$2,\$0,\$0
-	ret \$31,(\$26),1
+	.frame \$30,16,\$26,0
+	ldgp \$29,0(\$27)
+	.prologue 1
+	.long 0x47e03d80 # implver \$0
+	lda \$2,-1
+	.long 0x47e20c21 # amask \$2,\$1
+	lda \$16,\$Lformat
+	mov \$0,\$17
+	not \$1,\$18
+	jsr \$26,printf
+	ldgp \$29,0(\$26)
+	mov 0,\$16
+	jsr \$26,exit
 	.end main
 EOF
 	$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
 	if test "$?" = 0 ; then
-		./$dummy
-		case "$?" in
-			7)
+		case `./$dummy` in
+			0-0)
 				UNAME_MACHINE="alpha"
 				;;
-			15)
+			1-0)
 				UNAME_MACHINE="alphaev5"
 				;;
-			14)
+			1-1)
 				UNAME_MACHINE="alphaev56"
 				;;
-			10)
+			1-101)
 				UNAME_MACHINE="alphapca56"
 				;;
-			16)
+			2-303)
 				UNAME_MACHINE="alphaev6"
 				;;
+			2-307)
+				UNAME_MACHINE="alphaev67"
+				;;
 		esac
 	fi
 	rm -f $dummy.s $dummy
@@ -129,9 +175,6 @@
     Amiga*:UNIX_System_V:4.0:*)
 	echo m68k-cbm-sysv4
 	exit 0;;
-    amiga:NetBSD:*:*)
-      echo m68k-cbm-netbsd${UNAME_RELEASE}
-      exit 0 ;;
     amiga:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
@@ -156,12 +199,12 @@
     wgrisc:OpenBSD:*:*)
 	echo mipsel-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
+    *:OS/390:*:*)
+	echo i370-ibm-openedition
+	exit 0 ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
 	echo arm-acorn-riscix${UNAME_RELEASE}
 	exit 0;;
-    arm32:NetBSD:*:*)
-	echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-	exit 0 ;;
     SR2?01:HI-UX/MPP:*:*)
 	echo hppa1.1-hitachi-hiuxmpp
 	exit 0;;
@@ -218,15 +261,12 @@
     aushp:SunOS:*:*)
 	echo sparc-auspex-sunos${UNAME_RELEASE}
 	exit 0 ;;
-    atari*:NetBSD:*:*)
-	echo m68k-atari-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     atari*:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
     # The situation for MiNT is a little confusing.  The machine name
     # can be virtually everything (everything which is not
-    # "atarist" or "atariste" at least should have a processor 
+    # "atarist" or "atariste" at least should have a processor
     # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
     # to the lowercase version "mint" (or "freemint").  Finally
     # the system name "TOS" denotes a system which is actually not
@@ -250,15 +290,9 @@
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
         echo m68k-unknown-mint${UNAME_RELEASE}
         exit 0 ;;
-    sun3*:NetBSD:*:*)
-	echo m68k-sun-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     sun3*:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    mac68k:NetBSD:*:*)
-	echo m68k-apple-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     mac68k:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
@@ -271,9 +305,6 @@
     powerpc:machten:*:*)
 	echo powerpc-apple-machten${UNAME_RELEASE}
 	exit 0 ;;
-    macppc:NetBSD:*:*)
-        echo powerpc-apple-netbsd${UNAME_RELEASE}
-        exit 0 ;;
     RISC*:Mach:*:*)
 	echo mips-dec-mach_bsd4.3
 	exit 0 ;;
@@ -289,6 +320,7 @@
     mips:*:*:UMIPS | mips:*:*:RISCos)
 	sed 's/^	//' << EOF >$dummy.c
 #ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
 	int main (int argc, char *argv[]) {
 #else
 	int main (argc, argv) int argc; char *argv[]; {
@@ -328,15 +360,18 @@
     AViiON:dgux:*:*)
         # DG/UX returns AViiON for all architectures
         UNAME_PROCESSOR=`/usr/bin/uname -p`
-        if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
-	if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
-	     -o ${TARGET_BINARY_INTERFACE}x = x ] ; then
+	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+	then
+	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+	       [ ${TARGET_BINARY_INTERFACE}x = x ]
+	    then
 		echo m88k-dg-dgux${UNAME_RELEASE}
-	else
+	    else
 		echo m88k-dg-dguxbcs${UNAME_RELEASE}
+	    fi
+	else
+	    echo i586-dg-dgux${UNAME_RELEASE}
 	fi
-        else echo i586-dg-dgux${UNAME_RELEASE}
-        fi
  	exit 0 ;;
     M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
 	echo m88k-dolphin-sysv3
@@ -402,7 +437,7 @@
     ibmrt:4.4BSD:*|romp-ibm:BSD:*)
 	echo romp-ibm-bsd4.4
 	exit 0 ;;
-    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC NetBSD and
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
 	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
 	exit 0 ;;                           # report: romp-ibm BSD 4.3
     *:BOSX:*:*)
@@ -423,6 +458,8 @@
 	    9000/[34]?? )         HP_ARCH=m68k ;;
 	    9000/[678][0-9][0-9])
               sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
               #include <stdlib.h>
               #include <unistd.h>
 
@@ -453,7 +490,7 @@
                   exit (0);
               }
 EOF
-	($CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
+	(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
 	rm -f $dummy.c $dummy
 	esac
 	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
@@ -547,11 +584,14 @@
 	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
 	exit 0 ;;
     CRAY*TS:*:*:*)
-	echo t90-cray-unicos${UNAME_RELEASE}
+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
     CRAY*T3E:*:*:*)
-	echo t3e-cray-unicosmk${UNAME_RELEASE}
+	echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit 0 ;;
+    CRAY*SV1:*:*:*)
+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
     CRAY-2:*:*:*)
 	echo cray2-cray-unicos
         exit 0 ;;
@@ -563,13 +603,10 @@
     F301:UNIX_System_V:*:*)
        echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
        exit 0 ;;
-    hp3[0-9][05]:NetBSD:*:*)
-	echo m68k-hp-netbsd${UNAME_RELEASE}
-	exit 0 ;;
     hp300:OpenBSD:*:*)
 	echo m68k-unknown-openbsd${UNAME_RELEASE}
 	exit 0 ;;
-    i?86:BSD/386:*:* | i?86:BSD/OS:*:*)
+    i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
 	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
 	exit 0 ;;
     sparc*:BSD/OS:*:*)
@@ -579,17 +616,8 @@
 	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
 	exit 0 ;;
     *:FreeBSD:*:*)
-	if test -x /usr/bin/objformat; then
-	    if test "elf" = "`/usr/bin/objformat`"; then
-		echo ${UNAME_MACHINE}-unknown-freebsdelf`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'`
-		exit 0
-	    fi
-	fi
 	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 	exit 0 ;;
-    *:NetBSD:*:*)
-	echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-	exit 0 ;;
     *:OpenBSD:*:*)
 	echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
 	exit 0 ;;
@@ -618,12 +646,6 @@
 	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
 	exit 0 ;;
     *:Linux:*:*)
-	# uname on the ARM produces all sorts of strangeness, and we need to
-	# filter it out.
-	case "$UNAME_MACHINE" in
-	  armv*)		      UNAME_MACHINE=$UNAME_MACHINE ;;
-	  arm* | sa110*)	      UNAME_MACHINE="arm" ;;
-	esac
 
 	# The BFD linker knows what the default object file format is, so
 	# first see if it will tell us. cd to the root directory to prevent
@@ -636,12 +658,43 @@
 				    s/ .*//
 				    p'`
         case "$ld_supported_emulations" in
-	  i?86linux)  echo "${UNAME_MACHINE}-pc-linux-gnuaout"      ; exit 0 ;;
-	  i?86coff)   echo "${UNAME_MACHINE}-pc-linux-gnucoff"      ; exit 0 ;;
-	  sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
-	  armlinux)   echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
-	  m68klinux)  echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
-	  elf32ppc)
+	  *ia64)
+		echo "${UNAME_MACHINE}-unknown-linux"
+		exit 0
+		;;
+	  i?86linux)
+		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+		exit 0
+		;;
+	  elf_i?86)
+		echo "${UNAME_MACHINE}-pc-linux"
+		exit 0
+		;;
+	  i?86coff)
+		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+		exit 0
+		;;
+	  sparclinux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+		exit 0
+		;;
+	  armlinux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+		exit 0
+		;;
+	  elf32arm*)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuoldld"
+		exit 0
+		;;
+	  armelf_linux*)
+		echo "${UNAME_MACHINE}-unknown-linux-gnu"
+		exit 0
+		;;
+	  m68klinux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+		exit 0
+		;;
+	  elf32ppc | elf32ppclinux)
 		# Determine Lib Version
 		cat >$dummy.c <<EOF
 #include <features.h>
@@ -668,49 +721,61 @@
 			if test "$?" = 0 ; then
 				LIBC="libc1"
 			fi
-		fi	
+		fi
 		rm -f $dummy.c $dummy
-		echo powerpc-unknown-linux-gnu${LIBC} ; exit 0 ;;
+		echo powerpc-unknown-linux-gnu${LIBC}
+		exit 0
+		;;
 	esac
 
 	if test "${UNAME_MACHINE}" = "alpha" ; then
-		sed 's/^	//'  <<EOF >$dummy.s
-		.globl main
-		.ent main
-	main:
-		.frame \$30,0,\$26,0
-		.prologue 0
-		.long 0x47e03d80 # implver $0
-		lda \$2,259
-		.long 0x47e20c21 # amask $2,$1
-		srl \$1,8,\$2
-		sll \$2,2,\$2
-		sll \$0,3,\$0
-		addl \$1,\$0,\$0
-		addl \$2,\$0,\$0
-		ret \$31,(\$26),1
-		.end main
+		cat <<EOF >$dummy.s
+			.data
+		\$Lformat:
+			.byte 37,100,45,37,120,10,0	# "%d-%x\n"
+
+			.text
+			.globl main
+			.align 4
+			.ent main
+		main:
+			.frame \$30,16,\$26,0
+			ldgp \$29,0(\$27)
+			.prologue 1
+			.long 0x47e03d80 # implver \$0
+			lda \$2,-1
+			.long 0x47e20c21 # amask \$2,\$1
+			lda \$16,\$Lformat
+			mov \$0,\$17
+			not \$1,\$18
+			jsr \$26,printf
+			ldgp \$29,0(\$26)
+			mov 0,\$16
+			jsr \$26,exit
+			.end main
 EOF
 		LIBC=""
 		$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
 		if test "$?" = 0 ; then
-			./$dummy
-			case "$?" in
-			7)
+			case `./$dummy` in
+			0-0)
 				UNAME_MACHINE="alpha"
 				;;
-			15)
+			1-0)
 				UNAME_MACHINE="alphaev5"
 				;;
-			14)
+			1-1)
 				UNAME_MACHINE="alphaev56"
 				;;
-			10)
+			1-101)
 				UNAME_MACHINE="alphapca56"
 				;;
-			16)
+			2-303)
 				UNAME_MACHINE="alphaev6"
 				;;
+			2-307)
+				UNAME_MACHINE="alphaev67"
+				;;
 			esac
 
 			objdump --private-headers $dummy | \
@@ -724,6 +789,7 @@
 	elif test "${UNAME_MACHINE}" = "mips" ; then
 	  cat >$dummy.c <<EOF
 #ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
 	int main (int argc, char *argv[]) {
 #else
 	int main (argc, argv) int argc; char *argv[]; {
@@ -739,6 +805,8 @@
 EOF
 	  $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
 	  rm -f $dummy.c $dummy
+	elif test "${UNAME_MACHINE}" = "s390"; then
+	  echo s390-ibm-linux && exit 0
 	else
 	  # Either a pre-BFD a.out linker (linux-gnuoldld)
 	  # or one that does not give us useful --help.
@@ -760,6 +828,7 @@
 	  cat >$dummy.c <<EOF
 #include <features.h>
 #ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
 	int main (int argc, char *argv[]) {
 #else
 	int main (argc, argv) int argc; char *argv[]; {
@@ -797,19 +866,21 @@
 	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
 	exit 0 ;;
     i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
 	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
-		echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
+		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
 	else
-		echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
 	fi
 	exit 0 ;;
     i?86:*:5:7*)
-	UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
-	(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
-	(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) && UNAME_MACHINE=i586
-	(/bin/uname -X|egrep '^Machine.*Pent.*II' >/dev/null) && UNAME_MACHINE=i686
-	(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) && UNAME_MACHINE=i585
-	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}${UNAME_VERSION}-sysv${UNAME_RELEASE}
+        # Fixed at (any) Pentium or better
+        UNAME_MACHINE=i586
+        if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
+	    echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
+	else
+	    echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+	fi
 	exit 0 ;;
     i?86:*:3.2:*)
 	if test -f /usr/options/cb.name; then
@@ -829,7 +900,11 @@
 		echo ${UNAME_MACHINE}-pc-sysv32
 	fi
 	exit 0 ;;
+    i?86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
+	exit 0 ;;
     pc:*:*:*)
+	# Left here for compatibility:
         # uname -m prints for DJGPP always 'pc', but it prints nothing about
         # the processor, so we play safe by assuming i386.
 	echo i386-pc-msdosdjgpp
@@ -942,6 +1017,27 @@
 	exit 0 ;;
     *:Rhapsody:*:*)
 	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+	exit 0 ;;
+    *:Darwin:*:*)
+	echo `uname -p`-apple-darwin${UNAME_RELEASE}
+	exit 0 ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+	if test "${UNAME_MACHINE}" = "x86pc"; then
+		UNAME_MACHINE=pc
+	fi
+	echo `uname -p`-${UNAME_MACHINE}-nto-qnx
+	exit 0 ;;
+    *:QNX:*:4*)
+	echo i386-pc-qnx
+	exit 0 ;;
+    NSR-W:NONSTOP_KERNEL:*:*)
+	echo nsr-tandem-nsk${UNAME_RELEASE}
+	exit 0 ;;
+    BS2000:POSIX*:*:*)
+	echo bs2000-siemens-sysv
+	exit 0 ;;
+    DS/*:UNIX_System_V:*:*)
+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
 	exit 0 ;;
 esac
 
--- a/common/libsndfile/config.sub
+++ b/common/libsndfile/config.sub
@@ -1,6 +1,8 @@
 #! /bin/sh
 # Configuration validation subroutine script, version 1.1.
-#   Copyright (C) 1991, 92-97, 1998, 1999 Free Software Foundation, Inc.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+#   Free Software Foundation, Inc.
+#
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
 # can handle that machine.  It does not imply ALL GNU software can.
@@ -25,6 +27,9 @@
 # configuration script generated by Autoconf, you may include it under
 # the same distribution terms that you use for the rest of that program.
 
+# Written by Per Bothner <bothner@cygnus.com>.
+# Please send patches to <config-patches@gnu.org>.
+#
 # Configuration subroutine to validate and canonicalize a configuration type.
 # Supply the specified configuration type as an argument.
 # If it is invalid, we print an error message on stderr and exit with code 1.
@@ -68,7 +73,7 @@
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  linux-gnu*)
+  nto-qnx* | linux-gnu*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
@@ -105,7 +110,7 @@
 	-scout)
 		;;
 	-wrs)
-		os=vxworks
+		os=-vxworks
 		basic_machine=$1
 		;;
 	-hiux*)
@@ -156,6 +161,10 @@
 	-psos*)
 		os=-psos
 		;;
+	-mint | -mint[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
 esac
 
 # Decode aliases for certain CPU-COMPANY combinations.
@@ -162,21 +171,24 @@
 case $basic_machine in
 	# Recognize the basic CPU types without company name.
 	# Some are omitted here because they have special meanings below.
-	tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
+	tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
 		| arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \
 		| 580 | i960 | h8300 \
+		| x86 | ppcbe | mipsbe | mipsle | shbe | shle | armbe | armle \
 		| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
-		| alpha | alphaev[4-7] | alphaev56 | alphapca5[67] \
+		| hppa64 \
+		| alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
+		| alphaev6[78] \
 		| we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \
 		| 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
 		| mips64orion | mips64orionel | mipstx39 | mipstx39el \
 		| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
-		| mips64vr5000 | miprs64vr5000el \
+		| mips64vr5000 | miprs64vr5000el | mcore \
 		| sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
-		| thumb | d10v)
+		| thumb | d10v | fr30 | avr)
 		basic_machine=$basic_machine-unknown
 		;;
-	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65)
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl)
 		;;
 
 	# We use `pc' rather than `unknown'
@@ -191,13 +203,17 @@
 		exit 1
 		;;
 	# Recognize the basic CPU types with company name.
-	vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \
+	# FIXME: clean up the formatting here.
+	vax-* | tahoe-* | i[34567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
 	      | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
 	      | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
 	      | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
 	      | xmp-* | ymp-* \
-	      | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* | hppa2.0n-* \
-	      | alpha-* | alphaev[4-7]-* | alphaev56-* | alphapca5[67]-* \
+	      | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* | armbe-* | armle-* \
+	      | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
+	      | hppa2.0n-* | hppa64-* \
+	      | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
+	      | alphaev6[78]-* \
 	      | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
 	      | clipper-* | orion-* \
 	      | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
@@ -204,10 +220,11 @@
 	      | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
 	      | mips64el-* | mips64orion-* | mips64orionel-* \
 	      | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
-	      | mipstx39-* | mipstx39el-* \
-	      | f301-* | armv*-* | t3e-* \
+	      | mipstx39-* | mipstx39el-* | mcore-* \
+	      | f301-* | armv*-* | s390-* | sv1-* | t3e-* \
 	      | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
-	      | thumb-* | v850-* | d30v-* | tic30-* | c30-* )
+	      | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \
+	      | bs2000-*)
 		;;
 	# Recognize the various machine names and aliases which stand
 	# for a CPU type and a company and sometimes even an OS.
@@ -425,7 +442,6 @@
 		;;
 	i370-ibm* | ibm*)
 		basic_machine=i370-ibm
-		os=-mvs
 		;;
 # I'm not sure what "Sysv32" means.  Should this be sysv3.2?
 	i[34567]86v32)
@@ -488,7 +504,7 @@
 	miniframe)
 		basic_machine=m68000-convergent
 		;;
-	*mint | *MiNT)
+	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
 		basic_machine=m68k-atari
 		os=-mint
 		;;
@@ -506,6 +522,10 @@
 	mips3*)
 		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
 		;;
+	mmix*)
+		basic_machine=mmix-knuth
+		os=-mmixware
+		;;
 	monitor)
 		basic_machine=m68k-rom68k
 		os=-coff
@@ -514,6 +534,10 @@
 		basic_machine=i386-unknown
 		os=-msdos
 		;;
+	mvs)
+		basic_machine=i370-ibm
+		os=-mvs
+		;;
 	ncr3000)
 		basic_machine=i486-ncr
 		os=-sysv4
@@ -523,7 +547,7 @@
 		os=-netbsd
 		;;
 	netwinder)
-		basic_machine=armv4l-corel
+		basic_machine=armv4l-rebel
 		os=-linux
 		;;
 	news | news700 | news800 | news900)
@@ -574,6 +598,9 @@
 	np1)
 		basic_machine=np1-gould
 		;;
+	nsr-tandem)
+		basic_machine=nsr-tandem
+		;;
 	op50n-* | op60c-*)
 		basic_machine=hppa1.1-oki
 		os=-proelf
@@ -718,6 +745,10 @@
 	sun386 | sun386i | roadrunner)
 		basic_machine=i386-sun
 		;;
+	sv1)
+		basic_machine=sv1-cray
+		os=-unicos
+		;;
 	symmetry)
 		basic_machine=i386-sequent
 		os=-dynix
@@ -907,12 +938,25 @@
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
 	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
-	      | -interix* | -uwin* | -rhapsody* | -openstep* | -oskit*)
+	      | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+	      | -openstep* | -oskit*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i[34567]86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto*)
+		os=-nto-qnx
+		;;
 	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
 	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
-	      | -macos* | -mpw* | -magic* | -mon960* | -lnews*)
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
 		;;
 	-mac*)
 		os=`echo $os | sed -e 's|mac|macos|'`
@@ -926,6 +970,12 @@
 	-sunos6*)
 		os=`echo $os | sed -e 's|sunos6|solaris3|'`
 		;;
+	-opened*)
+		os=-openedition
+		;;
+	-wince*)
+		os=-wince
+		;;
 	-osfrose*)
 		os=-osfrose
 		;;
@@ -950,6 +1000,9 @@
 	-ns2 )
 	        os=-nextstep2
 		;;
+	-nsk)
+		os=-nsk
+		;;
 	# Preserve the version number of sinix5.
 	-sinix5.*)
 		os=`echo $os | sed -e 's|sinix|sysv|'`
@@ -1012,7 +1065,7 @@
 	*-acorn)
 		os=-riscix1.2
 		;;
-	arm*-corel)
+	arm*-rebel)
 		os=-linux
 		;;
 	arm*-semi)
@@ -1186,7 +1239,7 @@
 			-genix*)
 				vendor=ns
 				;;
-			-mvs*)
+			-mvs* | -opened*)
 				vendor=ibm
 				;;
 			-ptx*)
--- a/common/libsndfile/configure
+++ b/common/libsndfile/configure
@@ -22,9 +22,13 @@
 ac_help="$ac_help
   --disable-libtool-lock  avoid locking (might break parallel builds)"
 ac_help="$ac_help
-  --enable-justsrc        only compile library sources "
+  --enable-justsrc             only compile library sources "
 ac_help="$ac_help
-  --disable-gcc-pipe      disable gcc -pipe option "
+  --disable-gcc-pipe           disable gcc -pipe option "
+ac_help="$ac_help
+  --disable-gcc-opt            disable gcc optimisations "
+ac_help="$ac_help
+  --enable-force-broken-float  force use of broken float code "
 
 # Initialize some variables set by options.
 # The variables have the same names as the options, with
@@ -582,7 +586,7 @@
 fi
 
 echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:586: checking host system type" >&5
+echo "configure:590: checking host system type" >&5
 
 host_alias=$host
 case "$host_alias" in
@@ -603,7 +607,7 @@
 echo "$ac_t""$host" 1>&6
 
 echo $ac_n "checking target system type""... $ac_c" 1>&6
-echo "configure:607: checking target system type" >&5
+echo "configure:611: checking target system type" >&5
 
 target_alias=$target
 case "$target_alias" in
@@ -621,7 +625,7 @@
 echo "$ac_t""$target" 1>&6
 
 echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:625: checking build system type" >&5
+echo "configure:629: checking build system type" >&5
 
 build_alias=$build
 case "$build_alias" in
@@ -656,7 +660,7 @@
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:660: checking for a BSD compatible install" >&5
+echo "configure:664: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -709,7 +713,7 @@
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
-echo "configure:713: checking whether build environment is sane" >&5
+echo "configure:717: checking whether build environment is sane" >&5
 # Just in case
 sleep 1
 echo timestamp > conftestfile
@@ -766,7 +770,7 @@
 test "$program_transform_name" = "" && program_transform_name="s,x,x,"
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:770: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:774: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -795,7 +799,7 @@
 
 PACKAGE=libsndfile
 
-VERSION=0.0.22
+VERSION=0.0.27
 
 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
   { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
@@ -812,7 +816,7 @@
 
 missing_dir=`cd $ac_aux_dir && pwd`
 echo $ac_n "checking for working aclocal""... $ac_c" 1>&6
-echo "configure:816: checking for working aclocal" >&5
+echo "configure:820: checking for working aclocal" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -825,7 +829,7 @@
 fi
 
 echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
-echo "configure:829: checking for working autoconf" >&5
+echo "configure:833: checking for working autoconf" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -838,7 +842,7 @@
 fi
 
 echo $ac_n "checking for working automake""... $ac_c" 1>&6
-echo "configure:842: checking for working automake" >&5
+echo "configure:846: checking for working automake" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -851,7 +855,7 @@
 fi
 
 echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
-echo "configure:855: checking for working autoheader" >&5
+echo "configure:859: checking for working autoheader" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -864,7 +868,7 @@
 fi
 
 echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
-echo "configure:868: checking for working makeinfo" >&5
+echo "configure:872: checking for working makeinfo" >&5
 # Run test in a subshell; some versions of sh will print an error if
 # an executable is not found, even if stderr is redirected.
 # Redirect stdin to placate older versions of autoconf.  Sigh.
@@ -879,7 +883,7 @@
 
 
 
-SHARED_VERSION_INFO="0:8:0"
+SHARED_VERSION_INFO="0:27:0"
 
 
 
@@ -889,7 +893,7 @@
 # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:893: checking for $ac_word" >&5
+echo "configure:897: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -919,7 +923,7 @@
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:923: checking for $ac_word" >&5
+echo "configure:927: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -970,7 +974,7 @@
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:974: checking for $ac_word" >&5
+echo "configure:978: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1002,7 +1006,7 @@
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1006: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:1010: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -1013,12 +1017,12 @@
 
 cat > conftest.$ac_ext << EOF
 
-#line 1017 "configure"
+#line 1021 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:1022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1026: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -1044,12 +1048,12 @@
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1048: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:1052: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:1053: checking whether we are using GNU C" >&5
+echo "configure:1057: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1058,7 +1062,7 @@
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1062: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1066: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -1077,7 +1081,7 @@
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1081: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1085: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1120,7 +1124,7 @@
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1124: checking for a BSD compatible install" >&5
+echo "configure:1128: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1174,7 +1178,7 @@
 
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:1178: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:1182: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1201,7 +1205,7 @@
 fi
 
 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
-echo "configure:1205: checking whether ln -s works" >&5
+echo "configure:1209: checking whether ln -s works" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1293,7 +1297,7 @@
 # Extract the first word of "ranlib", so it can be a program name with args.
 set dummy ranlib; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1297: checking for $ac_word" >&5
+echo "configure:1301: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1332,7 +1336,7 @@
 if test "$ac_cv_prog_gcc" = yes; then
   # Check if gcc -print-prog-name=ld gives a path.
   echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6
-echo "configure:1336: checking for ld used by GCC" >&5
+echo "configure:1340: checking for ld used by GCC" >&5
   ac_prog=`($CC -print-prog-name=ld) 2>&5`
   case "$ac_prog" in
     # Accept absolute paths.
@@ -1356,10 +1360,10 @@
   esac
 elif test "$with_gnu_ld" = yes; then
   echo $ac_n "checking for GNU ld""... $ac_c" 1>&6
-echo "configure:1360: checking for GNU ld" >&5
+echo "configure:1364: checking for GNU ld" >&5
 else
   echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
-echo "configure:1363: checking for non-GNU ld" >&5
+echo "configure:1367: checking for non-GNU ld" >&5
 fi
 if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -1393,9 +1397,8 @@
   echo "$ac_t""no" 1>&6
 fi
 test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; }
-
 echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6
-echo "configure:1399: checking if the linker ($LD) is GNU ld" >&5
+echo "configure:1402: checking if the linker ($LD) is GNU ld" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1411,7 +1414,7 @@
 
 
 echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6
-echo "configure:1415: checking for BSD-compatible nm" >&5
+echo "configure:1418: checking for BSD-compatible nm" >&5
 if eval "test \"`echo '$''{'ac_cv_path_NM'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1447,6 +1450,10 @@
 echo "$ac_t""$NM" 1>&6
 
 
+case "$target" in
+NONE) lt_target="$host" ;;
+*) lt_target="$target" ;;
+esac
 
 # Check for any special flags to pass to ltconfig.
 libtool_flags="--cache-file=$cache_file"
@@ -1468,11 +1475,11 @@
 
 # Some flags need to be propagated to the compiler or linker for good
 # libtool support.
-case "$host" in
+case "$lt_target" in
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 1475 "configure"' > conftest.$ac_ext
-  if { (eval echo configure:1476: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  echo '#line 1482 "configure"' > conftest.$ac_ext
+  if { (eval echo configure:1483: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
     case "`/usr/bin/file conftest.o`" in
     *32-bit*)
       LD="${LD-ld} -32"
@@ -1493,12 +1500,12 @@
   SAVE_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS -belf"
   echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6
-echo "configure:1497: checking whether the C compiler needs -belf" >&5
+echo "configure:1504: checking whether the C compiler needs -belf" >&5
 if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1502 "configure"
+#line 1509 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1505,7 +1512,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:1509: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1516: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   lt_cv_cc_needs_belf=yes
 else
@@ -1583,7 +1590,7 @@
 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
 DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
-$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
+$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
 || { echo "configure: error: libtool configure failed" 1>&2; exit 1; }
 
 # Reload cache, that may have been modified by ltconfig
@@ -1608,7 +1615,7 @@
 
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1612: checking how to run the C preprocessor" >&5
+echo "configure:1619: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -1623,13 +1630,13 @@
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 1627 "configure"
+#line 1634 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1633: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1640: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1640,13 +1647,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 1644 "configure"
+#line 1651 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1650: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1657: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1657,13 +1664,13 @@
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 1661 "configure"
+#line 1668 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1667: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1674: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1688,12 +1695,12 @@
 echo "$ac_t""$CPP" 1>&6
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1692: checking for ANSI C header files" >&5
+echo "configure:1699: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1697 "configure"
+#line 1704 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1701,7 +1708,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1705: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1712: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1718,7 +1725,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1722 "configure"
+#line 1729 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1736,7 +1743,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1740 "configure"
+#line 1747 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1757,7 +1764,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 1761 "configure"
+#line 1768 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1768,7 +1775,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:1772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -1796,17 +1803,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1800: checking for $ac_hdr" >&5
+echo "configure:1807: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1805 "configure"
+#line 1812 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1810: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1817: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1833,14 +1840,69 @@
 done
 
 
+for ac_func in fopen fread fwrite fclose fseek ftell malloc free snprintf vsnprintf
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1847: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1852 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $ac_func();
 
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+ 
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+
 echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:1839: checking for size_t" >&5
+echo "configure:1901: checking for size_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1844 "configure"
+#line 1906 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1868,12 +1930,12 @@
 fi
 
 echo $ac_n "checking for off_t""... $ac_c" 1>&6
-echo "configure:1872: checking for off_t" >&5
+echo "configure:1934: checking for off_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1877 "configure"
+#line 1939 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1902,7 +1964,7 @@
 
 
 echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:1906: checking size of short" >&5
+echo "configure:1968: checking size of short" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1910,9 +1972,10 @@
   ac_cv_sizeof_short=2
 else
   cat > conftest.$ac_ext <<EOF
-#line 1914 "configure"
+#line 1976 "configure"
 #include "confdefs.h"
 #include <stdio.h>
+#include <sys/types.h>
 main()
 {
   FILE *f=fopen("conftestval", "w");
@@ -1921,7 +1984,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:1925: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1988: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_short=`cat conftestval`
 else
@@ -1941,7 +2004,7 @@
 
 
 echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:1945: checking size of int" >&5
+echo "configure:2008: checking size of int" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1949,9 +2012,10 @@
   ac_cv_sizeof_int=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 1953 "configure"
+#line 2016 "configure"
 #include "confdefs.h"
 #include <stdio.h>
+#include <sys/types.h>
 main()
 {
   FILE *f=fopen("conftestval", "w");
@@ -1960,7 +2024,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:1964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2028: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_int=`cat conftestval`
 else
@@ -1980,7 +2044,7 @@
 
 
 echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:1984: checking size of long" >&5
+echo "configure:2048: checking size of long" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -1988,9 +2052,10 @@
   ac_cv_sizeof_long=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 1992 "configure"
+#line 2056 "configure"
 #include "confdefs.h"
 #include <stdio.h>
+#include <sys/types.h>
 main()
 {
   FILE *f=fopen("conftestval", "w");
@@ -1999,7 +2064,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:2003: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2068: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_long=`cat conftestval`
 else
@@ -2019,7 +2084,7 @@
 
 
 echo $ac_n "checking size of float""... $ac_c" 1>&6
-echo "configure:2023: checking size of float" >&5
+echo "configure:2088: checking size of float" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_float'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2027,9 +2092,10 @@
   ac_cv_sizeof_float=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 2031 "configure"
+#line 2096 "configure"
 #include "confdefs.h"
 #include <stdio.h>
+#include <sys/types.h>
 main()
 {
   FILE *f=fopen("conftestval", "w");
@@ -2038,7 +2104,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:2042: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_float=`cat conftestval`
 else
@@ -2058,7 +2124,7 @@
 
 
 echo $ac_n "checking size of double""... $ac_c" 1>&6
-echo "configure:2062: checking size of double" >&5
+echo "configure:2128: checking size of double" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_double'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2066,9 +2132,10 @@
   ac_cv_sizeof_double=4
 else
   cat > conftest.$ac_ext <<EOF
-#line 2070 "configure"
+#line 2136 "configure"
 #include "confdefs.h"
 #include <stdio.h>
+#include <sys/types.h>
 main()
 {
   FILE *f=fopen("conftestval", "w");
@@ -2077,7 +2144,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:2081: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2148: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_double=`cat conftestval`
 else
@@ -2097,7 +2164,7 @@
 
 
 echo $ac_n "checking size of void*""... $ac_c" 1>&6
-echo "configure:2101: checking size of void*" >&5
+echo "configure:2168: checking size of void*" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_voidp'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2105,9 +2172,10 @@
   ac_cv_sizeof_voidp=8
 else
   cat > conftest.$ac_ext <<EOF
-#line 2109 "configure"
+#line 2176 "configure"
 #include "confdefs.h"
 #include <stdio.h>
+#include <sys/types.h>
 main()
 {
   FILE *f=fopen("conftestval", "w");
@@ -2116,7 +2184,7 @@
   exit(0);
 }
 EOF
-if { (eval echo configure:2120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2188: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_sizeof_voidp=`cat conftestval`
 else
@@ -2139,7 +2207,7 @@
 # Check whether --enable-justsrc or --disable-justsrc was given.
 if test "${enable_justsrc+set}" = set; then
   enableval="$enable_justsrc"
-  ac_arg_justsrc="$enableval"
+  ac_arg_justsrc="Y"
 else
   ac_arg_justsrc="N"
 fi
@@ -2154,9 +2222,37 @@
 fi
 
 
+# Check whether --enable-gcc-opt or --disable-gcc-opt was given.
+if test "${enable_gcc_opt+set}" = set; then
+  enableval="$enable_gcc_opt"
+  ac_arg_gcc_opt="N"
+else
+  ac_arg_gcc_opt="Y"
+fi
+
+
+# Check whether --enable-force-broken-float or --disable-force-broken-float was given.
+if test "${enable_force_broken_float+set}" = set; then
+  enableval="$enable_force_broken_float"
+  ac_arg_broken_float="Y"
+else
+  ac_arg_broken_float="N"
+fi
+
+
 if test $ac_cv_prog_gcc = yes ; then
-	CFLAGS="-g -O2 -Wall -pedantic -Wstrict-prototypes"
-			
+	CFLAGS="$CFLAGS -g -O2 -Wstrict-prototypes"
+	if test "$ac_arg_gcc_opt" = "N" ; then
+		CFLAGS="$CFLAGS -g -O0 -Wstrict-prototypes"
+		echo "configure: warning: *** Compiler optimisations switched off. ***" 1>&2
+		fi
+			case "$target_os" in 
+		darwin* | rhapsody*)
+			;;
+		*)
+			CFLAGS="$CFLAGS -Wall -pedantic"
+			;;
+		esac
 	if test $ac_arg_gcc_pipe != "N" ; then
 	 	CFLAGS="$CFLAGS -pipe"
 	 	fi
@@ -2167,8 +2263,6 @@
 	echo "configure: warning: *** We are cross-compiling, so have to assume sizeof (short) == 2 " 1>&2
 	echo "configure: warning: *** and sizeof (int) == 4. If this is not the case there is no    " 1>&2
 	echo "configure: warning: *** chance of this working. Please contact the mantainer.         " 1>&2
-	echo "configure: warning: *** If the sizeof issues are not a problem you may need to        " 1>&2
-	echo "configure: warning: *** undefine CAN_READ_WRITE_x86_IEEE in src/config.h.             " 1>&2
 	echo "configure: warning: ******************************************************************" 1>&2
 	fi
 	
@@ -2195,7 +2289,7 @@
 	echo "configure: warning: *** sizeof (double) != 8.                                         " 1>&2
 	echo "configure: warning: ******************************************************************" 1>&2
 	fi
-	
+
 case "$target_cpu" in
 	alpha* | i?86 )
 		cat >> confdefs.h <<\EOF
@@ -2227,41 +2321,27 @@
 		;;
 esac
 
-case "$target_cpu" in
-	i?86 )
-		cat >> confdefs.h <<\EOF
-#define CAN_READ_WRITE_x86_IEEE 1
+subdirs="src/GSM610 src/G72x src"
+if test $ac_arg_justsrc = "N" ; then
+	subdirs="$subdirs examples doc tests"
+	fi
+
+if test $ac_arg_broken_float = "Y" ; then
+	cat >> confdefs.h <<\EOF
+#define FORCE_BROKEN_FLOAT 1
 EOF
 
-		;;
-		
-	alpha* | hppa* | m68* | mips* | powerpc* | hppa* | sparc*)
-		cat >> confdefs.h <<\EOF
-#define CAN_READ_WRITE_x86_IEEE 0
+	echo "configure: warning: *** Testing code for processors that can't read/write IEEE floats." 1>&2
+else
+	cat >> confdefs.h <<\EOF
+#define FORCE_BROKEN_FLOAT 0
 EOF
 
-		;;
+	fi
+ 
 
-	*)
-		echo "configure: warning: *****************************************************************" 1>&2
-		echo "configure: warning: *** Not able to determine endian-ness of processor.              " 1>&2
-		echo "configure: warning: *** You will need to edit src/config.h before compiling.         " 1>&2
-		echo "configure: warning: *****************************************************************" 1>&2
-		;;
-esac
 
-case $ac_arg_justsrc in
-		1*|n*|N*)
-			subdirs="src/GSM610 src/G72x src examples doc tests"
-			;;
-		*)
-			subdirs="src/GSM610 src/G72x src"
-			;;
-esac
 
-
-
-
 trap '' 1 2 15
 cat > confcache <<\EOF
 # This file is a shell script that caches the results of configure
@@ -2365,7 +2445,7 @@
 
 trap 'rm -fr `echo "Makefile src/Makefile src/GSM610/Makefile src/G72x/Makefile \
 			examples/Makefile tests/Makefile doc/Makefile Win32/Makefile \
-			MacOS/Makefile m4/Makefile libsndfile.spec src/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+			MacOS/Makefile libsndfile.spec src/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
 EOF
 cat >> $CONFIG_STATUS <<EOF
 
@@ -2426,8 +2506,6 @@
 s%@CC@%$CC%g
 s%@LN_S@%$LN_S%g
 s%@RANLIB@%$RANLIB%g
-s%@LD@%$LD%g
-s%@NM@%$NM%g
 s%@LIBTOOL@%$LIBTOOL%g
 s%@CPP@%$CPP%g
 s%@subdirs@%$subdirs%g
@@ -2475,7 +2553,7 @@
 
 CONFIG_FILES=\${CONFIG_FILES-"Makefile src/Makefile src/GSM610/Makefile src/G72x/Makefile \
 			examples/Makefile tests/Makefile doc/Makefile Win32/Makefile \
-			MacOS/Makefile m4/Makefile libsndfile.spec"}
+			MacOS/Makefile libsndfile.spec"}
 EOF
 cat >> $CONFIG_STATUS <<\EOF
 for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
@@ -2654,5 +2732,4 @@
 chmod +x $CONFIG_STATUS
 rm -fr confdefs* $ac_clean_files
 test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
-
 
--- a/common/libsndfile/configure.in
+++ b/common/libsndfile/configure.in
@@ -1,5 +1,5 @@
 # Configure `libsndfile'.
-# Copyright (C) 1999-2000 Erik de Castro Lopo (erikd@zip.com.au).
+# Copyright (C) 1999-2001 Erik de Castro Lopo (erikd@zip.com.au).
 
 dnl Require autoconf version >= 2.12
 
@@ -7,12 +7,12 @@
 AC_INIT(src/sndfile.c)
 AC_CANONICAL_SYSTEM
 
-AM_INIT_AUTOMAKE(libsndfile,0.0.22)
+AM_INIT_AUTOMAKE(libsndfile,0.0.27)
 
 dnl This is the version info according to the libtool versioning system.
 dnl It does *not* correspond to the release number.
 
-SHARED_VERSION_INFO="0:8:0"
+SHARED_VERSION_INFO="0:27:0"
 
 dnl Process this file with autoconf to produce a configure script.
 
@@ -29,7 +29,7 @@
 
 AC_CHECK_HEADERS(endian.h)
 
-dnl AC_CHECK_FUNCS(fopen fread fwrite fclose fseek ftell malloc free)
+AC_CHECK_FUNCS(fopen fread fwrite fclose fseek ftell malloc free snprintf vsnprintf)
 
 AC_TYPE_SIZE_T
 AC_TYPE_OFF_T
@@ -41,17 +41,34 @@
 AC_CHECK_SIZEOF(double,4)
 AC_CHECK_SIZEOF(void*,8)
 
-AC_ARG_ENABLE(justsrc,  [  --enable-justsrc        only compile library sources ],
-	ac_arg_justsrc="$enableval", ac_arg_justsrc="N")
+AC_ARG_ENABLE(justsrc,  [  --enable-justsrc             only compile library sources ],
+	ac_arg_justsrc="Y", ac_arg_justsrc="N")
 
-AC_ARG_ENABLE(gcc-pipe, [  --disable-gcc-pipe      disable gcc -pipe option ],
+AC_ARG_ENABLE(gcc-pipe, [  --disable-gcc-pipe           disable gcc -pipe option ],
 	ac_arg_gcc_pipe="N", ac_arg_gcc_pipe="Y")
 
+AC_ARG_ENABLE(gcc-opt,  [  --disable-gcc-opt            disable gcc optimisations ],
+	ac_arg_gcc_opt="N", ac_arg_gcc_opt="Y")
+
+AC_ARG_ENABLE(force-broken-float,  
+						[  --enable-force-broken-float  force use of broken float code ],
+	ac_arg_broken_float="Y", ac_arg_broken_float="N")
+
 if test $ac_cv_prog_gcc = yes ; then
-	CFLAGS="-g -O2 -Wall -pedantic -Wstrict-prototypes"
-	dnl CFLAGS="-g -O0 -Wall -Werror -Wstrict-prototypes"
-	dnl AC_MSG_WARN([**** Optimisation has been switched off. ****])
-	
+	CFLAGS="$CFLAGS -g -O2 -Wstrict-prototypes"
+	if test "$ac_arg_gcc_opt" = "N" ; then
+		CFLAGS="$CFLAGS -g -O0 -Wstrict-prototypes"
+		AC_MSG_WARN([[*** Compiler optimisations switched off. ***]])
+		fi
+	dnl Disable -Wall and -pedantic for Apple Darwin/Rhapsody.
+	dnl System headers on these systems are broken.
+	case "$target_os" in 
+		darwin* | rhapsody*)
+			;;
+		*)
+			CFLAGS="$CFLAGS -Wall -pedantic"
+			;;
+		esac
 	if test $ac_arg_gcc_pipe != "N" ; then
 	 	CFLAGS="$CFLAGS -pipe"
 	 	fi
@@ -58,39 +75,37 @@
 	fi
 	
 if test $cross_compiling = yes ; then
-	AC_MSG_WARN([******************************************************************])
-	AC_MSG_WARN([*** We are cross-compiling, so have to assume sizeof (short) == 2 ])
-	AC_MSG_WARN([*** and sizeof (int) == 4. If this is not the case there is no    ])
-	AC_MSG_WARN([*** chance of this working. Please contact the mantainer.         ])
-	AC_MSG_WARN([*** If the sizeof issues are not a problem you may need to        ])
-	AC_MSG_WARN([*** undefine CAN_READ_WRITE_x86_IEEE in src/config.h.             ])
-	AC_MSG_WARN([******************************************************************])
+	AC_MSG_WARN([[******************************************************************]])
+	AC_MSG_WARN([[*** We are cross-compiling, so have to assume sizeof (short) == 2 ]])
+	AC_MSG_WARN([[*** and sizeof (int) == 4. If this is not the case there is no    ]])
+	AC_MSG_WARN([[*** chance of this working. Please contact the mantainer.         ]])
+	AC_MSG_WARN([[******************************************************************]])
 	fi
 	
 if test $ac_cv_sizeof_int != 4 ; then
-	AC_MSG_WARN([******************************************************************])
-	AC_MSG_WARN([*** sizeof (int) != 4                                             ])
-	AC_MSG_WARN([******************************************************************])
+	AC_MSG_WARN([[******************************************************************]])
+	AC_MSG_WARN([[*** sizeof (int) != 4                                             ]])
+	AC_MSG_WARN([[******************************************************************]])
 	fi
 
 if test $ac_cv_sizeof_short != 2 ; then
-	AC_MSG_WARN([******************************************************************])
-	AC_MSG_WARN([*** sizeof (short) != 2.                                          ])
-	AC_MSG_WARN([******************************************************************])
+	AC_MSG_WARN([[******************************************************************]])
+	AC_MSG_WARN([[*** sizeof (short) != 2.                                          ]])
+	AC_MSG_WARN([[******************************************************************]])
 	fi
 	
 if test $ac_cv_sizeof_float != 4 ; then
-	AC_MSG_WARN([******************************************************************])
-	AC_MSG_WARN([*** sizeof (float) != 4.                                          ])
-	AC_MSG_WARN([******************************************************************])
+	AC_MSG_WARN([[******************************************************************]])
+	AC_MSG_WARN([[*** sizeof (float) != 4.                                          ]])
+	AC_MSG_WARN([[******************************************************************]])
 	fi
 	
 if test $ac_cv_sizeof_double != 8 ; then
-	AC_MSG_WARN([******************************************************************])
-	AC_MSG_WARN([*** sizeof (double) != 8.                                         ])
-	AC_MSG_WARN([******************************************************************])
+	AC_MSG_WARN([[******************************************************************]])
+	AC_MSG_WARN([[*** sizeof (double) != 8.                                         ]])
+	AC_MSG_WARN([[******************************************************************]])
 	fi
-	
+
 case "$target_cpu" in
 	alpha* | i?86 )
 		AC_DEFINE(GUESS_LITTLE_ENDIAN,1)
@@ -103,43 +118,28 @@
 		;;
 
 	*)
-		AC_MSG_WARN([*****************************************************************])
-		AC_MSG_WARN([*** Not able to determine endian-ness of processor.              ])
-		AC_MSG_WARN([*** You will need to edit src/config.h before compiling.         ])
-		AC_MSG_WARN([*****************************************************************])
+		AC_MSG_WARN([[*****************************************************************]])
+		AC_MSG_WARN([[*** Not able to determine endian-ness of processor.              ]])
+		AC_MSG_WARN([[*** You will need to edit src/config.h before compiling.         ]])
+		AC_MSG_WARN([[*****************************************************************]])
 		;;
 esac
 
-case "$target_cpu" in
-	i?86 )
-		AC_DEFINE(CAN_READ_WRITE_x86_IEEE,1)
-		;;
-		
-	alpha* | hppa* | m68* | mips* | powerpc* | hppa* | sparc*)
-		AC_DEFINE(CAN_READ_WRITE_x86_IEEE,0)
-		;;
+subdirs="src/GSM610 src/G72x src"
+if test $ac_arg_justsrc = "N" ; then
+	subdirs="$subdirs examples doc tests"
+	fi
 
-	*)
-		AC_MSG_WARN([*****************************************************************])
-		AC_MSG_WARN([*** Not able to determine endian-ness of processor.              ])
-		AC_MSG_WARN([*** You will need to edit src/config.h before compiling.         ])
-		AC_MSG_WARN([*****************************************************************])
-		;;
-esac
-
-case $ac_arg_justsrc in
-		1*|n*|N*)
-			subdirs="src/GSM610 src/G72x src examples doc tests"
-			;;
-		*)
-			subdirs="src/GSM610 src/G72x src"
-			;;
-esac
-
+if test $ac_arg_broken_float = "Y" ; then
+	AC_DEFINE(FORCE_BROKEN_FLOAT,1)
+	AC_MSG_WARN([[*** Testing code for processors that can't read/write IEEE floats.]])
+else
+	AC_DEFINE(FORCE_BROKEN_FLOAT,0)
+	fi
+ 
 AC_SUBST(subdirs)
 AC_SUBST(SHARED_VERSION_INFO)
 
 AC_OUTPUT(Makefile src/Makefile src/GSM610/Makefile src/G72x/Makefile \
 			examples/Makefile tests/Makefile doc/Makefile Win32/Makefile \
-			MacOS/Makefile m4/Makefile libsndfile.spec)
-
+			MacOS/Makefile libsndfile.spec)
--- a/common/libsndfile/doc/ChangeLog
+++ /dev/null
@@ -1,644 +1,0 @@
-2000-08-15  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/sndfile.c
-	Fixed a leak of FILE* pointers in sf_opren_read(). Thanks to Sigbj�rn Skj�ret
-	for spotting this one.
-
-2000-08-13  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/au_g72x.c src/G72x/g72x.c
-	Added G723 encoded AU file support.
-	
-	* tests/lossy_comp_test.c
-	Added tests for G721 and G723 encoded AU files.
-
-2000-08-06  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * all files
-	Changed the license to LGPL. Albert Faber who had copyright on Win32/unistd.h
-	gave his permission to change the license on that file. All other files were
-	either copyright erikd@zip.com.au or copyright under a GPL/LGPL compatible
-	license.
-
-2000-08-06  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * tests/lossy_comp_test.c
-    Fixed incorrect error message.
-    
-    * src/au_g72x.c src/G72x/*
-    G721 encoded AU files now working.
-	
-	* Win32/README-Win32.txt
-	Replaced this file with a new one which gives a full explanation
-	of how to build libsndfile under Win32. Thanks to Mike Ricos.
-
-2000-08-05  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/*.[ch]
-    Removed double leading underscores from the start of all variable and
-    function names. Identifiers with a leading underscores are reserved
-    for use by the compiler.
-    
-    * src/au_g72x.c src/G72x/*
-    Continued work on G721 encoded AU files.
-
-2000-07-12  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/G72x/*
-    New files for reading/writing G721 and G723 ADPCM audio. These files 
-    are from a Sun Microsystems reference implementation released under a 
-    free software licence.
-    Extensive changes to this code to make it fit in with libsndfile.
-    See the ChangeLog in this directory for details.
-    
-    * src/au_g72x.c
-    New file for G721 encoded AU files.
-    
-2000-07-08  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * libsndfile.spec.in
-    Added a spec file for making RPMs. Thanks to Josh Green for supplying this.
-
-2000-06-28  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/sndfile.c src/sndfile.h
-    Add checking for and handling of header-less u-law encoded AU/SND files.
-    Any file with a ".au" or ".snd" file extension and without the normal
-    AU file header is treated as an 8kHz, u-law encoded file.
-    
-    * src/au.h
-    New function for opening a headerless u-law encoded file for read.
-    
-2000-06-04  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/paf.c
-    Add checking for files shorter than minimal PAF file header length.
-
-2000-06-02  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * tests/write_read_test.c
-    Added extra sf_perror() calls when sf_write_XXXX fails.
-
-2000-05-29  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/common.c
-    Modified usage of va_arg() macro to work correctly on PowerPC 
-    Linux. Thanks to Kyle Wheeler for giving me ssh access to his 
-    machine while I was trying to track this down.
-    
-    * configure.in src/*.[ch]
-    Sorted out some endian-ness issues brought up by PowerPC Linux.
-
-    * tests/read_seek_test.c
-    Added extra debugging for when tests fail.
-
-2000-05-18  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/wav.c
-    Fixed bug in GSM 6.10 handling for big-endian machines. Thanks
-    to Sigbj�rn Skj�ret for reporting this.
-    
-2000-04-25  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/sndfile.c src/wav.c src/wav_gsm610.c
-    Finallised writing of GSM 6.10 WAV files.
-    
-    * tests/lossy_comp_test.c
-    Wrote new test code for GSM 6.10 files. 
-    
-    * examples/sfinfo.c
-    Fixed incorrect format in printf() statement.
-
-2000-04-06  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/sndfile.h.in
-    Fixed comments about sf_perror () and sf_error_str ().
-
-2000-03-14  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * configure.in
-    Fixed --enable-justsrc option.
-
-2000-03-07  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * wav.c
-    Fixed checking of bytespersec field of header. Still some weirdness
-    with some files.
-
-2000-03-05  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * tests/lossy_comp_test.c
-    Added option to test PCM WAV files (sanity check).
-    Fixed bug in sf_seek() tests.
-
-2000-02-29  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/sndfile.c src/wav.c
-    Minor changes to allow writing of GSM 6.10 WAV files.
-
-2000-02-28  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * configure.in Makefile.am src/Makefile.am
-    Finally got around to figuring out how to build a single library from 
-    multiple source directories.
-    Reading GSM 6.10 files now seems to work.
-
-2000-01-03  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/wav.c
-    Added more error reporting in read_fmt_chunk().
-
-1999-12-21  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * examples/sfinfo.c
-    Modified program to accept multiple filenames from the command line.
-
-1999-11-27  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/wav_ima_adpcm.c
-    Moved code around in preparation to adding ability to read/write IMA ADPCM
-    encoded AIFF files.
-
-1999-11-16  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/common.c
-    Fixed put_int() and put_short() macros used by _psf_hprintf() which were 
-    causing seg. faults on Sparc Solaris.
-
-1999-11-15  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/common.c
-    Added string.h to includes. Thanks to Sigbjxrn Skjfret.
-    
-    * src/svx.c
-    Fixed __svx_close() function to ensure FORM and BODY chunks are correctly
-    set.
-
-1999-10-01  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/au.c
-    Fixed handling of incorrect size field in AU header on read. Thanks to 
-    Christoph Lauer for finding this problem.
-
-1999-09-28  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/aiff.c
-    Fixed a bug with incorrect SSND chunk length being written. This also lead
-    to finding an minor error in AIFF header parsing. Thanks to Dan Timis for 
-    pointing this out.
-
-1999-09-24  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/paf.c
-    Fixed a bug with reading and writing 24 bit stereo PAF files. This problem
-    came to light when implementing tests for the new functions which operate
-    in terms of frames rather than items.
-
-1999-09-23  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/sndfile.c
-    Modified file type detection to use first 12 bytes of file rather than 
-    file name extension. Required this because NIST files use the same 
-    filename extension as Microsoft WAV files.
-    
-    * src/sndfile.c src/sndfile.h
-    Added short, int and double read/write functions which work in frames rather 
-    than items. This was originally suggested by Maurizio Umberto Puxeddu
-    
-1999-09-22  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/svx.c
-    Finished off implementation of write using __psf_hprintf().
-
-1999-09-21  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/common.h
-    Added a buffer to SF_PRIVATE for writing the header. This is required
-    to make generating headers for IFF/SVX files easier as well as making
-    it easier to do re-write the headers which will be required when 
-    sf_rewrite_header() is implemented.
-
-    * src/common.c
-    Implemented __psf_hprintf() function. This is an internal function
-    which is documented briefly just above the code.
-    
-1999-09-05  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/sndfile.c
-    Fixed a bug in sf_write_raw() where it was returning incorrect values
-    (thanks to Richard Dobson for finding this one). Must put in a test 
-    routine for sf_read_raw and sf_write_raw.
-    
-    * src/aiff.c
-    Fixed default FORMsize in __aiff_open_write ().
-
-    * src/sndfile.c
-    Added copy of filename to internal data structure. IFF/SVX files 
-    contain a NAME header chunk. Both sf_open_read() and sf_open_write()
-    copy the file name (less the leading path information) to the
-    filename field.
-    
-    * src/svx.c
-    Started implementing writing of files.
-
-1999-08-04  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/svx.c
-    New file for reading/writing 8SVX and 16SVX files.
-
-    * src/sndfile.[ch] src/common.h
-    Changes for SVX files.
-    
-    * src/aiff.c
-    Fixed header parsing when unknown chunk is found.
-    
-1999-08-01  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/paf.c
-    New file for reading/writing Ensoniq PARIS audio file format.
-    
-    * src/sndfile.[ch] src/common.h
-    Changes for PAF files.
-    
-    * src/sndfile.[ch]
-    Added stuff for sf_get_lib_version() function.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-1999-07-31  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/sndfile.h MacOS/config.h
-    Fixed minor MacOS configuration issues.
-
-1999-07-30  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * MacOS/
-    Added a new directory for the MacOS config.h file and the
-    readme file.
-
-    * src/aiff.c
-    Fixed calculation of datalength when reading SSND chunk. Thanks to
-    Sigbj�rn Skj�ret for pointing out this error.
-
-1999-07-29  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/sndfile.c src/sndfile.h src/raw.c
-    Further fixing of #includes for MacOS.
-
-1999-07-25  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/wav.c src/aiff.c
-    Added call to ferror () in main header parsing loop of __XXX_open_read
-    functions. This should fix problems on platforms (MacOS, AmigaOS) where 
-    fseek()ing or fread()ing beyond the end of the file puts the FILE*
-    stream in an error state until clearerr() is called.
-    
-    * tests/write_read_test.c
-    Added tests for RAW header-less PCM files.
-    
-    * src/common.h
-    Moved definition of struct tribyte to pcm.c which is the only place
-    which needs it.
-
-    * src/pcm.c
-    Modified all code which assumed sizeof (struct tribyte) == 3. This code
-    did not work on MacOS. Thanks to Ben "Jacobs" for pointing this out.
-
-    * src/au.c
-    Removed <sys/stat.h> from list of #includes (not being used).
-    
-    * src/sndfile.c
-    Added MacOS specific #ifdef to replace <sys/stat.h>.
-    
-    * src/sndfile.h
-    Added MacOS specific #ifdef to replace <sys/stat.h>.
-    
-    * src/sndfile.h
-    Added MacOS specific typedef for off_t.
-    
-    * MacOS-readme.txt
-    New file with instructions for building libsndfile under MacOS. Thanks
-    to Ben "Jacobs" for supplying these instructions.
-    
-1999-07-24  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * configure.in
-    Removed sndfile.h from generated file list as there were no longer
-    any autoconf substitutions being made.
-    
-    * src/raw.c
-    New file for handling raw header-less PCM files. In order to open these
-    for read, the user must specify format, pcmbitwidth and channels in the
-    SF_INFO struct when calling sf_open_read ().
-    
-    * src/sndfile.c
-    Added support for raw header-less PCM files.    
-    
-1999-07-22  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * examples/sfinfo.c
-    Removed options so the sfinfo program always prints out all the information.
-    
-1999-07-19  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/alaw.c
-    New file for A-law encoding (similar to u-law).
-    
-    * tests/alaw_test.c
-    New test program to test the A-law encode/decode lookup tables.
-    
-    * tests/lossy_comp_test.c
-    Added tests for a-law encoded WAV, AU and AULE files.
-    
-1999-07-18  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/sndfile.c src/au.c
-    Removed second "#include <unistd.h>". Thanks to Ben "Jacobs" for pointing
-    this out.
-
-1999-07-18  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * tests/ulaw_test.c
-    New test program to test the u-law encode/decode lookup tables.
-
-1999-07-16  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/sndfile.h
-    Made corrections to comments on the return values from sf_seek ().
-    
-    * src/sndfile.c
-    Fixed boundary condition checking bug and accounting bug in sf_read_raw ().
-
-1999-07-15  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/au.c src/ulaw.c
-    Finished implementation of u-law encoded AU files.
-    
-    * src/wav.c
-    Implemented reading and writing of u-law encoded WAV files.
-
-    * tests/
-    Changed name of adpcm_test.c to lossy_comp_test.c. This test program
-    will now be used to test Ulaw and Alaw encoding as well as APDCM.
-    Added tests for Ulaw encoded WAV files.
-
-1999-07-14  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * tests/adpcm_test.c
-    Initialised amp variable in gen_signal() to remove compiler warning.
-    
-1999-07-12  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/aiff.c
-    In __aiff_open_read () prevented fseek()ing beyond end of file which 
-    was causing trouble on MacOS with the MetroWerks compiler. Thanks to
-    Ben "Jacobs" for pointing this out.
-    
-    *src/wav.c
-    Fixed as above in __wav_open_read ().
-
-1999-07-01    Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/wav_ms_adpcm.c
-    Implemented MS ADPCM encoding. Code cleanup of decoder.
-    
-    * tests/adpcm_test.c
-    Added tests for MS ADPCM WAV files.
-
-    * src/wav_ima_adpcm.c
-    Fixed incorrect parameter in call to srate2blocksize () from
-    __ima_writer_init ().
-    
-1999-06-23  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * tests/read_seek_test.c
-    Added test for 8 bit AIFF files.
-
-1999-06-18  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * tests/write_read_test.c
-    Removed test for IMA ADPCM WAV files which is now done in adpcm_test.c
-
-    * configure.in
-    Added -Wconversion to CFLAGS. 
-    
-    * src/*.c tests/*.c examples/*.c
-    Fixed all warnings resulting from use of -Wconversion. 
-
-1999-06-17  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/wav.c
-    Added fact chunk handling on read and write for all non WAVE_FORMAT_PCM
-    WAV files.
-
-    * src/wav_ima.c
-    Changed block alignment to be dependant on sample rate. This should make
-    WAV files created with libsndfile compatible with the MS Windows media
-    players.
-    
-    * tests/adpcm_test.c
-    Reimplemented adpcm_test_short and implemented adpcm_test_int and adpcm_test_double.
-    Now have full testing of IMA ADPCM WAV file read, write and seek.
-
-1999-06-15  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/wav_float.c
-    Fixed function prototype for x86f2d_array () which was causing ocassional 
-    seg. faults on Sparc Solaris machines.
-
-1999-06-14  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/aiff.c
-    Fixed bug in __aiff_close where the length fields in the header were
-    not being correctly calculated before writing.
-    
-    * tests/write_read_test.c
-    Modified to detect the above bug in WAV, AIFF and AU files.
-
-1999-06-12    Erik de Castro Lopo     <erikd@zip.com.au>
-
-    * Win32/*
-    Added a contribution from Albert Faber to allow libsndfile to compile
-    under Win32 systems. libsndfile will now be used as part of LAME the
-    the MPEG 1 Layer 3 encoder (http://internet.roadrunner.com/~mt/mp3/).
-
-1999-06-11    Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * configure.in
-    Changed to reflect previous changes.
-    
-    * src/wav_ima_adpcm.c
-    Fixed incorrect calculation of bytespersec header field (IMA ADPCM only).
-    
-    Fixed bug when writing from int or double data to IMA ADPCM file. Will need 
-    to write test code for this.
-    
-    Fixed bug in __ima_write () whereby the length of the current block was 
-    calculated incorrectly. Thanks to Jongcheon Park for pointing this out.
-
-1999-03-27  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/*.c
-    Changed all read/write/lseek function calls to fread/fwrite/
-    fseek/ftell and added error checking of return values from
-    fread and fwrite in critical areas of the code.
-    
-    * src/au.c
-    Fixed incorrect datasize element in AU header on write.
-    
-    * tests/error_test.c
-    Add new test to check all error values have an associated error
-    string. This will avoid embarrassing real world core dumps.
-
-1999-03-23  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/wav.c src/aiff.c
-    Added handling for unknown chunk markers in the file. 
-
-1999-03-22  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/sndfile.c
-    Filled in missing error strings in SndfileErrors array. Missing entries 
-    can cause core dumps when calling sf_error-str (). Thanks to Sam 
-    <mrsam at-sign geocities.com> for finding this problem.
-
-1999-03-21  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/wav_ima_adpcm.c
-    Work on wav_ms_adpcm.c uncovered a bug in __ima_read () when reading 
-    stereo files. Caused by not adjusting offset into buffer of decoded
-    samples for 2 channels. A similar bug existed in __ima_write ().
-    Need a test for stereo ADPCM files.
-    
-    * src/wav_ms_adpcm.c
-    Decoder working correctly.
-    
-1999-03-18  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * configure.in Makefile.am
-    Added --enable-justsrc configuration variable sent by Sam
-    <mrsam at-sign geocities.com>.
-    
-    * src/wav_ima_adpcm.c
-    Fixed bug when reading beyond end of data section due to not
-    checking pima->blockcount.
-    This uncovered __ima_seek () bug due to pima->blockcount being set 
-    before calling __ima_init_block ().
-
-1999-03-17  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/wav.c
-    Started implementing MS ADPCM decoder. 
-    If file is WAVE_FORMAT_ADPCM and length of data chunk is odd, this
-    encoder seems to add an extra byte. Why not just give an even data
-    length? 
-
-1999-03-16  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/wav.c
-    Split code out of wav.c to create wav_float.c and wav_ima_adpcm.c.
-    This will make it easier to add and debug other kinds of WAV files
-    in future.
-
-1999-03-14  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * tests/
-    Added adpcm_test.c which implements test functions for
-    IMA ADPCM reading/writing/seeking etc.
-
-    * src/wav.c
-    Fixed many bugs in IMA ADPCM encoder and decoder. 
-    
-1999-03-11  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/wav.c
-    Finished implementing IMA ADPCM encoder and decoder (what a bitch!). 
-    
-1999-03-03  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/wav.c
-    Started implementing IMA ADPCM decoder. 
-
-1999-03-02  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/sndfile.c
-    Fixed bug where the sf_read_XXX functions were returning a 
-    incorrect read count when reading past end of file.
-    Fixed bug in sf_seek () when seeking backwards from end of file.
-
-    * tests/read_seek_test.c
-    Added multiple read test to short_test(), int_test () and
-    double_test ().
-    Added extra chunk to all test WAV files to test that reading
-    stops at end of 'data' chunk.
-
-1999-02-21  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * tests/write_read_test.c
-    Added tests for little DEC endian AU files.
-
-    * src/au.c
-    Add handling for DEC format little endian AU files.
-     
-1999-02-20  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/aiff.c src/au.c src/wav.c
-    Add __psf_sprintf calls during header parsing.
-     
-    * src/sndfile.c src/common.c
-    Implement sf_header_info (sndfile.c) function and __psf_sprintf (common.c).
-
-    * tests/write_read_test.c
-    Added tests for 8 bit PCM files (WAV, AIFF and AU).
-
-    * src/au.c src/aiff.c
-    Add handling of 8 bit PCM data format.
-     
-    * src/aiff.c
-    On write, set blocksize in SSND chunk to zero like everybody else.
-    
-1999-02-16  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/pcm.c:
-    Fixed bug in let2s_array (cptr was not being initialised).
-
-    * src/sndfile.c:
-    Fixed bug in sf_read_raw and sf_write_raw. sf_seek should
-    now work when using these functions.
-
-1999-02-15  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * tests/write_read_test.c:
-    Force test_buffer array to be double aligned. Sparc Solaris
-    requires this.
-
-1999-02-14  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/pcm.c:
-    Fixed a bug which was causing errors in the reading
-    and writing of 24 bit PCM files.
-    
-    * doc/api.html
-    Finished of preliminary documentaion.
-
-1999-02-13  Erik de Castro Lopo  <erikd@zip.com.au>
-
-    * src/aiff.c:
-    Changed reading of 'COMM' chunk to avoid reading an int
-    which overlaps an int (4 byte) boundary.
-
--- a/common/libsndfile/doc/Makefile.am
+++ /dev/null
@@ -1,1 +1,0 @@
-EXTRA_DIST = index.html libsndfile.jpg api.html bugs.html sfinfo.html
--- a/common/libsndfile/doc/Makefile.in
+++ /dev/null
@@ -1,184 +1,0 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
-
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-
-SHELL = @SHELL@
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-
-top_builddir = ..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_alias = @build_alias@
-build_triplet = @build@
-host_alias = @host_alias@
-host_triplet = @host@
-target_alias = @target_alias@
-target_triplet = @target@
-AS = @AS@
-CC = @CC@
-DLLTOOL = @DLLTOOL@
-LD = @LD@
-LIBTOOL = @LIBTOOL@
-LN_S = @LN_S@
-MAKEINFO = @MAKEINFO@
-NM = @NM@
-OBJDUMP = @OBJDUMP@
-PACKAGE = @PACKAGE@
-RANLIB = @RANLIB@
-SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
-VERSION = @VERSION@
-subdirs = @subdirs@
-
-EXTRA_DIST = index.html libsndfile.jpg api.html bugs.html sfinfo.html
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../src/config.h
-CONFIG_CLEAN_FILES = 
-DIST_COMMON =  ChangeLog Makefile.am Makefile.in NEWS
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = gtar
-GZIP_ENV = --best
-all: all-redirect
-.SUFFIXES:
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps doc/Makefile
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-tags: TAGS
-TAGS:
-
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = doc
-
-distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
-	  if test -d $$d/$$file; then \
-	    cp -pr $$/$$file $(distdir)/$$file; \
-	  else \
-	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
-	  fi; \
-	done
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
-check-am: all-am
-check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am:
-install-exec: install-exec-am
-
-install-data-am:
-install-data: install-data-am
-
-install-am: all-am
-	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am:
-uninstall: uninstall-am
-all-am: Makefile
-all-redirect: all-am
-install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-
-
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
-	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
-
-maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am:  clean-generic mostlyclean-am
-
-clean: clean-am
-
-distclean-am:  distclean-generic clean-am
-	-rm -f libtool
-
-distclean: distclean-am
-
-maintainer-clean-am:  maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
-
-maintainer-clean: maintainer-clean-am
-
-.PHONY: tags distdir info-am info dvi-am dvi check check-am \
-installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
-
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
--- a/common/libsndfile/doc/NEWS
+++ /dev/null
@@ -1,58 +1,0 @@
-Version 0.0.21 (2000-08-16)
-  * Offical release.
-  * AU files without the normal AU file header are now recognised as headerless
-    8kHz 8 bit ulaw encoded files.
-  * Added handling for G721 4bit APDCM encoded AU files.
-  * Added handling for G723 3bit APDCM encoded AU files.
-  * Improved Win32 compiling and use instructions from Mike Ricos.
-
-Version 0.0.20 (2000-05-30)
-  * Offical release.
-  * Minor bug fix for LinuxPPC (endian issues).
-
-Version 0.0.19 (2000-05-20)
-  * Offical release.
-  * Minor bug fix for handling GSM 6.10 encoded WAV files on big endian machines.
-
-Version 0.0.18 (2000-04-25)
-  * Offical release.
-  * Added handling for GSM 6.10 encoded WAV files.
-  * Minor bug fixes.
-
-Version 0.0.17 (1999-11-16)
-  * Offical release.
-  * New file formats (SVX and PAF).
-  * Minor bug fixes.
-
-Version 0.0.16 (1999-07-31)
-  * Offical release.
-  * Fixed minor MacOS configuration issues.
-
-Version 0.0.15 (1999-07-30)
-  * Offical release.
-  * Added MS ADPCM WAV file write.
-  * Added WAV and AU file A-law and u-law encoding.
-  * Added RAW header-less PCM file handling.
-  * Added MacOS support (thanks to Ben "Jacobs").
-
-Version 0.0.12 (1999-06-19)
-  * Offical release.
-  * Code cleanup to remove compiler warning messages.
-
-Version 0.0.10 (1999-06-12)
-  * Unoffical release.
-  * Changes to low level code which improve error detection and handling.
-  * Added read-only handling of Microsoft ADPCM WAV files.
-  * Added Win32 support (almost exclusively due to Albert Faber, thanks).
-  * Fixed bug in IMA ADPCM file writing.
-
-Version 0.0.9 (1999-03-14)
-  * Add handling of IMA ADPCM WAV files.
-  * Add new function sf_get_header_info and add example program sfinfo.
-  * Implemented 8 bit PCM data formats for AIFF, AU and WAV.
-  
-Version 0.0.8 (1999-02-16)
-  * First offical release.
-
-Version 0.0.7 (1999-02-13)
-  * First unoffical release.
--- a/common/libsndfile/doc/api.html
+++ /dev/null
@@ -1,329 +1,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN//3.0">
-<HTML>
-
-<HEAD>
-	<TITLE>
-	The libsndfile API.
-	</TITLE>
-	<META NAME="Author"      CONTENT="Erik de Castro Lopo">
-	<META NAME="Version"     CONTENT="Version 0.0.18">
-	<META NAME="Description" CONTENT="The libsndfile API.">
-	<META NAME="Keywords"    CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
-
-</HEAD>
-
-<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#5050FF" VLINK="#5050FF" ALINK="#FF00FF">
-
-<FONT SIZE=3>
-
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>libsndfile</B></FONT>
-<BR><BR>
-	Libsndfile is a library designed to allow the reading and writing of many 
-	different sampled sound file formats (such as MS Windows WAV and the Apple/SGI 
-	AIFF format) through one standard library interface. 
-<BR><BR>
-
-<FONT SIZE=+5 COLOR="#5050FF"><BR><B>SYNOPSIS</B></FONT>
-<BR><BR>
-
-The functions of linbsndfile are defined as follows:
-
-<PRE>
-      #include &lt;stdio.h&gt;
-      #include &lt;sndfile.h&gt;
-        
-      SNDFILE*  <A HREF="#open">sf_open_read</A>     (const char *path, SF_INFO *sfinfo) ;
-      SNDFILE*  <A HREF="#open">sf_open_write</A>    (const char *path, const SF_INFO *sfinfo) ;
-        
-      off_t     <A HREF="#seek">sf_seek</A>          (SNDFILE *sndfile, off_t frames, int whence) ;
-
-      size_t    <A HREF="#raw">sf_read_raw</A>      (SNDFILE *sndfile, void *ptr, size_t bytes) ;
-      size_t    <A HREF="#raw">sf_write_raw</A>     (SNDFILE *sndfile, void *ptr, size_t bytes) ;
-
-      size_t    <A HREF="#read">sf_read_short</A>    (SNDFILE *sndfile, short *ptr, size_t items) ;
-      size_t    <A HREF="#read">sf_read_int</A>      (SNDFILE *sndfile, int *ptr, size_t items) ;
-      size_t    <A HREF="#read">sf_read_double</A>   (SNDFILE *sndfile, double *ptr, size_t items, int normalize) ;
-
-      size_t    <A HREF="#readf">sf_readf_short</A>   (SNDFILE *sndfile, short *ptr, size_t frames) ;
-      size_t    <A HREF="#readf">sf_readf_int</A>     (SNDFILE *sndfile, int *ptr, size_t frames) ;
-      size_t    <A HREF="#readf">sf_readf_double</A>  (SNDFILE *sndfile, double *ptr, size_t frames, int normalize) ;
-
-      size_t    <A HREF="#write">sf_write_short</A>   (SNDFILE *sndfile, short *ptr, size_t items) ;
-      size_t    <A HREF="#write">sf_write_int</A>     (SNDFILE *sndfile, int *ptr, size_t items) ;
-      size_t    <A HREF="#write">sf_write_double</A>  (SNDFILE *sndfile, double *ptr, size_t items, int normalize) ;
-
-      size_t    <A HREF="#writef">sf_writef_short</A>  (SNDFILE *sndfile, short *ptr, size_t frames) ;
-      size_t    <A HREF="#writef">sf_writef_int</A>    (SNDFILE *sndfile, int *ptr, size_t frames) ;
-      size_t    <A HREF="#writef">sf_writef_double</A> (SNDFILE *sndfile, double *ptr, size_t frames, int normalize) ;
-
-      int       <A HREF="#close">sf_close</A>         (SNDFILE *sndfile) ;
-</PRE>
-
-<BR>
-SNDFILE* is an anonymous pointer to data which is private to the library.
-<BR><BR>
-
-<A NAME="open">
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>File Open Functions</B></FONT>
-
-<PRE>
-      SNDFILE*  sf_open_read    (const char *path, SF_INFO *wfinfo) ;
-      SNDFILE*  sf_open_write   (const char *path, const SF_INFO *wfinfo) ;
-</PRE>
-
-The SF_INFO structure is for passing data between the calling function and the library
-when opening a file for read or writing. It is defined in sndfile.h as follows:
-
-<PRE>
-      typedef struct
-      {    int      samplerate ;
-           int      samples ;
-           int      channels ;
-           int      pcmbitwidth ;
-           int      format ;
-           int      sections ;
-           int      seekable ;
-       } SF_INFO ;
-</PRE>
-
-<BR>
-When opening a file for read (with the exception of RAW files where the caller has
-to fill in the channels, pcmbitwidth and format fields), all the structure members 
-are filled in by the library.
-
-<BR><BR>
-When opening a file for write, the caller must fill in structure members samplerate,
-channels, pcmbitwidth and format. For encoded formats (ie u-law, A-law and ADPCM), 
-pcmbitwidth is the bit width before encoding or after decoding.
-
-<BR><BR>
-The format field in the above structure is made up of the bit-wise OR of a major
-format type with a value of 0x10000 or greater and a minor format type with a value
-less than 0x10000. The currently understood formats are listed in sndfile.h as 
-follows and also includes two bitmasks for separating major and minor file types.
-Not all combinations of major and minor file types are valid. 
-
-<PRE>
-      enum
-      {   SF_FORMAT_WAV       = 0x10000,       /* Microsoft WAV format (big endian). */
-          SF_FORMAT_AIFF      = 0x20000,       /* Apple/SGI AIFF format (little endian). */
-          SF_FORMAT_AU        = 0x30000,       /* Sun/NeXT AU format (big endian). */
-          SF_FORMAT_AULE      = 0x40000,       /* DEC AU format (little endian). */
-          SF_FORMAT_RAW       = 0x50000,       /* RAW PCM data. */
-          SF_FORMAT_PAF       = 0x60000,       /* Ensoniq PARIS file format. */
-          SF_FORMAT_SVX       = 0x70000,       /* Amiga IFF / SVX8 / SV16 format. */
-          
-          SF_FORMAT_PCM       = 0x0001,        /* PCM data in 8, 16, 24 or 32 bits. */
-          SF_FORMAT_FLOAT     = 0x0002,        /* 32 bit floats. */
-          SF_FORMAT_ULAW      = 0x0003,        /* U-Law encoded. */
-          SF_FORMAT_ALAW      = 0x0004,        /* A-Law encoded. */
-          SF_FORMAT_IMA_ADPCM = 0x0005,        /* IMA ADPCM. */
-          SF_FORMAT_MS_ADPCM  = 0x0006,        /* Microsoft ADPCM. */
-      
-          SF_FORMAT_PCM_BE    = 0x0007,        /* Big endian PCM data. */
-          SF_FORMAT_PCM_LE    = 0x0008,        /* Little endian PCM data. */
-          SF_FORMAT_PCM_S8    = 0x0009,        /* Signed 8 bit PCM. */
-          SF_FORMAT_PCM_U8    = 0x000A,        /* Unsigned 8 bit PCM. */
-
-          SF_FORMAT_PCM_BE    = 0x0007,        /* RAW PCM (big endian). */
-          SF_FORMAT_PCM_LE    = 0x0008,        /* RAW PCM (little endian). */
-          SF_FORMAT_RAW_S8    = 0x0009,        /* Signed 8 bit RAW PCM. */
-          SF_FORMAT_RAW_U8    = 0x000A,        /* Unsigned 8 bit RAW PCM. */
-          
-          SF_FORMAT_SUBMASK   = 0xFFFF,        
-          SF_FORMAT_TYPEMASK  = 0x7FFF0000
-      } ;
-</PRE>
-
-<BR>
-On success, the sf_open functions return a non NULL pointer which should be passed as
-the first parameter to all subsequent libsndfile calls dealing with that audio file.
-On fail, the sf_open functions return a NULL pointer.
-<BR><BR>
-
-
-<A NAME="seek">
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>File Seek Functions</B></FONT>
-
-<PRE>
-      off_t     sf_seek         (SNDFILE *sndfile, off_t frames, int whence) ;
-</PRE>
-
-The file seek functions work much like lseek in stdio.h with the exception that
-the non-audio data is ignored and the seek only moves within the audio data section of 
-the file. In addition, seeks are defined in number of (multichannel) samples or frames.
-Therefor, for a seek in a stereo file from the current position forward with an offset 
-of 1 would skip forward by one sample of both channels.
-<BR><BR>
-Valid values for the whence parameter are defined to be the same as the lseek function
-and behave as follows:
-
-<PRE>
-      SEEK_SET  - The offset is set to the start of the audio data plus offset (multichannel) samples.
-      SEEK_CUR  - The offset is set to its current location plus offset (multichannel) samples.
-      SEEK_END  - The offset is set to the end of the data plus offset (multichannel) samples.
-</PRE>
-
-Note that frames offset can be negative and in fact should be when SEEK_END is used for the 
-whence parameter. 
-
-<BR><BR>
-sf_seek will return the offset in (multichannel) samples from the start of the audio data
-or -1 if an error occurs (ie an attempt is made to seek beyond the start or end of the file).
-
-<BR>
-<A NAME="read">
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>File Read Functions (Items)</B></FONT>
-
-<PRE>
-      size_t    sf_read_short   (SNDFILE *sndfile, short *ptr, size_t items) ;
-      size_t    sf_read_int     (SNDFILE *sndfile, int *ptr, size_t items) ;
-      size_t    sf_read_double  (SNDFILE *sndfile, double *ptr, size_t items, int normalize) ;
-</PRE>
-
-The file read items functions fill the array pointed to by ptr with the requested
-number of items. The items parameter must be an integer product of the number 
-of channels or an error will occur.
-
-<BR><BR>
-The sf_read_double function has an extra parameter. If normalize is 1, the 
-read operation will return data that is normalized so that the maximum possible 
-full scale sample value of the file on disk will result in a sample value of 1.0 
-in the array, with all other sample values scaled accordingly.
-
-<BR><BR>
-The sf_read_XXXX functions return the number of items read. Unless the end of the
-file was reached during the read, the return value should equal the of items 
-requested. Attempts to read beyond the end of the file will not result in an error 
-but will cause the sf_read_XXXX functions to return less than the number of items 
-requested or 0 if already at the end of the file. On error, a value of -1 is 
-returned.
-
-<BR><BR>
-	
-<A NAME="readf">
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>File Read Functions (Frames)</B></FONT>
-
-<PRE>
-      size_t    sf_readf_short   (SNDFILE *sndfile, short *ptr, size_t frames) ;
-      size_t    sf_readf_int     (SNDFILE *sndfile, int *ptr, size_t frames) ;
-      size_t    sf_readf_double  (SNDFILE *sndfile, double *ptr, size_t frames, int normalize) ;
-</PRE>
-
-The file read frames functions fill the array pointed to by ptr with the requested
-number of frames of data. The array must be large enough to hold the product of
-frames and the number of channels.
-
-<BR><BR>
-The sf_readf_double function has an extra parameter. If normalize is 1, the 
-read operation will return data that is normalized so that the maximum possible 
-full scale sample value of the file on disk will result in a sample value of 1.0 
-in the array, with all other sample values scaled accordingly.
-
-<BR><BR>
-The sf_readf_XXXX functions return the number of frames read. Unless the end of the
-file was reached during the read, the return value should equal the of frames 
-requested. Attempts to read beyond the end of the file will not result in an error 
-but will cause the sf_readf_XXXX functions to return less than the number of frames 
-requested or 0 if already at the end of the file. On error, a value of -1 is 
-returned.
-
-<BR><BR>
-	
-<A NAME="write">
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>File Write Functions (Items)</B></FONT>
-
-<PRE>
-      size_t    sf_write_short   (SNDFILE *sndfile, short *ptr, size_t items) ;
-      size_t    sf_write_int     (SNDFILE *sndfile, int *ptr, size_t items) ;
-      size_t    sf_write_double  (SNDFILE *sndfile, double *ptr, size_t items, int normalize) ;
-</PRE>
-
-
-The file write items functions write the data in the array pointed to by ptr to the file.
-The items parameter must be an integer product of the number of channels or an error 
-will occur.
-
-<BR><BR>
-The sf_write_double function has an extra parameter. If normalize is 1, the write 
-operation will assume that data in the array is normalize so that all values are
-between -1 and 1 and will scale the samples to fill the bitwidth of the disk file
-format. If normalize is zero, no scaling will take place and the samples will be
-truncated and written to disk as integers of 8, 16, 24 or 32 bits.
-
-<BR><BR>
-The sf_write_XXXX functions return the number of items written (which should be the
-same as the items parameter) or -1 if an error has occurred. 
-<BR><BR>
-	
-<A NAME="writef">
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>File Write Functions (Frames)</B></FONT>
-
-<PRE>
-      size_t    sf_writef_short  (SNDFILE *sndfile, short *ptr, size_t frames) ;
-      size_t    sf_writef_int    (SNDFILE *sndfile, int *ptr, size_t frames) ;
-      size_t    sf_writef_double (SNDFILE *sndfile, double *ptr, size_t frames, int normalize) ;
-</PRE>
-
-
-The file write frames functions write the data in the array pointed to by ptr to the file.
-The array must be large enough to hold the product of frames and the number of channels.
-
-<BR><BR>
-The sf_writef_double function has an extra parameter. If normalize is 1, the write 
-operation will assume that data in the array is normalize so that all values are
-between -1 and 1 and will scale the samples to fill the bitwidth of the disk file
-format. If normalize is zero, no scaling will take place and the samples will be
-truncated and written to disk as integers of 8, 16, 24 or 32 bits.
-
-<BR><BR>
-The sf_writef_XXXX functions return the number of frames written (which should be the
-same as the frames parameter) or -1 if an error has occurred. 
-<BR><BR>
-	
-<A NAME="raw">
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>Raw File Read and Write Functions</B></FONT>
-
-
-<PRE>
-      size_t    sf_read_raw     (SNDFILE *sndfile, void *ptr, size_t bytes) ;
-      size_t    sf_write_raw    (SNDFILE *sndfile, void *ptr, size_t bytes) ;
-</PRE>
-
-The raw write and write functions read raw audio data from the audio file (not to be
-confused with reading RAW header-less PCM files). The number of bytes read or written 
-must always be an integer multiple of the number of channels multiplied by the number 
-of bytes required to represent one sample from one channel.
-
-<BR><BR>
-The raw read and write functions return the number of bytes read or written (which 
-should be the same as the bytes parameter) or -1 if an error has occurred. 
-<BR><BR>
-
-<A NAME="close">
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>File Close Function</B></FONT>
-
-
-<PRE>
-      int       sf_close        (SNDFILE *sndfile) ;
-</PRE>
-
-The close function closes the file, deallocates it's internal buffers and returns
-0 on success or an error value.
-
-<BR><BR>
-<BR>
-
-<HR>
-
-<BR><BR>
-	The libsndfile home page is 
-		<A HREF="http://www.zip.com.au/~erikd/libsndfile/">here</A>.
-<P>
-Version : 0.0.18
-</P>
-
-
-</FONT>
-</BODY>
-</HTML>
--- a/common/libsndfile/doc/bugs.html
+++ /dev/null
@@ -1,61 +1,0 @@
-<HTML>
-
-<HEAD>
-	<TITLE>
-	Bug Reporting
-	</TITLE>
-	<META NAME="Author"      CONTENT="Erik de Castro Lopo (erikd@zip.com.au)">
-</HEAD>
-
-<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#9090FF" VLINK="#5050FF" ALINK="#FF00FF">
-
-<FONT SIZE=3>
-
-<FONT SIZE=+20 COLOR="#5050FF">
-	<BR>
-	<CENTER>
-		<B>Reporting Bugs in libsndfile</B>
-	</CENTER>
-</FONT>
-
-<BR><BR>
-	I am interested in finding and fixing all genuine bugs in libsndfile. Bugs I want to
-	fix include	any of the following problems (and probably others) :
-	<UL>
-	<LI>	compilation problems on new platforms
-	<LI>	errors being detected during the `make check' process
-	<LI>	segmentation faults occuring inside libsndfile
-	<LI>	libsndfile hanging when opening a file
-	<LI>	supported sound file types being incorrectly read or written
-	<LI>	errors or spelling mistakes in the documentation
-	</UL>
-	
-<BR>
-	When submitting a bug report you must include :
-	<UL>
-	<LI>	the operating system you are using
-	<LI>	the compiler you are using 
-	<LI>	a description of the problem
-	<LI>	information generated by the sfinfo program (see next paragraph)
-	</UL>
-	
-<BR>
-	If libsndfile compiles and installs correctly but has difficulty reading a particular 
-	file or type of file you should run the <B>sfinfo</B> program (from the examples 
-	directory of the libsndfile distribution) on the file. See 
-		<A HREF="sfinfo.html">here</A>
-	for an example of the use of the <B>sfinfo</B> program.
-
-<BR><BR>
-	Please do not send me a sound file which fails to open under libsndfile unless I
-	specifically ask you to. The above information should usually suffice for most
-	problems.
-	
-<BR><BR>
-	Once you have the above information you may mail it to me at
-		 <A HREF="mailto:erikd@zip.com.au">erikd@zip.com.au</a>.
-
-<BR><BR>
-</FONT>
-</BODY>
-</HTML>
--- a/common/libsndfile/doc/index.html
+++ /dev/null
@@ -1,229 +1,0 @@
-<HTML>
-
-<HEAD>
-	<TITLE>
-	libsndfile
-	</TITLE>
-	<META NAME="Author"      CONTENT="Erik de Castro Lopo (erikd@zip.com.au)">
-    <META NAME="Version"     CONTENT="libsndfile-0.0.21">
-	<META NAME="Description" CONTENT="The `libsndfile' Home Page">
-	<META NAME="Keywords"    CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
-	<META NAME="ROBOTS" 	 CONTENT="NOFOLLOW">
-
-</HEAD>
-
-<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#9090FF" VLINK="#5050FF" ALINK="#FF00FF">
-
-<CENTER>
-	<IMG SRC="libsndfile.jpg" HEIGHT=98 WIDTH=367 ALT="libsndfile.jpg">
-</CENTER>
-	
-<CENTER>
-		<A HREF="#History">History</A> -+- 
-		<A HREF="#Capabilities">Capabilities</A> -+- 
-		<A HREF="#Similar">Similar or Related Projects</A> 
-		<BR> 
-		<A HREF="api.html">Programming Interface</A> -+- 
-		<A HREF="bugs.html">Bug Reporting</A> -+- 
-		<A HREF="#Download">Download</A>
-		<BR> 
-		<A HREF="NEWS">News</A> -+- 
-		<A HREF="ChangeLog">Change Log</A> -+- 
-		<A HREF="#Licensing">Licensing Information</A>
-</CENTER>
-
-<FONT SIZE=3>
-
-<BR><BR>
-	Libsndfile is a C library for reading and writing files containing sampled sound 
-	(such as MS Windows WAV and the Apple/SGI AIFF format) through one standard 
-	library interface. It is released in source code format under the 
-		<A HREF="http://www.gnu.org/copyleft/lesser.html">Gnu Lesser General Public License</A>.
-<BR><BR>
-	The library was written to compile and run on a Linux system but should compile
-	and run on just about any Unix. It can also be compiled and run on Win32 systems
-	using the Microsoft compiler and MacOS using the Metrowerks compiler (thanks to 
-	Ben "Jacobs"). There are directions for compiling libsndfile on these platforms
-	in the Win32 and MacOS directories of the source code distribution.
-<BR><BR>	
-	It was designed to handle both little-endian (such as WAV) and big-endian 
-	(such as AIFF) data, and to compile and run correctly on little-endian (such as Intel 
-	and DEC/Compaq Alpha) processor systems as well as big-endian processor systems such 
-	as Motorola 68k, Power PC, MIPS and Sparc. Hopefully the design of the library will 
-	also make it easy to extend for reading and writing new sound file formats.
-<BR><BR>
-    It has so far been compiled and tested on the following systems:
-	<UL>
-	<LI>i586-pc-linux-gnu (Redhat 5.2 glibc)
- 	<LI>powerpc-unknown-linux-gnu (Linux PPC)
- 	<LI>mips-sgi-irix5.3 (Native IRIX toolset)
-	<LI>sparc-sun-solaris2.7 (gcc)
-	<LI>sparc-sun-solaris2.5.1 (gcc)
-	<LI>mips-sgi-irix5.3 (gcc)
-	<LI>mips-sgi-irix6.3 (cc - native compiler)
-	<BR>
-	<LI>Win32 (Microsoft Visual C++)
-	<LI>MacOS 8.6 (Metrowerks Codewarrior Pro4)
-	</UL>
-<BR>
-
-<A NAME="Capabilities">
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>Capabilities</B></FONT>
-
-<BR><BR>
-	libsndfile is currently capable of reading and writing the following sound file
-	formats :
-	<UL>
-	<LI> Microsoft WAV 8, 16, 24 and 32 bit integer PCM.
-    <LI> Microsoft 32 bit floating point PCM. 
-    <LI> Microsoft IMA/DVI ADPCM WAV format (16 bits per sample compressed to 4 bits per sample). 
-    <LI> Microsoft ADPCM WAV format (16 bits per sample compressed to 4 bits per sample). 
-    <LI> Microsoft 8 bit A-law an u-law formats (16 bits per sample compressed to 8 bits per sample). 
-    <LI> Microsoft WAV files using GSM 6.10 encoding.
-    <LI> Apple/SGI AIFF and AIFC uncompressed 8, 16, 24 and 32 bit integer PCM. 
-    <LI> Sun/NeXT AU/SND format (big endian 8, 16, 24 and 32 bit PCM, 8 bit u-law and 8 bit A-law). 
-    <LI> Dec AU format (little endian 8, 16, 24 and 32 bit PCM, 8 bit u-law and 8 bit A-law). 
-    <LI> Headerless 8kHz 8bit u-law encoded AU/SND files.
-    <LI> G721 and G723 ADPCM encoded AU/SND files.
-    <LI> RAW header-less PCM files of 8 (signed and unsigned), 16, 24 and 32 bits. The 16, 24 and 32 
-			bit files may be big or little endian byte ordering. The 8 bit samples may be signed
-			or unsigned values.
-    <LI> Amiga uncompressed IFF / 8SVX / 16SV PCM files (8 and 16 bit).
-    <LI> Ensoniq PARIS big and little endian, 16 and 24 bit PCM files (.PAF).
-	</UL>
-<BR>
-	Some of the file formats I am also interested in adding are:
-	<UL>
-	<LI> Soundfont II.
-	<LI> Gravis Ultrasound patch files.
-	<LI> Kurzweil K2000 sampler files.
-	<LI> MPEG Layer 3.
-	</UL>
-<BR>
-	Other file formats may also be added on request.
-<BR><BR>
-
-<A NAME="History">
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>History</B></FONT>
-
-<BR><BR>
-	My first attempt at reading and writing WAV files was in 1990 or so under Windows
-	3.1. I started using Linux in early 1995 and contributed some code to the 
-		<A HREF="http://www.vaxxine.com/ve3wwg/gnuwave.html">wavplay</A>
-	program which would eventually mutate into this library. As one of my interests
-	is Digital Signal Processing (DSP) I decided that as well as reading data from an
-	audio file in the native format (typically 16 bit short integers) it would also 
-	be useful to be able to have the library do the conversion to floating point numbers
-	for DSP applications. It then dawned on me that whatever file format (anything from
-	8 bit unsigned chars, to 32 bit floating point numbers) the library should be able 
-	to convert the data to whatever format the library user wishes to use it in. For 
-	example, in a sound playback program, the library caller typically wants the sound 
-	data in 16 bit short integers to dump into a sound card even though the data in the
-	file may be 32 bit floating point numbers (ie Microsoft's WAVE_FORMAT_IEEE_FLOAT 
-	format). Another example would be someone doing speech recognition research who has
-	recorded some speech as a 16 bit WAV file but wants to process it as double precision 
-	floating point numbers.
-<BR><BR>
-    Here is the release history for libsndfile :
-	<UL>
-	<LI>Version 0.0.8 (Feb 15 1999) First official release.
-	<LI>Version 0.0.9 (Mar 14 1999) Added support for IMA ADPCM WAV files and
-		8 bit PCM AIFF, AU and WAV files.
-	<LI>Version 0.0.12 (Jun 19 1999) Added <B>read only</B> support for MS ADPCM WAV files plus
-		a number of bug fixes and code cleanups. It now also compiles and runs on Win32 systems
-		using the Microsoft compiler (thanks to the efforts of Albert Faber).
-	<LI>Version 0.0.15 (Jul 30 1999) Added ability to write MS ADPCM WAV files. Added WAV and AU
-		file A-law and u-law encoding/decoding. Added RAW headerless PCM file handling. It now
-		also compiles and runs on MacOS using the Metrowerks compiler (thanks to Ben "Jacobs").
-	<LI>Version 0.0.16 (Jul 31 1999) Fixed minor MacOS problems.
-	<LI>Version 0.0.17 (Nov 16 1999) Added Ensoniq PARIS audio file format, Amiga IFF / 8SVX / 16SV
-		file format and minor bug fixes.
-	<LI>Version 0.0.18 (Apr 25 2000) Added read/write capabilities for GSM 6.10 encoded WAV files.
-	<LI>Version 0.0.19 (May 20 2000) Minor bug fix for GSM 6.10 encoded WAV files on big endian 
-	<LI>Version 0.0.20 (May 30 2000) Minor bug fix for LinuxPPC. Fixes endian-ness related compile 
-	<LI>Version 0.0.21 (Aug 16 2000) Added handling of headerless AU/SND files. Added handling
-		of G721 and G723 ADPCM AU/SND files. New improved Win32 compiling and use instructions. 
-		License change from GPL to LGPL.
-	<LI>Version 0.0.22 (Oct 17 2000) Bug fix for G723 encoded AU files. References to GPL replaced
-		with LGPL.
-	</UL>
-<BR>
-	
-<A NAME="Similar">
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>Similar or Related Projects</B></FONT>
-
-<BR><BR>
-	<UL>
-	<LI><A HREF="http://home.sprynet.com/~cbagwell/sox.html">SoX</A> is a program for 
-		converting between sound file formats.
-	<LI><A HREF="http://members.home.com/ve3wwg/gnuwave.html">Wavplay</A> started out 
-		as a minimal WAV file player under Linux and has mutated into Gnuwave a client/server
-		application for more general multimedia and games sound playback.
-	<LI><A HREF="http://www.68k.org/~michael/audiofile/">Audiofile</A> (libaudiofile) is 
-		a library similar to libsndfile but with a different programming interface. The 
-		author Michael Pruett has set out to clone (and fix some bugs) the libaudiofile 
-		library which ships with SGI's IRIX OS. If I had known of this project earlier I 
-		may not have started on libsndfile.	
-	<LI><A HREF="ftp://ccrma-ftp.stanford.edu/pub/Lisp/sndlib.tar.gz">sndlib.tar.gz</A> is 
-		another library written by Bill Schottstaedt of CCRMA.
-	</UL>
-<BR>
-
-<A NAME="Licensing">
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>Licensing</B></FONT>
-
-<BR><BR>
-	libsndfile is released under the terms of the GNU Lesser General Public License. You may 
-	read the license 
-		<A HREF="http://www.gnu.org/copyleft/lesser.html">here</A> 
-	or read a simple explanation of the ideas behind the GPL and the LGPL  
-		<A HREF="http://www.gnu.org/copyleft/copyleft.html">here</A>. 
-<BR><BR>
-	
-<A NAME="Download">
-<FONT SIZE=+20 COLOR="#5050FF"><BR><B>Download</B></FONT>
-
-<BR><BR>
-	Here is the latest version. It is available in the following formats.
-	<UL>
-	<LI>Source code as a .tar.gz :
-		<A HREF="libsndfile-0.0.21.tar.gz">libsndfile-0.0.21.tar.gz</A>
-	<LI>Source code as a Zip file :
-		<A HREF="libsndfile-0_0_21.zip">libsndfile-0_0_21.zip</A>
-	<LI>Linux source RPM :
-		<A HREF="libsndfile-0.0.21-1.src.rpm">libsndfile-0.0.21-1.src.rpm</A>
-	<LI>Linux i386 binary RPM :
-		<A HREF="libsndfile-0.0.21-1.i386.rpm">libsndfile-0.0.21-1.i386.rpm</A>
-	<LI>Linux i386 development RPM :
-		<A HREF="libsndfile-devel-0.0.21-1.i386.rpm">libsndfile-devel-0.0.21-1.i386.rpm</A>
-		
-	</UL>
-<BR><BR>
-
-<HR>
-
-<BR>
-	The latest version of this document can be found
-		<A HREF="http://www.zip.com.au/~erikd/libsndfile/">here</A>.
-
-<P>
-Author : 
-	<A HREF="mailto:erikd@zip.com.au">Erik de Castro Lopo</a>
-<BR>
-
-</P>
-
-This page has been accessed
-	<IMG SRC="/cgi-bin/counter?ft=6|frgb=55;55;55|tr=0|trgb=0;0;0|
-	wxh=15;20|md=6|dd=B|st=1|sh=1|df=libsndfile.dat" HEIGHT=30 WIDTH=100>
-times.
-<! Oct 13, 2000 - 20000 hits>
-
-<BR><BR>
-<BR>
-
-</FONT>
-
-
-</BODY>
-</HTML>
binary files a/common/libsndfile/doc/libsndfile.jpg /dev/null differ
--- a/common/libsndfile/doc/sfinfo.html
+++ /dev/null
@@ -1,51 +1,0 @@
-<HTML>
-
-<HEAD>
-	<TITLE>
-	sfinfo
-	</TITLE>
-	<META NAME="Author"      CONTENT="Erik de Castro Lopo (erikd@zip.com.au)">
-</HEAD>
-
-<BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#9090FF" VLINK="#5050FF" ALINK="#FF00FF">
-
-<FONT SIZE=3>
-
-<BR>
-	Here is an example of the output from the <B>sfinfo</B> program distributed with libsndfile.
-
-<BR><BR>
-	This file was opened and parsed correctly but had been truncated so that the values
-	in the <B>FORM</B> and <B>SSND</B> chunks were incorrect.
-	<PRE>
-        <B>erikd@hendrix ></B> examples/sfinfo truncated.aiff 
-        truncated.aiff
-        size : 200000
-        FORM : 307474 (should be 199992)
-         AIFF
-         COMM : 18
-          Sample Rate : 16000
-          Samples     : 76857
-          Channels    : 2
-          Sample Size : 16
-         SSND : 307436 (should be 199946)
-          Offset     : 0
-          Block Size : 0
-        
-        --------------------------------
-        Sample Rate : 16000
-        Samples     : 76857
-        Channels    : 2
-        Bit Width   : 16
-        Format      : 0x00020001
-        Sections    : 1
-        Seekable    : TRUE
-        Signal Max  : 32766
-        	
-        </PRE>
-
-</FONT>
-
-
-</BODY>
-</HTML>
--- a/common/libsndfile/examples/Makefile.am
+++ /dev/null
@@ -1,22 +1,0 @@
-noinst_PROGRAMS = sfconvert sndfile2oct wav32_aiff24 make_sine sfinfo sfhexdump
-
-SNDFILEDIR =../src
-INCLUDES = -I$(srcdir)/$(SNDFILEDIR)
-
-sfconvert_SOURCES = sfconvert.c 
-sfconvert_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-sndfile2oct_SOURCES = sndfile2oct.c 
-sndfile2oct_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-wav32_aiff24_SOURCES = wav32_aiff24.c 
-wav32_aiff24_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-make_sine_SOURCES = make_sine.c 
-make_sine_LDADD = $(SNDFILEDIR)/libsndfile.la -lm
-
-sfinfo_SOURCES = sfinfo.c 
-sfinfo_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-sfhexdump_SOURCES = sfhexdump.c 
-sfhexdump_LDADD = $(SNDFILEDIR)/libsndfile.la
--- a/common/libsndfile/examples/Makefile.in
+++ /dev/null
@@ -1,356 +1,0 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
-
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-
-SHELL = @SHELL@
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-
-top_builddir = ..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_alias = @build_alias@
-build_triplet = @build@
-host_alias = @host_alias@
-host_triplet = @host@
-target_alias = @target_alias@
-target_triplet = @target@
-AS = @AS@
-CC = @CC@
-DLLTOOL = @DLLTOOL@
-LD = @LD@
-LIBTOOL = @LIBTOOL@
-LN_S = @LN_S@
-MAKEINFO = @MAKEINFO@
-NM = @NM@
-OBJDUMP = @OBJDUMP@
-PACKAGE = @PACKAGE@
-RANLIB = @RANLIB@
-SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
-VERSION = @VERSION@
-subdirs = @subdirs@
-
-noinst_PROGRAMS = sfconvert sndfile2oct wav32_aiff24 make_sine sfinfo sfhexdump
-
-SNDFILEDIR = ../src
-INCLUDES = -I$(srcdir)/$(SNDFILEDIR)
-
-sfconvert_SOURCES = sfconvert.c 
-sfconvert_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-sndfile2oct_SOURCES = sndfile2oct.c 
-sndfile2oct_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-wav32_aiff24_SOURCES = wav32_aiff24.c 
-wav32_aiff24_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-make_sine_SOURCES = make_sine.c 
-make_sine_LDADD = $(SNDFILEDIR)/libsndfile.la -lm
-
-sfinfo_SOURCES = sfinfo.c 
-sfinfo_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-sfhexdump_SOURCES = sfhexdump.c 
-sfhexdump_LDADD = $(SNDFILEDIR)/libsndfile.la
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../src/config.h
-CONFIG_CLEAN_FILES = 
-PROGRAMS =  $(noinst_PROGRAMS)
-
-
-DEFS = @DEFS@ -I. -I$(srcdir) -I../src
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-sfconvert_OBJECTS =  sfconvert.o
-sfconvert_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-sfconvert_LDFLAGS = 
-sndfile2oct_OBJECTS =  sndfile2oct.o
-sndfile2oct_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-sndfile2oct_LDFLAGS = 
-wav32_aiff24_OBJECTS =  wav32_aiff24.o
-wav32_aiff24_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-wav32_aiff24_LDFLAGS = 
-make_sine_OBJECTS =  make_sine.o
-make_sine_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-make_sine_LDFLAGS = 
-sfinfo_OBJECTS =  sfinfo.o
-sfinfo_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-sfinfo_LDFLAGS = 
-sfhexdump_OBJECTS =  sfhexdump.o
-sfhexdump_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-sfhexdump_LDFLAGS = 
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-DIST_COMMON =  Makefile.am Makefile.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = gtar
-GZIP_ENV = --best
-SOURCES = $(sfconvert_SOURCES) $(sndfile2oct_SOURCES) $(wav32_aiff24_SOURCES) $(make_sine_SOURCES) $(sfinfo_SOURCES) $(sfhexdump_SOURCES)
-OBJECTS = $(sfconvert_OBJECTS) $(sndfile2oct_OBJECTS) $(wav32_aiff24_OBJECTS) $(make_sine_OBJECTS) $(sfinfo_OBJECTS) $(sfhexdump_OBJECTS)
-
-all: all-redirect
-.SUFFIXES:
-.SUFFIXES: .S .c .lo .o .s
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps examples/Makefile
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-mostlyclean-noinstPROGRAMS:
-
-clean-noinstPROGRAMS:
-	-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
-
-distclean-noinstPROGRAMS:
-
-maintainer-clean-noinstPROGRAMS:
-
-.c.o:
-	$(COMPILE) -c $<
-
-.s.o:
-	$(COMPILE) -c $<
-
-.S.o:
-	$(COMPILE) -c $<
-
-mostlyclean-compile:
-	-rm -f *.o core *.core
-
-clean-compile:
-
-distclean-compile:
-	-rm -f *.tab.c
-
-maintainer-clean-compile:
-
-.c.lo:
-	$(LIBTOOL) --mode=compile $(COMPILE) -c $<
-
-.s.lo:
-	$(LIBTOOL) --mode=compile $(COMPILE) -c $<
-
-.S.lo:
-	$(LIBTOOL) --mode=compile $(COMPILE) -c $<
-
-mostlyclean-libtool:
-	-rm -f *.lo
-
-clean-libtool:
-	-rm -rf .libs _libs
-
-distclean-libtool:
-
-maintainer-clean-libtool:
-
-sfconvert: $(sfconvert_OBJECTS) $(sfconvert_DEPENDENCIES)
-	@rm -f sfconvert
-	$(LINK) $(sfconvert_LDFLAGS) $(sfconvert_OBJECTS) $(sfconvert_LDADD) $(LIBS)
-
-sndfile2oct: $(sndfile2oct_OBJECTS) $(sndfile2oct_DEPENDENCIES)
-	@rm -f sndfile2oct
-	$(LINK) $(sndfile2oct_LDFLAGS) $(sndfile2oct_OBJECTS) $(sndfile2oct_LDADD) $(LIBS)
-
-wav32_aiff24: $(wav32_aiff24_OBJECTS) $(wav32_aiff24_DEPENDENCIES)
-	@rm -f wav32_aiff24
-	$(LINK) $(wav32_aiff24_LDFLAGS) $(wav32_aiff24_OBJECTS) $(wav32_aiff24_LDADD) $(LIBS)
-
-make_sine: $(make_sine_OBJECTS) $(make_sine_DEPENDENCIES)
-	@rm -f make_sine
-	$(LINK) $(make_sine_LDFLAGS) $(make_sine_OBJECTS) $(make_sine_LDADD) $(LIBS)
-
-sfinfo: $(sfinfo_OBJECTS) $(sfinfo_DEPENDENCIES)
-	@rm -f sfinfo
-	$(LINK) $(sfinfo_LDFLAGS) $(sfinfo_OBJECTS) $(sfinfo_LDADD) $(LIBS)
-
-sfhexdump: $(sfhexdump_OBJECTS) $(sfhexdump_DEPENDENCIES)
-	@rm -f sfhexdump
-	$(LINK) $(sfhexdump_LDFLAGS) $(sfhexdump_OBJECTS) $(sfhexdump_LDADD) $(LIBS)
-
-tags: TAGS
-
-ID: $(HEADERS) $(SOURCES) $(LISP)
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	here=`pwd` && cd $(srcdir) \
-	  && mkid -f$$here/ID $$unique $(LISP)
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
-	tags=; \
-	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
-
-mostlyclean-tags:
-
-clean-tags:
-
-distclean-tags:
-	-rm -f TAGS ID
-
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = examples
-
-distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
-	  if test -d $$d/$$file; then \
-	    cp -pr $$/$$file $(distdir)/$$file; \
-	  else \
-	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
-	  fi; \
-	done
-make_sine.o: make_sine.c ../src/sndfile.h
-sfconvert.o: sfconvert.c ../src/sndfile.h
-sfhexdump.o: sfhexdump.c ../src/sndfile.h
-sfinfo.o: sfinfo.c ../src/sndfile.h
-sndfile2oct.o: sndfile2oct.c ../src/sndfile.h
-wav32_aiff24.o: wav32_aiff24.c ../src/sndfile.h
-
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
-check-am: all-am
-check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am:
-install-exec: install-exec-am
-
-install-data-am:
-install-data: install-data-am
-
-install-am: all-am
-	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am:
-uninstall: uninstall-am
-all-am: Makefile $(PROGRAMS)
-all-redirect: all-am
-install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-
-
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
-	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
-
-maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-noinstPROGRAMS mostlyclean-compile \
-		mostlyclean-libtool mostlyclean-tags \
-		mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am:  clean-noinstPROGRAMS clean-compile clean-libtool clean-tags \
-		clean-generic mostlyclean-am
-
-clean: clean-am
-
-distclean-am:  distclean-noinstPROGRAMS distclean-compile \
-		distclean-libtool distclean-tags distclean-generic \
-		clean-am
-	-rm -f libtool
-
-distclean: distclean-am
-
-maintainer-clean-am:  maintainer-clean-noinstPROGRAMS \
-		maintainer-clean-compile maintainer-clean-libtool \
-		maintainer-clean-tags maintainer-clean-generic \
-		distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
-
-maintainer-clean: maintainer-clean-am
-
-.PHONY: mostlyclean-noinstPROGRAMS distclean-noinstPROGRAMS \
-clean-noinstPROGRAMS maintainer-clean-noinstPROGRAMS \
-mostlyclean-compile distclean-compile clean-compile \
-maintainer-clean-compile mostlyclean-libtool distclean-libtool \
-clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
-distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
-dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
-install-exec install-data-am install-data install-am install \
-uninstall-am uninstall all-redirect all-am all installdirs \
-mostlyclean-generic distclean-generic clean-generic \
-maintainer-clean-generic clean mostlyclean distclean maintainer-clean
-
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
--- a/common/libsndfile/examples/make_sine.c
+++ /dev/null
@@ -1,58 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-#include	<stdio.h>
-#include	<math.h>
-
-#include	<sndfile.h>
-
-#define		SINE_LENGTH		(4096)
-
-#ifndef M_PI
-	#define M_PI 3.14159
-#endif
-
-int main (void)
-{	SNDFILE	*file ;
-	SF_INFO	sfinfo ;
-	int		k ;
-	double	val ;
-	
-	memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	sfinfo.samplerate  = 8000 ;
-	sfinfo.samples     = SINE_LENGTH ;
-	sfinfo.pcmbitwidth = 16 ;
-	sfinfo.channels	   = 1 ;
-	sfinfo.format      = (SF_FORMAT_SVX | SF_FORMAT_PCM) ;
-
-	if (! (file = sf_open_write ("sine.svx", &sfinfo)))
-	{	printf ("Error : Not able to open output file.\n") ;
-		return 1 ;
-		} ;
-		
-	for (k = 0 ; k < SINE_LENGTH ; k++)
-	{	val = 32000 * sin (2.0 * M_PI * ((double) k) / ((double) SINE_LENGTH)) ;
-		if (sf_write_double (file, &val, 1, 0) != 1)
-			sf_perror (file) ;
-		} ;
-
-	sf_close (file) ;
-	return	 0 ;
-} /* main */
--- a/common/libsndfile/examples/sfconvert.c
+++ /dev/null
@@ -1,196 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-#include	<stdio.h>
-#include	<string.h>
-#include	<ctype.h>
-
-#include	<sndfile.h>
-
-#define	 BUFFER_LEN      1024
-
-
-typedef	struct
-{	char	*infilename, *outfilename ;
-	SF_INFO	infileinfo, outfileinfo ;
-} OptionData ;
-
-static
-void    copy_data (SNDFILE *outfile, SNDFILE *infile, unsigned int len, double normfactor)
-{	static double	data [BUFFER_LEN] ;
-	unsigned int	readcount, k ;
-
-	readcount = len ;
-	while (readcount == len)
-	{	readcount = sf_read_double (infile, data, len, 0) ;
-		for (k = 0 ; k < readcount ; k++)
-			data [k] *= normfactor ;
-		sf_write_double (outfile, data, readcount, 0) ;
-		} ;
-
-	return ;
-} /* copy_data */
-
-static
-int	guess_output_file_type (char *str, unsigned int format)
-{	char	buffer [16], *cptr ;
-	int		k ;
-	
-	format &= SF_FORMAT_SUBMASK ;
-
-	if (! (cptr = strrchr (str, '.')))
-		return 0 ;
-
-	strncpy (buffer, cptr + 1, 15) ;
-	buffer [15] = 0 ;
-	
-	for (k = 0 ; buffer [k] ; k++)
-		buffer [k] = tolower ((buffer [k])) ;
-		
-	if (! strncmp (buffer, "aif", 3))
-		return	(SF_FORMAT_AIFF | format) ;
-	if (! strcmp (buffer, "wav"))
-		return	(SF_FORMAT_WAV | format) ;
-	if (! strcmp (buffer, "au") || ! strcmp (buffer, "snd"))
-		return	(SF_FORMAT_AU | format) ;
-	return	0 ;
-} /* guess_output_file_type */
-
-
-static
-void	print_usage (char *progname)
-{	printf ("\nUsage : %s [options] <input file> <output file>\n", progname) ;
-	printf ("\n        where [options] may be one of the following:\n") ;
-	printf ("            -pcm16     : force the output to 16 bit pcm\n") ;
-	printf ("            -pcm24     : force the output to 24 bit pcm\n") ;
-	printf ("            -pcm32     : force the output to 32 bit pcm\n") ;
-	printf ("\n        with one of the following extra specifiers:\n") ;
-	printf ("            -fullscale	: force the output signal to the full bit width\n") ;
-	printf ("\n") ;
-} /* print_usage */
-
-int     main (int argc, char *argv[])
-{	char 		*progname, *infilename, *outfilename ;
-	SNDFILE	 	*infile, *outfile ;
-	SF_INFO	 	sfinfo ;
-	int			k, outfilemajor ;
-	int			outfileminor = 0, outfilebits = 0, fullscale = 0 ;
-	double		normfactor ;
-
-	progname = strrchr (argv [0], '/') ;
-	progname = progname ? progname + 1 : argv [0] ;
-		
-	if (argc < 3 || argc > 5)
-	{	print_usage (progname) ;
-		return  1 ;
-		} ;
-		
-	infilename = argv [argc-2] ;
-	outfilename = argv [argc-1] ;
-		
-	if (! strcmp (infilename, outfilename))
-	{	printf ("Error : Input and output filenames are the same.\n\n") ;
-		print_usage (progname) ;
-		return  1 ;
-		} ;
-		
-	if (infilename [0] == '-')
-	{	printf ("Error : Input filename (%s) looks like an option.\n\n", infilename) ;
-		print_usage (progname) ;
-		return  1 ;
-		} ;
-	
-	if (outfilename [0] == '-')
-	{	printf ("Error : Output filename (%s) looks like an option.\n\n", outfilename) ;
-		print_usage (progname) ;
-		return  1 ;
-		} ;
-		
-	for (k = 1 ; k < argc - 2 ; k++)
-	{	printf ("%s\n", argv [k]) ;
-		if (! strcmp (argv [k], "-pcm16"))
-		{	outfileminor = SF_FORMAT_PCM ;
-			outfilebits = 16 ;
-			continue ;
-			} ;
-		if (! strcmp (argv [k], "-pcm24"))
-		{	outfileminor = SF_FORMAT_PCM ;
-			outfilebits = 24 ;
-			continue ;
-			} ;
-		if (! strcmp (argv [k], "-pcm32"))
-		{	outfileminor = SF_FORMAT_PCM ;
-			outfilebits = 32 ;
-			continue ;
-			} ;
-		if (! strcmp (argv [k], "-fullscale"))
-			fullscale = 1 ;
-		} ;
-
-	
-	if (! (infile = sf_open_read (infilename, &sfinfo)))
-	{	printf ("Not able to open input file %s.\n", infilename) ;
-		sf_perror (NULL) ;
-		return  1 ;
-		} ;
-		
-	if (! (sfinfo.format = guess_output_file_type (outfilename, sfinfo.format)))
-	{	printf ("Error : Not able to determine output file type for %s.\n", outfilename) ;
-		return 1 ;
-		} ;
-	
-	outfilemajor = sfinfo.format & SF_FORMAT_TYPEMASK ;
-
-	if (outfileminor)
-	{	sfinfo.format = outfilemajor | outfileminor ;
-		printf ("asdasdasdad\n") ;
-		}
-	else
-		sfinfo.format = outfilemajor | (sfinfo.format & SF_FORMAT_SUBMASK) ;
-		
-	if (outfilebits)
-		sfinfo.pcmbitwidth = outfilebits ;
-		
-	if (! sf_format_check (&sfinfo))
-	{	printf ("Error : output file format is invalid (0x%08X).\n", sfinfo.format) ;
-		return 1 ;
-		} ;	
-
-	normfactor = sf_signal_max (infile) ;
-	if (normfactor < 1.0 && normfactor > 0.0)
-		normfactor = fullscale ? 2.0 / normfactor * ((double) (1 << (sfinfo.pcmbitwidth - 2))) : 
-								2.0 * ((double) (1 << (sfinfo.pcmbitwidth - 2))) ;
-	else
-		normfactor = 1.0 ;
-	
-	printf ("normfactor : %g\n", normfactor) ;
-	
-	if (! (outfile = sf_open_write (outfilename, &sfinfo)))
-	{	printf ("Not able to open output file %s.\n", outfilename) ;
-		return  1 ;
-		} ;
-		
-	copy_data (outfile, infile, BUFFER_LEN / sfinfo.channels, normfactor) ;
-		
-	sf_close (infile) ;
-	sf_close (outfile) ;
-	
-	return 0 ;
-} /* main */
-
--- a/common/libsndfile/examples/sfhexdump.c
+++ /dev/null
@@ -1,78 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-#include	<stdio.h>
-#include	<string.h>
-#include	<ctype.h>
-
-#include	<sndfile.h>
-
-#define	 BUFFER_LEN      4096
-
-static
-void	print_usage (char *progname)
-{	printf ("\nUsage : %s <file>\n", progname) ;
-	printf ("\n") ;
-} /* print_usage */
-
-int     main (int argc, char *argv[])
-{	static	char	strbuffer [BUFFER_LEN] ;
-	unsigned int	linecount ;
-	char 		*progname, *infilename ;
-	SNDFILE	 	*infile ;
-	SF_INFO	 	sfinfo ;
-	int			k, start, readcount ;
-
-	progname = strrchr (argv [0], '/') ;
-	progname = progname ? progname + 1 : argv [0] ;
-		
-	if (argc != 2)
-	{	print_usage (progname) ;
-		return  1 ;
-		} ;
-		
-	infilename = argv [1] ;
-		
-	if (! (infile = sf_open_read (infilename, &sfinfo)))
-	{	printf ("Error : Not able to open input file %s.\n", infilename) ;
-		sf_perror (NULL) ;
-		sf_get_header_info (NULL, strbuffer, BUFFER_LEN, 0) ;
-		printf (strbuffer) ;
-		return  1 ;
-		} ;
-		
-	start = 0 ;
-	
-	linecount = 24 ;
-	
-	while ((readcount = sf_read_raw (infile, strbuffer, linecount)))
-	{	printf ("%08X: ", start) ;
-		for (k = 0 ; k < readcount ; k++)
-			printf ("%02X ", strbuffer [k] & 0xFF) ;
-		for (k = readcount ; k < 16 ; k++)
-			printf ("   ") ;
-		printf ("\n") ;
-		start += readcount ;
-		} ;
-
-	sf_close (infile) ;
-	
-	return 0 ;
-} /* main */
-
--- a/common/libsndfile/examples/sfinfo.c
+++ /dev/null
@@ -1,84 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-#include	<stdio.h>
-#include	<string.h>
-#include	<ctype.h>
-
-#include	<sndfile.h>
-
-#define	 BUFFER_LEN      4096
-
-static
-void	print_usage (char *progname)
-{	char buffer [256] ;
-	
-	sf_get_lib_version (buffer, 256) ;
-	printf ("libsndfile version : %s\n\n", buffer) ;
-	printf ("\nUsage : %s <file>\n", progname) ;
-	printf ("\n        Prints out information about a sound file.\n") ;
-	printf ("\n") ;
-} /* print_usage */
-
-int     main (int argc, char *argv[])
-{	static	char	strbuffer [BUFFER_LEN] ;
-	char 		*progname, *infilename ;
-	SNDFILE	 	*infile ;
-	SF_INFO	 	sfinfo ;
-	int			k ;
-
-	progname = strrchr (argv [0], '/') ;
-	progname = progname ? progname + 1 : argv [0] ;
-		
-	if (argc < 2)
-	{	print_usage (progname) ;
-		return  1 ;
-		} ;
-		
-	for (k = 1 ; k < argc ; k++)	
-	{	infilename = argv [k] ;
-		
-		infile = sf_open_read (infilename, &sfinfo) ;
-	
-		sf_get_header_info (infile, strbuffer, BUFFER_LEN, 0) ;
-		puts (strbuffer) ;
-
-		printf ("--------------------------------\n") ;
-		
-		if (infile)
-		{	printf ("Sample Rate : %d\n", sfinfo.samplerate) ;
-			printf ("Samples     : %d\n", sfinfo.samples) ;
-			printf ("Channels    : %d\n", sfinfo.channels) ;
-			printf ("Bit Width   : %d\n", sfinfo.pcmbitwidth) ;
-			printf ("Format      : 0x%08X\n", sfinfo.format) ;
-			printf ("Sections    : %d\n", sfinfo.sections) ;
-			printf ("Seekable    : %s\n", (sfinfo.seekable ? "TRUE" : "FALSE")) ;
-			printf ("Signal Max  : %g\n", sf_signal_max (infile)) ;
-			}
-		else
-		{	printf ("Error : Not able to open input file %s.\n", infilename) ;
-			sf_perror (NULL) ;
-			} ;
-
-		sf_close (infile) ;
-		} ;
-	
-	return 0 ;
-} /* main */
-
--- a/common/libsndfile/examples/sndfile2oct.c
+++ /dev/null
@@ -1,95 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-#include	<stdio.h>
-#include	<string.h>
-#include	<ctype.h>
-
-#include	<sndfile.h>
-
-#define	 BUFFER_LEN      400
-
-
-int     main (int argc, char *argv[])
-{	static double	data [BUFFER_LEN] ;
-	char 			*progname, *infilename, *outfilename, *cptr ;
-	SNDFILE	 		*infile ;
-	SF_INFO	 		sfinfo ;
-	FILE			*outfile ;
-	unsigned int	k, readcount, len, total ;
-
-	progname = strrchr (argv [0], '/') ;
-	progname = progname ? progname + 1 : argv [0] ;
-		
-	if (argc != 3)
-	{	printf ("\n Usage : %s <input file> <output file>\n\n", progname) ;
-		return  1 ;
-		} ;
-		
-	infilename  = argv [1] ;
-	outfilename = argv [2] ;
-	
-	if (! strcmp (infilename, outfilename))
-	{	printf ("Error : Input and output filename are the same.\n") ;
-		return 1 ;
-		} ;
-		
-	if (! (infile = sf_open_read (infilename, &sfinfo)))
-	{	printf ("Not able to open input file %s.\n", infilename) ;
-		sf_perror (NULL) ;
-		return  1 ;
-		} ;
-		
-	if (! (outfile = fopen (outfilename, "w")))
-	{	printf ("Not able to open output file %s.\n", outfilename) ;
-		sf_perror (NULL) ;
-		return  1 ;
-		} ;
-		
-	outfilename = strrchr (argv [2], '/') ;
-	outfilename = outfilename ? outfilename + 1 : argv [2] ;
-	if ((cptr = strchr (outfilename, '.')))
-		*cptr = 0 ;
-		
-	fprintf (outfile, "# name: %s\n", outfilename) ;
-	fprintf (outfile, "# type: matrix\n") ;
-	fprintf (outfile, "# rows: %d\n", sfinfo.samples) ;
-	fprintf (outfile, "# columns: %d", sfinfo.channels) ;
-		
-	len = BUFFER_LEN - (BUFFER_LEN % sfinfo.channels) ;
-	total = 0 ;
-	while ((readcount = sf_read_double (infile, data, len, 0)))
-	{	
-		for (k = 0 ; k < readcount ; k++)
-		{	if (! (k % sfinfo.channels))
-				fprintf (outfile, "\n") ;
-			fprintf (outfile, "%g ", data [k]) ;
-			} ;
-		memset (data, 0, len * sizeof (double)) ;
-		total += readcount ;
-		} ;
-	if (total != sfinfo.samples * sfinfo.channels)
-		printf ("Error : Values read (%d) != samples * channels (%d)\n", total, sfinfo.samples * sfinfo.channels) ;
-
-	fclose (outfile) ;
-	sf_close (infile) ;
-	
-	return 0 ;
-} /* main */
-
--- a/common/libsndfile/examples/wav32_aiff24.c
+++ /dev/null
@@ -1,109 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-#include	<stdio.h>
-#include	<string.h>
-#include	<ctype.h>
-
-#include	<sndfile.h>
-
-#define	 BUFFER_LEN      1024
-
-static double	data [BUFFER_LEN] ;
-	
-static
-void    copy_data (SNDFILE *outfile, SNDFILE *infile, unsigned int len, double normfactor)
-{	unsigned int	readcount, k ;
-
-	readcount = len ;
-	while (readcount == len)
-	{	readcount = sf_read_double (infile, data, len, 0) ;
-		for (k = 0 ; k < readcount ; k++)
-			data [k] *= normfactor ;
-		sf_write_double (outfile, data, readcount, 0) ;
-		} ;
-
-	return ;
-} /* copy_data */
-
-static
-void	print_usage (char *progname)
-{	
-	printf ("\nConverts a 32 bit floating point WAV file into a 24 bit PCM AIFF file.\n") ;
-	printf ("        Usage : %s <input file> <output file>\n\n", progname) ;
-} /* print_usage */
-
-int     main (int argc, char *argv[])
-{	char 		*progname, *infilename, *outfilename ;
-	SNDFILE	 	*infile, *outfile ;
-	SF_INFO	 	sfinfo ;
-	double		normfactor ;
-
-	progname = strrchr (argv [0], '/') ;
-	progname = progname ? progname + 1 : argv [0] ;
-		
-	if (argc != 3)
-	{	print_usage (progname) ;
-		return  1 ;
-		} ;
-		
-	infilename = argv [1] ;
-	outfilename = argv [2] ;
-		
-	if (! strcmp (infilename, outfilename))
-	{	printf ("Error : Input and output filenames are the same.\n\n") ;
-		print_usage (progname) ;
-		return  1 ;
-		} ;
-		
-	if (! (infile = sf_open_read (infilename, &sfinfo)))
-	{	printf ("Not able to open input file %s.\n", infilename) ;
-		sf_perror (NULL) ;
-		return  1 ;
-		} ;
-		
-	if (sfinfo.format != (SF_FORMAT_WAV | SF_FORMAT_FLOAT))
-	{	printf ("Error : Input file %s is not a 32 bit floating point WAV file.\n", infilename) ;
-		return  1 ;
-		} ;
-	
-	sfinfo.format = (SF_FORMAT_AIFF | SF_FORMAT_PCM) ;
-	sfinfo.pcmbitwidth = 24 ;
-		
-	normfactor = sf_signal_max (infile) ;
-	if (normfactor < 1.0 && normfactor > 0.0)
-		normfactor = ((double) 0x400000) ;
-	else
-		normfactor = 1.0 ;
-	
-	printf ("normfactor : %g\n", normfactor) ;
-	
-	if (! (outfile = sf_open_write (outfilename, &sfinfo)))
-	{	printf ("Not able to open output file %s.\n", outfilename) ;
-		return  1 ;
-		} ;
-		
-	copy_data (outfile, infile, BUFFER_LEN / sfinfo.channels, normfactor) ;
-		
-	sf_close (infile) ;
-	sf_close (outfile) ;
-	
-	return 0 ;
-} /* main */
-
--- a/common/libsndfile/libsndfile.spec
+++ b/common/libsndfile/libsndfile.spec
@@ -1,6 +1,6 @@
 
 %define name    libsndfile
-%define version 0.0.22
+%define version 0.0.27
 %define release 1
 %define prefix  /usr
 
--- a/common/libsndfile/ltconfig
+++ b/common/libsndfile/ltconfig
@@ -53,7 +53,7 @@
 
 # Find the correct PATH separator.  Usually this is `:', but
 # DJGPP uses `;' like DOS.
-if test "X${PATH_SEPARATOR+set}" != "Xset"; then
+if test "X${PATH_SEPARATOR+set}" != Xset; then
   UNAME=${UNAME-`uname 2>/dev/null`}
   case X$UNAME in
     *-DOS) PATH_SEPARATOR=';' ;;
@@ -63,9 +63,9 @@
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
-if test "${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi
+if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
 
-if test "X${echo_test_string+set}" != "Xset"; then
+if test "X${echo_test_string+set}" != Xset; then
   # find a string as large as possible, as long as the shell can cope with it
   for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
     # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
@@ -169,10 +169,10 @@
 # Constants:
 PROGRAM=ltconfig
 PACKAGE=libtool
-VERSION=1.3.3
-TIMESTAMP=" (1.385.2.181 1999/07/02 15:49:11)"
-ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.c 1>&5'
-ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.c $LIBS 1>&5'
+VERSION=1.3.5
+TIMESTAMP=" (1.385.2.206 2000/05/27 11:12:27)"
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
 rm="rm -f"
 
 help="Try \`$progname --help' for more information."
@@ -369,8 +369,8 @@
 # Only set LANG and LC_ALL to C if already set.
 # These must not be set unconditionally because not all systems understand
 # e.g. LANG=C (notably SCO).
-if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
-if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
+if test "X${LC_ALL+set}" = Xset; then LC_ALL=C; export LC_ALL; fi
+if test "X${LANG+set}"   = Xset; then LANG=C;   export LANG;   fi
 
 if test -n "$cache_file" && test -r "$cache_file"; then
   echo "loading cache $cache_file within ltconfig"
@@ -462,7 +462,7 @@
   # AIX sometimes has problems with the GCC collect2 program.  For some
   # reason, if we set the COLLECT_NAMES environment variable, the problems
   # vanish in a puff of smoke.
-  if test "${COLLECT_NAMES+set}" != set; then
+  if test "X${COLLECT_NAMES+set}" != Xset; then
     COLLECT_NAMES=
     export COLLECT_NAMES
   fi
@@ -663,7 +663,7 @@
   link_static_flag='-static'
 
   case "$host_os" in
-  beos* | irix5* | irix6* | osf3* | osf4*)
+  beos* | irix5* | irix6* | osf3* | osf4* | osf5*)
     # PIC is the default for these OSes.
     ;;
   aix*)
@@ -718,7 +718,7 @@
     # We can build DLLs from non-PIC.
     ;;
 
-  osf3* | osf4*)
+  osf3* | osf4* | osf5*)
     # All OSF/1 code is PIC.
     wl='-Wl,'
     link_static_flag='-non_shared'
@@ -1164,15 +1164,21 @@
     # Extract the symbol export list from an `--export-all' def file,
     # then regenerate the def file from the symbol export list, so that
     # the compiled dll only exports the symbol export list.
+    # Be careful not to strip the DATA tag left by newer dlltools.
     export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~
       test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~
       $DLLTOOL --export-all --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def $objdir/$soname-def  $objdir/$soname-ltdll.$objext $libobjs $convenience~
-      sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]* ; *//" < $objdir/$soname-def > $export_symbols'
+      sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $objdir/$soname-def > $export_symbols'
 
+    # If DATA tags from a recent dlltool are present, honour them!
     archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~
       _lt_hint=1;
-      for symbol in `cat $export_symbols`; do
-	echo "	\$symbol @ \$_lt_hint ; " >> $objdir/$soname-def;
+      cat $export_symbols | while read symbol; do
+        set dummy \$symbol;
+        case \$# in
+          2) echo "	\$2 @ \$_lt_hint ; " >> $objdir/$soname-def;;
+          *) echo "     \$2 @ \$_lt_hint \$3 ; " >> $objdir/$soname-def;;
+        esac;
 	_lt_hint=`expr 1 + \$_lt_hint`;
       done~
       test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~
@@ -1187,7 +1193,7 @@
     ;;
 
   netbsd*)
-    if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
       archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
       archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
     else
@@ -1196,7 +1202,7 @@
     fi
     ;;
 
-  solaris*)
+  solaris* | sysv5*)
     if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
       ld_shlibs=no
       cat <<EOF 1>&2
@@ -1244,7 +1250,12 @@
       whole_archive_flag_spec=
       ;;
     *)
-      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then
+        whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+        whole_archive_flag_spec=
+      fi
       ;;
     esac
   fi
@@ -1405,7 +1416,7 @@
     old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def'
     ;;
 
-  osf3* | osf4*)
+  osf3*)
     if test "$with_gcc" = yes; then
       allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
       archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
@@ -1417,6 +1428,24 @@
     hardcode_libdir_separator=:
     ;;
 
+  osf4* | osf5*)  # As osf3* with the addition of the -msym flag
+    if test "$with_gcc" = yes; then
+      allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+      archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
+    else
+      allow_undefined_flag=' -expect_unresolved \*'
+      archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
+    fi
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_separator=:
+    ;;
+  rhapsody*)
+    archive_cmds='$CC -bundle -undefined suppress -o $lib $libobjs $deplibs $linkopts'
+    hardcode_libdir_flags_spec='-L$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+                                       
   sco3.2v5*)
     archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
     hardcode_shlibpath_var=no
@@ -1449,7 +1478,13 @@
     ;;
 
   sysv4)
-    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    if test "x$host_vendor" = xsequent; then
+      # Use $CC to link under sequent, because it throws in some extra .o 
+      # files that make .init and .fini sections work.
+      archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $linkopts'
+    else
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    fi
     runpath_var='LD_RUN_PATH'
     hardcode_shlibpath_var=no
     hardcode_direct=no #Motorola manual says yes, but my tests say they lie 
@@ -1461,6 +1496,18 @@
     export_dynamic_flag_spec='-Bexport'
     ;;
 
+  sysv5*)
+    no_undefined_flag=' -z text'
+    # $CC -shared without GNU ld will not create a library from C++
+    # object files and a static libstdc++, better avoid it by now
+    archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts'
+    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp'
+    hardcode_libdir_flag_spec=
+    hardcode_shlibpath_var=no
+    runpath_var='LD_RUN_PATH'
+    ;;
+
   uts4*)
     archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
     hardcode_libdir_flag_spec='-L$libdir'
@@ -1474,16 +1521,30 @@
     ;;
 
   sysv4*MP*)
-    if test -d /usr/nec ;then
-    # archive_cmds='$LD -G -z text -h $soname -o $lib$libobjs$deplibs'
-    archive_cmds='$LD -G -h $soname -o $lib$libobjs$deplibs'
+    if test -d /usr/nec; then
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+      hardcode_shlibpath_var=no
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ld_shlibs=yes
+    fi
+    ;;
+
+  sysv4.2uw2*)
+    archive_cmds='$LD -G -o $lib $libobjs $deplibs $linkopts'
+    hardcode_direct=yes
+    hardcode_minus_L=no
     hardcode_shlibpath_var=no
-    runpath_var=LD_RUN_PATH
     hardcode_runpath_var=yes
-    ld_shlibs=yes
-    fi
+    runpath_var=LD_RUN_PATH
     ;;
 
+  unixware7*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    runpath_var='LD_RUN_PATH'
+    hardcode_shlibpath_var=no
+    ;;
+
   *)
     ld_shlibs=no
     ;;
@@ -1589,11 +1650,11 @@
 main(){nm_test_var='a';nm_test_func();return(0);}
 EOF
 
-  echo "$progname:1592: checking if global_symbol_pipe works" >&5
-  if { (eval echo $progname:1593: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then
+  echo "$progname:1653: checking if global_symbol_pipe works" >&5
+  if { (eval echo $progname:1654: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then
     # Now try to grab the symbols.
     nlist=conftest.nm
-    if { echo "$progname:1596: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then
+    if { echo "$progname:1657: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then
 
       # Try sorting and uniquifying the output.
       if sort "$nlist" | uniq > "$nlist"T; then
@@ -1645,7 +1706,7 @@
 	  save_CFLAGS="$CFLAGS"
 	  LIBS="conftstm.$objext"
 	  CFLAGS="$CFLAGS$no_builtin_flag"
-	  if { (eval echo $progname:1648: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+	  if { (eval echo $progname:1709: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
 	    pipe_works=yes
 	  else
 	    echo "$progname: failed program was:" >&5
@@ -1787,8 +1848,9 @@
 
 bsdi4*)
   version_type=linux
-  library_names_spec='${libname}.so$major ${libname}.so'
-  soname_spec='${libname}.so'
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
@@ -1796,6 +1858,7 @@
   file_magic_test_file=/shlib/libc.so
   sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
   sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  export_dynamic_flag_spec=-rdynamic
   # the default ld.so.conf also contains /usr/contrib/lib and
   # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
   # libtool to hard-code these into programs
@@ -1841,10 +1904,9 @@
       need_version=yes
       ;;
   esac
-  finish_cmds='PATH="\$PATH:/sbin" OBJFORMAT="'"$objformat"'" ldconfig -m $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   case "$host_os" in
-  freebsd2* | freebsd3.[01]*)
+  freebsd2* | freebsd3.[01]* | freebsdelf3.[01]*)
     shlibpath_overrides_runpath=yes
     ;;
   *) # from 3.2 on
@@ -1875,6 +1937,14 @@
   soname_spec='${libname}${release}.sl$major'
   # HP-UX runs *really* slowly unless shared libraries are mode 555.
   postinstall_cmds='chmod 555 $lib'
+  case "$host_os" in
+  hpux10.20*)
+    # TODO:  Does this work for hpux-11 too?
+    deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
+    file_magic_cmd=/usr/bin/file
+    file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
   ;;
 
 irix5* | irix6*)
@@ -1896,8 +1966,6 @@
     *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;;
     *) libsuff= shlibsuff= libmagic=never-match;;
     esac
-    # this will be overridden with pass_all, but let us keep it just in case
-    deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1"
     ;;
   esac
   shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
@@ -1924,9 +1992,7 @@
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
   shlibpath_overrides_runpath=no
-  deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
-  file_magic_cmd=/usr/bin/file
-  file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so`
+  deplibs_check_method=pass_all
 
   if test -f /lib/ld.so.1; then
     dynamic_linker='GNU ld.so'
@@ -1972,7 +2038,7 @@
   shlibpath_var=LIBPATH
   ;;
 
-osf3* | osf4*)
+osf3* | osf4* | osf5*)
   version_type=osf
   need_version=no
   soname_spec='${libname}${release}.so'
@@ -1987,6 +2053,14 @@
   sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
   ;;
 
+rhapsody*)
+  version_type=sunos
+  library_names_spec='${libname}.so'
+  soname_spec='${libname}.so'
+  shlibpath_var=DYLD_LIBRARY_PATH
+  deplibs_check_method=pass_all
+  ;;
+
 sco3.2v5*)
   version_type=osf
   soname_spec='${libname}${release}.so$major'
@@ -2027,6 +2101,10 @@
   soname_spec='${libname}${release}.so$major'
   shlibpath_var=LD_LIBRARY_PATH
   case "$host_vendor" in
+    sequent)
+      file_magic_cmd='/bin/file'
+      deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+      ;;
     ncr)
       deplibs_check_method='pass_all'
       ;;
@@ -2167,7 +2245,7 @@
 if eval "test \"`echo '$''{'lt_cv_dlopen'+set}'`\" != set"; then
   lt_cv_dlopen=no lt_cv_dlopen_libs=
 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "$progname:2170: checking for dlopen in -ldl" >&5
+echo "$progname:2248: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2175,10 +2253,13 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2178 "ltconfig"
+#line 2256 "ltconfig"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
 char dlopen();
 
 int main() {
@@ -2185,7 +2266,7 @@
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo $progname:2188: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo $progname:2269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2204,12 +2285,12 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "$progname:2207: checking for dlopen" >&5
+echo "$progname:2288: checking for dlopen" >&5
 if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2212 "ltconfig"
+#line 2293 "ltconfig"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char dlopen(); below.  */
 #include <assert.h>
@@ -2216,6 +2297,9 @@
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
 char dlopen();
 
 int main() {
@@ -2231,7 +2315,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo $progname:2234: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo $progname:2318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_dlopen=yes"
 else
@@ -2248,7 +2332,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6
-echo "$progname:2251: checking for dld_link in -ldld" >&5
+echo "$progname:2335: checking for dld_link in -ldld" >&5
 ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2256,10 +2340,13 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldld  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2259 "ltconfig"
+#line 2343 "ltconfig"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
 char dld_link();
 
 int main() {
@@ -2266,7 +2353,7 @@
 dld_link()
 ; return 0; }
 EOF
-if { (eval echo $progname:2269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo $progname:2356: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2285,12 +2372,12 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for shl_load""... $ac_c" 1>&6
-echo "$progname:2288: checking for shl_load" >&5
+echo "$progname:2375: checking for shl_load" >&5
 if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2293 "ltconfig"
+#line 2380 "ltconfig"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shl_load(); below.  */
 #include <assert.h>
@@ -2297,6 +2384,9 @@
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
 char shl_load();
 
 int main() {
@@ -2312,7 +2402,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo $progname:2315: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo $progname:2405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_shl_load=yes"
 else
@@ -2330,7 +2420,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
-echo "$progname:2333: checking for shl_load in -ldld" >&5
+echo "$progname:2423: checking for shl_load in -ldld" >&5
 ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2338,11 +2428,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldld  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2341 "ltconfig"
+#line 2431 "ltconfig"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
     builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
 char shl_load();
 
 int main() {
@@ -2349,7 +2442,7 @@
 shl_load()
 ; return 0; }
 EOF
-if { (eval echo $progname:2352: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo $progname:2445: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2392,17 +2485,17 @@
 for ac_hdr in dlfcn.h; do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "$progname:2395: checking for $ac_hdr" >&5
+echo "$progname:2488: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2400 "ltconfig"
+#line 2493 "ltconfig"
 #include <$ac_hdr>
 int fnord = 0;
 EOF
-ac_try="$ac_compile conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo $progname:2405: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_try="$ac_compile >/dev/null 2>conftest.out"
+{ (eval echo $progname:2498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2430,7 +2523,7 @@
     LIBS="$lt_cv_dlopen_libs $LIBS"
 
   echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6
-echo "$progname:2433: checking whether a program can dlopen itself" >&5
+echo "$progname:2526: checking whether a program can dlopen itself" >&5
 if test "${lt_cv_dlopen_self+set}" = set; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2438,7 +2531,7 @@
     lt_cv_dlopen_self=cross
   else
     cat > conftest.c <<EOF
-#line 2441 "ltconfig"
+#line 2534 "ltconfig"
 
 #if HAVE_DLFCN_H
 #include <dlfcn.h>
@@ -2484,7 +2577,7 @@
 	       if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } 
 
 EOF
-if { (eval echo $progname:2487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo $progname:2580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   lt_cv_dlopen_self=yes
 else
@@ -2503,7 +2596,7 @@
   if test "$lt_cv_dlopen_self" = yes; then
     LDFLAGS="$LDFLAGS $link_static_flag"
   echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6
-echo "$progname:2506: checking whether a statically linked program can dlopen itself" >&5
+echo "$progname:2599: checking whether a statically linked program can dlopen itself" >&5
 if test "${lt_cv_dlopen_self_static+set}" = set; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2511,7 +2604,7 @@
     lt_cv_dlopen_self_static=cross
   else
     cat > conftest.c <<EOF
-#line 2514 "ltconfig"
+#line 2607 "ltconfig"
 
 #if HAVE_DLFCN_H
 #include <dlfcn.h>
@@ -2557,7 +2650,7 @@
     if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } 
 
 EOF
-if { (eval echo $progname:2560: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo $progname:2653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   lt_cv_dlopen_self_static=yes
 else
@@ -2649,7 +2742,7 @@
 # NOTE: Changes made to this file will be lost: look at ltconfig or ltmain.sh.
 #
 # Copyright (C) 1996-1999 Free Software Foundation, Inc.
-# Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -2675,7 +2768,7 @@
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
-if test "\${CDPATH+set}" = set; then CDPATH=; export CDPATH; fi
+if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
 
 ### BEGIN LIBTOOL CONFIG
 EOF
@@ -2938,7 +3031,7 @@
 # AIX sometimes has problems with the GCC collect2 program.  For some
 # reason, if we set the COLLECT_NAMES environment variable, the problems
 # vanish in a puff of smoke.
-if test "${COLLECT_NAMES+set}" != set; then
+if test "X${COLLECT_NAMES+set}" != Xset; then
   COLLECT_NAMES=
   export COLLECT_NAMES
 fi
@@ -2948,6 +3041,10 @@
 
   # Append the ltmain.sh script.
   sed '$q' "$ltmain" >> "$ofile" || (rm -f "$ofile"; exit 1)
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
 
   chmod +x "$ofile"
   ;;
--- a/common/libsndfile/ltmain.sh
+++ b/common/libsndfile/ltmain.sh
@@ -54,8 +54,8 @@
 # Constants.
 PROGRAM=ltmain.sh
 PACKAGE=libtool
-VERSION=1.3.3
-TIMESTAMP=" (1.385.2.181 1999/07/02 15:49:11)"
+VERSION=1.3.5
+TIMESTAMP=" (1.385.2.206 2000/05/27 11:12:27)"
 
 default_mode=
 help="Try \`$progname --help' for more information."
@@ -435,7 +435,7 @@
       fbsd_hideous_sh_bug=$base_compile
 
       # All platforms use -DPIC, to notify preprocessed assembler code.
-      command="$base_compile $pic_flag -DPIC $srcfile"
+      command="$base_compile $srcfile $pic_flag -DPIC"
       if test "$build_old_libs" = yes; then
 	lo_libobj="$libobj"
 	dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
@@ -521,9 +521,17 @@
 	  exit $error
 	fi
 
+	xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
+	if test "X$xdir" = "X$obj"; then
+	  xdir="."
+	else
+	  xdir="$xdir"
+	fi
+	baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"`
+	libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"`
 	# Now arrange that obj and lo_libobj become the same file
-	$show "$LN_S $obj $lo_libobj"
-	if $run $LN_S $obj $lo_libobj; then
+	$show "(cd $xdir && $LN_S $baseobj $libobj)"
+	if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then
 	  exit 0
 	else
 	  error=$?
@@ -613,8 +621,6 @@
   # libtool link mode
   link)
     modename="$modename: link"
-    C_compiler="$CC" # save it, to compile generated C sources
-    CC="$nonopt"
     case "$host" in
     *-*-cygwin* | *-*-mingw* | *-*-os2*)
       # It is impossible to link a dll without this setting, and
@@ -802,8 +808,8 @@
       allow_undefined=yes
       ;;
     esac
-    compile_command="$CC"
-    finalize_command="$CC"
+    compile_command="$nonopt"
+    finalize_command="$nonopt"
 
     compile_rpath=
     finalize_rpath=
@@ -1789,6 +1795,10 @@
 	*-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*)
 	  # these systems don't actually have a c library (as such)!
 	  ;;
+        *-*-rhapsody*)
+	  # rhapsody is a little odd...
+	  deplibs="$deplibs -framework System"
+	  ;;
 	*)
 	  # Add libc to deplibs on all other systems.
 	  deplibs="$deplibs -lc"
@@ -1851,7 +1861,7 @@
 	  int main() { return 0; }
 EOF
 	  $rm conftest
-	  $C_compiler -o conftest conftest.c $deplibs
+	  $CC -o conftest conftest.c $deplibs
 	  if test $? -eq 0 ; then
 	    ldd_output=`ldd conftest`
 	    for i in $deplibs; do
@@ -1884,7 +1894,7 @@
 	     # If $name is empty we are operating on a -L argument.
 	      if test "$name" != "" ; then
 		$rm conftest
-		$C_compiler -o conftest conftest.c $i
+		$CC -o conftest conftest.c $i
 		# Did it work?
 		if test $? -eq 0 ; then
 		  ldd_output=`ldd conftest`
@@ -2047,13 +2057,20 @@
 	done
 
 	# Ensure that we have .o objects for linkers which dislike .lo
-	# (e.g. aix) incase we are running --disable-static
+	# (e.g. aix) in case we are running --disable-static
 	for obj in $libobjs; do
-	  oldobj=`$echo "X$obj" | $Xsed -e "$lo2o"`
-	  if test ! -f $oldobj; then
-	    $show "${LN_S} $obj $oldobj"
-	    $run ${LN_S} $obj $oldobj || exit $?
+	  xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
+	  if test "X$xdir" = "X$obj"; then
+	    xdir="."
+	  else
+	    xdir="$xdir"
 	  fi
+	  baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+	  oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"`
+	  if test ! -f $xdir/$oldobj; then
+	    $show "(cd $xdir && ${LN_S} $baseobj $oldobj)"
+	    $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $?
+	  fi
 	done
 
 	# Use standard objects if they are pic
@@ -2311,8 +2328,16 @@
 	# Just create a symlink.
 	$show $rm $libobj
 	$run $rm $libobj
-	$show "$LN_S $obj $libobj"
-	$run $LN_S $obj $libobj || exit $?
+	xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
+	if test "X$xdir" = "X$libobj"; then
+	  xdir="."
+	else
+	  xdir="$xdir"
+	fi
+	baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
+	oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"`
+	$show "(cd $xdir && $LN_S $oldobj $baseobj)"
+	$run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $?
       fi
 
       if test -n "$gentop"; then
@@ -2598,16 +2623,21 @@
 	  # linked before any other PIC object.  But we must not use
 	  # pic_flag when linking with -static.  The problem exists in
 	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
-	  *-*-freebsd2*|*-*-freebsd3.0*)
+	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
 	    case "$compile_command " in
 	    *" -static "*) ;;
 	    *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";;
+	    esac;;
+	  *-*-hpux*)
+	    case "$compile_command " in
+	    *" -static "*) ;;
+	    *) pic_flag_for_symtable=" $pic_flag -DPIC";;
 	    esac
 	  esac
 
 	  # Now compile the dynamic symbol file.
-	  $show "(cd $output_objdir && $C_compiler -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
-	  $run eval '(cd $output_objdir && $C_compiler -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
+	  $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+	  $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
 
 	  # Clean up the generated files.
 	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
@@ -2776,7 +2806,7 @@
 
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
-if test \"\${CDPATH+set}\" = set; then CDPATH=; export CDPATH; fi
+if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi
 
 relink_command=\"$relink_command\"
 
@@ -2865,7 +2895,7 @@
   fi"
 	else
 	  echo >> $output "\
-  program='$outputname$exeext'
+  program='$outputname'
   progdir=\"\$thisdir/$objdir\"
 "
 	fi
@@ -2901,13 +2931,21 @@
       # Run the actual program with our arguments.
 "
 	case $host in
-	*-*-cygwin* | *-*-mingw | *-*-os2*)
 	  # win32 systems need to use the prog path for dll
 	  # lookup to work
+	*-*-cygwin*)
 	  $echo >> $output "\
+      exec \$progdir/\$program \${1+\"\$@\"}
+"
+	  ;;
+
+	# Backslashes separate directories on plain windows
+	*-*-mingw | *-*-os2*)
+	  $echo >> $output "\
       exec \$progdir\\\\\$program \${1+\"\$@\"}
 "
 	  ;;
+
 	*)
 	  $echo >> $output "\
       # Export the path to the program.
@@ -2995,14 +3033,21 @@
       if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
 	eval cmds=\"$old_archive_from_new_cmds\"
       else
-	# Ensure that we have .o objects in place incase we decided
+	# Ensure that we have .o objects in place in case we decided
 	# not to build a shared library, and have fallen back to building
 	# static libs even though --disable-static was passed!
 	for oldobj in $oldobjs; do
 	  if test ! -f $oldobj; then
-	    obj=`$echo "X$oldobj" | $Xsed -e "$o2lo"`
-	    $show "${LN_S} $obj $oldobj"
-	    $run ${LN_S} $obj $oldobj || exit $?
+	    xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'`
+	    if test "X$xdir" = "X$oldobj"; then
+	      xdir="."
+	    else
+	      xdir="$xdir"
+	    fi
+	    baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'`
+	    obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"`
+	    $show "(cd $xdir && ${LN_S} $obj $baseobj)"
+	    $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $?
 	  fi
 	done
 
@@ -3672,8 +3717,10 @@
     done
 
     if test -z "$run"; then
-      # Export the shlibpath_var.
-      eval "export $shlibpath_var"
+      if test -n "$shlibpath_var"; then
+        # Export the shlibpath_var.
+        eval "export $shlibpath_var"
+      fi
 
       # Restore saved enviroment variables
       if test "${save_LC_ALL+set}" = set; then
@@ -3690,8 +3737,10 @@
       exit 1
     else
       # Display what would be done.
-      eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
-      $echo "export $shlibpath_var"
+      if test -n "$shlibpath_var"; then
+        eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
+        $echo "export $shlibpath_var"
+      fi
       $echo "$cmd$args"
       exit 0
     fi
--- a/common/libsndfile/m4/Makefile.am
+++ /dev/null
@@ -1,1 +1,0 @@
-
--- a/common/libsndfile/m4/Makefile.in
+++ /dev/null
@@ -1,182 +1,0 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
-
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-
-SHELL = @SHELL@
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-
-top_builddir = ..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_alias = @build_alias@
-build_triplet = @build@
-host_alias = @host_alias@
-host_triplet = @host@
-target_alias = @target_alias@
-target_triplet = @target@
-AS = @AS@
-CC = @CC@
-DLLTOOL = @DLLTOOL@
-LD = @LD@
-LIBTOOL = @LIBTOOL@
-LN_S = @LN_S@
-MAKEINFO = @MAKEINFO@
-NM = @NM@
-OBJDUMP = @OBJDUMP@
-PACKAGE = @PACKAGE@
-RANLIB = @RANLIB@
-SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
-VERSION = @VERSION@
-subdirs = @subdirs@
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../src/config.h
-CONFIG_CLEAN_FILES = 
-DIST_COMMON =  Makefile.am Makefile.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = gtar
-GZIP_ENV = --best
-all: all-redirect
-.SUFFIXES:
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps m4/Makefile
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-tags: TAGS
-TAGS:
-
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = m4
-
-distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
-	  if test -d $$d/$$file; then \
-	    cp -pr $$/$$file $(distdir)/$$file; \
-	  else \
-	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
-	  fi; \
-	done
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
-check-am: all-am
-check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am:
-install-exec: install-exec-am
-
-install-data-am:
-install-data: install-data-am
-
-install-am: all-am
-	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am:
-uninstall: uninstall-am
-all-am: Makefile
-all-redirect: all-am
-install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-
-
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
-	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
-
-maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am:  clean-generic mostlyclean-am
-
-clean: clean-am
-
-distclean-am:  distclean-generic clean-am
-	-rm -f libtool
-
-distclean: distclean-am
-
-maintainer-clean-am:  maintainer-clean-generic distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
-
-maintainer-clean: maintainer-clean-am
-
-.PHONY: tags distdir info-am info dvi-am dvi check check-am \
-installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
-
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
--- a/common/libsndfile/mkinstalldirs
+++ b/common/libsndfile/mkinstalldirs
@@ -4,7 +4,7 @@
 # Created: 1993-05-16
 # Public domain
 
-# $Id: mkinstalldirs,v 1.1 2001/05/09 19:44:12 menno Exp $
+# $Id: mkinstalldirs,v 1.2 2002/02/13 12:42:00 menno Exp $
 
 errstatus=0
 
--- a/common/libsndfile/src/G72x/ChangeLog
+++ b/common/libsndfile/src/G72x/ChangeLog
@@ -1,3 +1,8 @@
+2001-06-05  Erik de Castro Lopo  <erikd@zip.com.au>
+
+	* g72x.c
+	Added {} in function update () to prevent 'ambiguous else' warning messages.
+
 2000-07-14  Erik de Castro Lopo  <erikd@zip.com.au>
 
 	* g72x.c
--- a/common/libsndfile/src/G72x/Makefile.in
+++ b/common/libsndfile/src/G72x/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
 
 # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
@@ -68,11 +68,9 @@
 AS = @AS@
 CC = @CC@
 DLLTOOL = @DLLTOOL@
-LD = @LD@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
 MAKEINFO = @MAKEINFO@
-NM = @NM@
 OBJDUMP = @OBJDUMP@
 PACKAGE = @PACKAGE@
 RANLIB = @RANLIB@
@@ -116,7 +114,7 @@
 
 DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
-TAR = gtar
+TAR = tar
 GZIP_ENV = --best
 SOURCES = $(libg72x_la_SOURCES)
 OBJECTS = $(libg72x_la_OBJECTS)
@@ -219,7 +217,7 @@
 	@for file in $(DISTFILES); do \
 	  d=$(srcdir); \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$/$$file $(distdir)/$$file; \
+	    cp -pr $$d/$$file $(distdir)/$$file; \
 	  else \
 	    test -f $(distdir)/$$file \
 	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
--- a/common/libsndfile/src/G72x/g72x.c
+++ b/common/libsndfile/src/G72x/g72x.c
@@ -31,6 +31,8 @@
  */
  
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #include "g72x.h"
 #include "private.h"
@@ -509,7 +511,7 @@
 				a2p += fa1 >> 5;
 
 			if (pk0 ^ state_ptr->pk[1])
-				/* LIMC */
+			{	/* LIMC */
 				if (a2p <= -12160)
 					a2p = -12288;
 				else if (a2p >= 12416)
@@ -516,6 +518,7 @@
 					a2p = 12288;
 				else
 					a2p -= 0x80;
+				}
 			else if (a2p <= -12416)
 				a2p = -12288;
 			else if (a2p >= 12160)
--- a/common/libsndfile/src/G72x/g72x.h
+++ b/common/libsndfile/src/G72x/g72x.h
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
--- a/common/libsndfile/src/GSM610/ChangeLog
+++ b/common/libsndfile/src/GSM610/ChangeLog
@@ -1,9 +1,20 @@
-2000-02-29  Erik de Castro Lopo  <erikd@zip.com.au>
+2001-09-16  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
+    * code.c
+    Added #includes fro string.h and stdlib.h.
+
+2000-10-27  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
+    * config.h
+    Removed some commented out #defines (ie //*efine) which were causing problems on
+	the Sun cc compiler.
+
+2000-02-29  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
+
     * private.h
     Added #defines to emulate normal compile time options.
 
-2000-02-28  Erik de Castro Lopo  <erikd@zip.com.au>
+2000-02-28  Erik de Castro Lopo  <erikd AT zip DOT com DOT au>
 
     * everthing
     Created this directory and copied files from libgsm.
--- a/common/libsndfile/src/GSM610/Makefile.in
+++ b/common/libsndfile/src/GSM610/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
 
 # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
@@ -68,11 +68,9 @@
 AS = @AS@
 CC = @CC@
 DLLTOOL = @DLLTOOL@
-LD = @LD@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
 MAKEINFO = @MAKEINFO@
-NM = @NM@
 OBJDUMP = @OBJDUMP@
 PACKAGE = @PACKAGE@
 RANLIB = @RANLIB@
@@ -119,7 +117,7 @@
 
 DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
-TAR = gtar
+TAR = tar
 GZIP_ENV = --best
 SOURCES = $(libgsm_la_SOURCES)
 OBJECTS = $(libgsm_la_OBJECTS)
@@ -222,7 +220,7 @@
 	@for file in $(DISTFILES); do \
 	  d=$(srcdir); \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$/$$file $(distdir)/$$file; \
+	    cp -pr $$d/$$file $(distdir)/$$file; \
 	  else \
 	    test -f $(distdir)/$$file \
 	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
--- a/common/libsndfile/src/GSM610/add.c
+++ b/common/libsndfile/src/GSM610/add.c
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/add.c,v 1.1 2001/05/09 19:44:12 menno Exp $ */
+/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/add.c,v 1.2 2002/02/13 12:42:02 menno Exp $ */
 
 /*
  *  See private.h for the more commonly used macro versions.
--- a/common/libsndfile/src/GSM610/code.c
+++ b/common/libsndfile/src/GSM610/code.c
@@ -4,17 +4,15 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/code.c,v 1.1 2001/05/09 19:44:12 menno Exp $ */
+/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/code.c,v 1.2 2002/02/13 12:42:02 menno Exp $ */
 
-#include	"config.h"
 
 
-#ifdef	HAS_STDLIB_H
+
 #include	<stdlib.h>
-#else
-#	include "proto.h"
-	extern char	* memcpy P((char *, char *, int));
-#endif
+#include	<string.h>
+
+#include	"config.h"
 
 #include	"private.h"
 #include	"gsm.h"
--- a/common/libsndfile/src/GSM610/config.h
+++ b/common/libsndfile/src/GSM610/config.h
@@ -4,18 +4,13 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/*$Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/config.h,v 1.1 2001/05/09 19:44:12 menno Exp $*/
+/*$Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/config.h,v 1.2 2002/02/13 12:42:02 menno Exp $*/
 
 #ifndef	CONFIG_H
 #define	CONFIG_H
 
-//*efine	SIGHANDLER_T	int 		/* signal handlers are void	*/
-//*efine HAS_SYSV_SIGNAL	1		/* sigs not blocked/reset?	*/
-
 #define	HAS_STDLIB_H	1		/* /usr/include/stdlib.h	*/
-//*efine	HAS_LIMITS_H	1		/* /usr/include/limits.h	*/
 #define	HAS_FCNTL_H	1		/* /usr/include/fcntl.h		*/
-//*efine	HAS_ERRNO_DECL	1		/* errno.h declares errno	*/
 
 #define	HAS_FSTAT 	1		/* fstat syscall		*/
 #define	HAS_FCHMOD 	1		/* fchmod syscall		*/
@@ -22,16 +17,11 @@
 #define	HAS_CHMOD 	1		/* chmod syscall		*/
 #define	HAS_FCHOWN 	1		/* fchown syscall		*/
 #define	HAS_CHOWN 	1		/* chown syscall		*/
-//*efine	HAS__FSETMODE 	1		/* _fsetmode -- set file mode	*/
 
 #define	HAS_STRING_H 	1		/* /usr/include/string.h 	*/
-//*efine	HAS_STRINGS_H	1		/* /usr/include/strings.h 	*/
 
 #define	HAS_UNISTD_H	1		/* /usr/include/unistd.h	*/
 #define	HAS_UTIME	1		/* POSIX utime(path, times)	*/
-//*efine	HAS_UTIMES	1		/* use utimes()	syscall instead	*/
 #define	HAS_UTIME_H	1		/* UTIME header file		*/
-//*efine	HAS_UTIMBUF	1		/* struct utimbuf		*/
-//*efine	HAS_UTIMEUSEC   1		/* microseconds in utimbuf?	*/
 
 #endif	/* CONFIG_H */
--- a/common/libsndfile/src/GSM610/decode.c
+++ b/common/libsndfile/src/GSM610/decode.c
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/decode.c,v 1.1 2001/05/09 19:44:12 menno Exp $ */
+/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/decode.c,v 1.2 2002/02/13 12:42:02 menno Exp $ */
 
 #include <stdio.h>
 
--- a/common/libsndfile/src/GSM610/gsm.h
+++ b/common/libsndfile/src/GSM610/gsm.h
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/*$Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/gsm.h,v 1.1 2001/05/09 19:44:12 menno Exp $*/
+/*$Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/gsm.h,v 1.2 2002/02/13 12:42:02 menno Exp $*/
 
 #ifndef	GSM_H
 #define	GSM_H
--- a/common/libsndfile/src/GSM610/gsm_create.c
+++ b/common/libsndfile/src/GSM610/gsm_create.c
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-static char const	ident[] = "$Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/gsm_create.c,v 1.1 2001/05/09 19:44:12 menno Exp $";
+static char const	ident[] = "$Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/gsm_create.c,v 1.2 2002/02/13 12:42:02 menno Exp $";
 
 #include	"config.h"
 
--- a/common/libsndfile/src/GSM610/gsm_decode.c
+++ b/common/libsndfile/src/GSM610/gsm_decode.c
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/gsm_decode.c,v 1.1 2001/05/09 19:44:12 menno Exp $ */
+/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/gsm_decode.c,v 1.2 2002/02/13 12:42:02 menno Exp $ */
 
 #include "private.h"
 
--- a/common/libsndfile/src/GSM610/gsm_destroy.c
+++ b/common/libsndfile/src/GSM610/gsm_destroy.c
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/gsm_destroy.c,v 1.1 2001/05/09 19:44:12 menno Exp $ */
+/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/gsm_destroy.c,v 1.2 2002/02/13 12:42:02 menno Exp $ */
 
 #include "gsm.h"
 #include "config.h"
--- a/common/libsndfile/src/GSM610/gsm_encode.c
+++ b/common/libsndfile/src/GSM610/gsm_encode.c
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/gsm_encode.c,v 1.1 2001/05/09 19:44:12 menno Exp $ */
+/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/gsm_encode.c,v 1.2 2002/02/13 12:42:02 menno Exp $ */
 
 #include "private.h"
 #include "gsm.h"
--- a/common/libsndfile/src/GSM610/gsm_option.c
+++ b/common/libsndfile/src/GSM610/gsm_option.c
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/gsm_option.c,v 1.1 2001/05/09 19:44:12 menno Exp $ */
+/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/gsm_option.c,v 1.2 2002/02/13 12:42:02 menno Exp $ */
 
 #include "private.h"
 
--- a/common/libsndfile/src/GSM610/long_term.c
+++ b/common/libsndfile/src/GSM610/long_term.c
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/long_term.c,v 1.1 2001/05/09 19:44:12 menno Exp $ */
+/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/long_term.c,v 1.2 2002/02/13 12:42:02 menno Exp $ */
 
 #include <stdio.h>
 #include <assert.h>
--- a/common/libsndfile/src/GSM610/lpc.c
+++ b/common/libsndfile/src/GSM610/lpc.c
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/lpc.c,v 1.1 2001/05/09 19:44:12 menno Exp $ */
+/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/lpc.c,v 1.2 2002/02/13 12:42:02 menno Exp $ */
 
 #include <stdio.h>
 #include <assert.h>
--- a/common/libsndfile/src/GSM610/preprocess.c
+++ b/common/libsndfile/src/GSM610/preprocess.c
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/preprocess.c,v 1.1 2001/05/09 19:44:12 menno Exp $ */
+/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/preprocess.c,v 1.2 2002/02/13 12:42:02 menno Exp $ */
 
 #include	<stdio.h>
 #include	<assert.h>
--- a/common/libsndfile/src/GSM610/private.h
+++ b/common/libsndfile/src/GSM610/private.h
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/*$Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/private.h,v 1.1 2001/05/09 19:44:12 menno Exp $*/
+/*$Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/private.h,v 1.2 2002/02/13 12:42:02 menno Exp $*/
 
 #ifndef	PRIVATE_H
 #define	PRIVATE_H
--- a/common/libsndfile/src/GSM610/proto.h
+++ b/common/libsndfile/src/GSM610/proto.h
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/*$Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/proto.h,v 1.1 2001/05/09 19:44:12 menno Exp $*/
+/*$Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/proto.h,v 1.2 2002/02/13 12:42:02 menno Exp $*/
 
 #ifndef	PROTO_H
 #define	PROTO_H
--- a/common/libsndfile/src/GSM610/rpe.c
+++ b/common/libsndfile/src/GSM610/rpe.c
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/rpe.c,v 1.1 2001/05/09 19:44:12 menno Exp $ */
+/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/rpe.c,v 1.2 2002/02/13 12:42:02 menno Exp $ */
 
 #include <stdio.h>
 #include <assert.h>
--- a/common/libsndfile/src/GSM610/short_term.c
+++ b/common/libsndfile/src/GSM610/short_term.c
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/short_term.c,v 1.1 2001/05/09 19:44:12 menno Exp $ */
+/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/short_term.c,v 1.2 2002/02/13 12:42:02 menno Exp $ */
 
 #include <stdio.h>
 #include <assert.h>
--- a/common/libsndfile/src/GSM610/table.c
+++ b/common/libsndfile/src/GSM610/table.c
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/table.c,v 1.1 2001/05/09 19:44:12 menno Exp $ */
+/* $Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/table.c,v 1.2 2002/02/13 12:42:02 menno Exp $ */
 
 /*  Most of these tables are inlined at their point of use.
  */
--- a/common/libsndfile/src/GSM610/unproto.h
+++ b/common/libsndfile/src/GSM610/unproto.h
@@ -4,7 +4,7 @@
  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  */
 
-/*$Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/unproto.h,v 1.1 2001/05/09 19:44:12 menno Exp $*/
+/*$Header: /home/cvs/f/fa/faac/faac/common/libsndfile/src/GSM610/Attic/unproto.h,v 1.2 2002/02/13 12:42:02 menno Exp $*/
 
 #ifdef	PROTO_H		/* sic */
 #undef	PROTO_H
--- a/common/libsndfile/src/Makefile.am
+++ b/common/libsndfile/src/Makefile.am
@@ -8,13 +8,14 @@
 include_HEADERS = sndfile.h
 INCLUDES = -I$(srcdir)/../src -I$(srcdir)
 
-noinst_HEADERS = common.h sfendian.h pcm.h ulaw.h alaw.h wav.h au.h
+noinst_HEADERS = common.h sfendian.h floatcast.h wav.h au.h
 
-COMMON = common.c newpcm.c pcm.c ulaw.c alaw.c sndfile.c
-FILESPECIFIC = aiff.c au.c au_g72x.c paf.c raw.c svx.c wav.c wav_float.c \
-				wav_gsm610.c wav_ima_adpcm.c wav_ms_adpcm.c
+COMMON = common.c pcm.c ulaw.c alaw.c float32.c sndfile.c  
+FILESPECIFIC = aiff.c au.c au_g72x.c nist.c paf.c raw.c samplitude.c \
+				svx.c wav.c wav_gsm610.c wav_ima_adpcm.c \
+				wav_ms_adpcm.c voc.c ircam.c
 
-libsndfile_la_SOURCES = $(FILESPECIFIC) $(COMMON) sndfile.h common.h
+libsndfile_la_SOURCES = $(COMMON) $(FILESPECIFIC) sndfile.h
 libsndfile_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@
 libsndfile_la_LIBADD  = GSM610/libgsm.la G72x/libg72x.la
 
--- a/common/libsndfile/src/Makefile.in
+++ b/common/libsndfile/src/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
 
 # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
@@ -69,11 +69,9 @@
 AS = @AS@
 CC = @CC@
 DLLTOOL = @DLLTOOL@
-LD = @LD@
 LIBTOOL = @LIBTOOL@
 LN_S = @LN_S@
 MAKEINFO = @MAKEINFO@
-NM = @NM@
 OBJDUMP = @OBJDUMP@
 PACKAGE = @PACKAGE@
 RANLIB = @RANLIB@
@@ -88,13 +86,13 @@
 include_HEADERS = sndfile.h
 INCLUDES = -I$(srcdir)/../src -I$(srcdir)
 
-noinst_HEADERS = common.h sfendian.h pcm.h ulaw.h alaw.h wav.h au.h
+noinst_HEADERS = common.h sfendian.h floatcast.h wav.h au.h
 
-COMMON = common.c newpcm.c pcm.c ulaw.c alaw.c sndfile.c
-FILESPECIFIC = aiff.c au.c au_g72x.c paf.c raw.c svx.c wav.c wav_float.c 				wav_gsm610.c wav_ima_adpcm.c wav_ms_adpcm.c
+COMMON = common.c pcm.c ulaw.c alaw.c float32.c sndfile.c  
+FILESPECIFIC = aiff.c au.c au_g72x.c nist.c paf.c raw.c samplitude.c 				svx.c wav.c wav_gsm610.c wav_ima_adpcm.c 				wav_ms_adpcm.c voc.c ircam.c
 
 
-libsndfile_la_SOURCES = $(FILESPECIFIC) $(COMMON) sndfile.h common.h
+libsndfile_la_SOURCES = $(COMMON) $(FILESPECIFIC) sndfile.h
 libsndfile_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@
 libsndfile_la_LIBADD = GSM610/libgsm.la G72x/libg72x.la
 
@@ -111,9 +109,10 @@
 LDFLAGS = @LDFLAGS@
 LIBS = @LIBS@
 libsndfile_la_DEPENDENCIES =  GSM610/libgsm.la G72x/libg72x.la
-libsndfile_la_OBJECTS =  aiff.lo au.lo au_g72x.lo paf.lo raw.lo svx.lo \
-wav.lo wav_float.lo wav_gsm610.lo wav_ima_adpcm.lo wav_ms_adpcm.lo \
-common.lo newpcm.lo pcm.lo ulaw.lo alaw.lo sndfile.lo
+libsndfile_la_OBJECTS =  common.lo pcm.lo ulaw.lo alaw.lo float32.lo \
+sndfile.lo aiff.lo au.lo au_g72x.lo nist.lo paf.lo raw.lo samplitude.lo \
+svx.lo wav.lo wav_gsm610.lo wav_ima_adpcm.lo wav_ms_adpcm.lo voc.lo \
+ircam.lo
 CFLAGS = @CFLAGS@
 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -126,7 +125,7 @@
 
 DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
-TAR = gtar
+TAR = tar
 GZIP_ENV = --best
 SOURCES = $(libsndfile_la_SOURCES)
 OBJECTS = $(libsndfile_la_OBJECTS)
@@ -348,7 +347,7 @@
 	@for file in $(DISTFILES); do \
 	  d=$(srcdir); \
 	  if test -d $$d/$$file; then \
-	    cp -pr $$/$$file $(distdir)/$$file; \
+	    cp -pr $$d/$$file $(distdir)/$$file; \
 	  else \
 	    test -f $(distdir)/$$file \
 	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
@@ -365,35 +364,31 @@
 	      || exit 1; \
 	  fi; \
 	done
-aiff.lo aiff.o : aiff.c sndfile.h config.h sfendian.h common.h pcm.h
-alaw.lo alaw.o : alaw.c sndfile.h common.h
-au.lo au.o : au.c sndfile.h config.h sfendian.h common.h pcm.h au.h \
-	ulaw.h alaw.h
-au_g721.lo au_g721.o : au_g721.c sndfile.h config.h sfendian.h common.h \
-	au.h G72x/g72x.h
-au_g721_32.lo au_g721_32.o : au_g721_32.c sndfile.h config.h sfendian.h \
-	common.h au.h G72x/g72x.h
-au_g72x.lo au_g72x.o : au_g72x.c sndfile.h config.h sfendian.h common.h \
-	au.h G72x/g72x.h
+aiff.lo aiff.o : aiff.c sndfile.h config.h sfendian.h common.h
+alaw.lo alaw.o : alaw.c sndfile.h floatcast.h common.h
+au.lo au.o : au.c sndfile.h config.h sfendian.h common.h au.h
+au_g72x.lo au_g72x.o : au_g72x.c config.h sndfile.h sfendian.h \
+	floatcast.h common.h au.h G72x/g72x.h
 common.lo common.o : common.c sndfile.h sfendian.h config.h common.h
-newpcm.lo newpcm.o : newpcm.c config.h sndfile.h common.h sfendian.h \
-	pcm.h
-paf.lo paf.o : paf.c sndfile.h config.h sfendian.h common.h pcm.h
-pcm.lo pcm.o : pcm.c config.h sndfile.h common.h sfendian.h pcm.h
-raw.lo raw.o : raw.c sndfile.h config.h sfendian.h common.h pcm.h
+float32.lo float32.o : float32.c sndfile.h config.h sfendian.h common.h
+ircam.lo ircam.o : ircam.c sndfile.h config.h sfendian.h common.h
+nist.lo nist.o : nist.c sndfile.h config.h sfendian.h common.h
+paf.lo paf.o : paf.c config.h sndfile.h sfendian.h floatcast.h common.h
+pcm.lo pcm.o : pcm.c config.h sndfile.h sfendian.h floatcast.h common.h
+raw.lo raw.o : raw.c sndfile.h config.h sfendian.h common.h
+samplitude.lo samplitude.o : samplitude.c sndfile.h config.h sfendian.h \
+	common.h
 sndfile.lo sndfile.o : sndfile.c sndfile.h config.h sfendian.h common.h
-svx.lo svx.o : svx.c sndfile.h config.h sfendian.h common.h pcm.h
-ulaw.lo ulaw.o : ulaw.c sndfile.h common.h
-wav.lo wav.o : wav.c sndfile.h config.h sfendian.h common.h pcm.h ulaw.h \
-	alaw.h wav.h
-wav_float.lo wav_float.o : wav_float.c sndfile.h config.h sfendian.h \
-	common.h wav.h
+svx.lo svx.o : svx.c sndfile.h config.h sfendian.h common.h
+ulaw.lo ulaw.o : ulaw.c sndfile.h floatcast.h common.h
+voc.lo voc.o : voc.c sndfile.h config.h sfendian.h common.h
+wav.lo wav.o : wav.c sndfile.h config.h sfendian.h common.h wav.h
 wav_gsm610.lo wav_gsm610.o : wav_gsm610.c sndfile.h config.h sfendian.h \
-	common.h wav.h GSM610/gsm.h
+	floatcast.h common.h wav.h GSM610/gsm.h
 wav_ima_adpcm.lo wav_ima_adpcm.o : wav_ima_adpcm.c sndfile.h config.h \
-	sfendian.h common.h wav.h
+	sfendian.h floatcast.h common.h wav.h
 wav_ms_adpcm.lo wav_ms_adpcm.o : wav_ms_adpcm.c sndfile.h config.h \
-	sfendian.h common.h wav.h
+	sfendian.h floatcast.h common.h wav.h
 
 info-am:
 info: info-recursive
--- a/common/libsndfile/src/aiff.c
+++ b/common/libsndfile/src/aiff.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -21,12 +21,12 @@
 #include	<unistd.h>
 #include	<string.h>
 #include	<ctype.h>
+#include	<time.h>
 
 #include	"sndfile.h"
 #include	"config.h"
 #include	"sfendian.h"
 #include	"common.h"
-#include	"pcm.h"
 
 
 /*------------------------------------------------------------------------------
@@ -54,21 +54,55 @@
 #define NAME_MARKER	(MAKE_MARKER ('N', 'A', 'M', 'E')) 
 #define AUTH_MARKER	(MAKE_MARKER ('A', 'U', 'T', 'H')) 
 #define ANNO_MARKER	(MAKE_MARKER ('A', 'N', 'N', 'O')) 
+#define COMT_MARKER	(MAKE_MARKER ('C', 'O', 'M', 'T')) 
 #define FVER_MARKER	(MAKE_MARKER ('F', 'V', 'E', 'R')) 
+#define SFX_MARKER	(MAKE_MARKER ('S', 'F', 'X', '!')) 
 
+
+#define PEAK_MARKER	(MAKE_MARKER ('P', 'E', 'A', 'K')) 
+
+/* Supported AIFC encodings.*/
 #define NONE_MARKER	(MAKE_MARKER ('N', 'O', 'N', 'E')) 
+#define sowt_MARKER	(MAKE_MARKER ('s', 'o', 'w', 't')) 
+#define twos_MARKER	(MAKE_MARKER ('t', 'w', 'o', 's')) 
+#define fl32_MARKER	(MAKE_MARKER ('f', 'l', '3', '2')) 
+#define FL32_MARKER	(MAKE_MARKER ('F', 'L', '3', '2')) 
 
-#define	REAL_COMM_SIZE			(2+4+2+10)
+/* Unsupported AIFC encodings.*/
+#define fl64_MARKER	(MAKE_MARKER ('f', 'l', '6', '4')) 
+#define FL64_MARKER	(MAKE_MARKER ('F', 'L', '6', '4')) 
+#define MAC3_MARKER	(MAKE_MARKER ('M', 'A', 'C', '3')) 
+#define MAC6_MARKER	(MAKE_MARKER ('M', 'A', 'C', '6')) 
+#define ima4_MARKER	(MAKE_MARKER ('i', 'm', 'a', '4')) 
+#define ulaw_MARKER	(MAKE_MARKER ('a', 'l', 'a', 'w')) 
+#define alaw_MARKER	(MAKE_MARKER ('u', 'l', 'a', 'w')) 
+#define ADP4_MARKER	(MAKE_MARKER ('A', 'D', 'P', '4')) 
 
+/* Predfined chunk sizes. */
+#define AIFF_COMM_SIZE		18
+#define AIFC_COMM_SIZE		24
+#define SSND_CHUNK_SIZE		8
+
 /*------------------------------------------------------------------------------
  * Typedefs for file chunks.
  */
 
+enum
+{	HAVE_FORM	= 0x01,
+	HAVE_AIFF	= 0x02,
+	HAVE_COMM	= 0x04,
+	HAVE_SSND	= 0x08
+} ;
+
 typedef struct
-{	short			numChannels ;
+{	unsigned int	type ;
+	unsigned int	size ;
+	short			numChannels ;
 	unsigned int	numSampleFrames ;
 	short			sampleSize ;
 	unsigned char	sampleRate [10] ;
+	unsigned int	encoding ;
+	char			zero_bytes [2] ;
 } COMM_CHUNK ; 
 
 typedef struct
@@ -76,7 +110,6 @@
 	unsigned int	blocksize ;
 } SSND_CHUNK ; 
 
-
 typedef struct 
 {	short           playMode;
     int		        beginLoop;
@@ -92,188 +125,228 @@
 static	int     tenbytefloat2int (unsigned char *bytes) ;
 static	void	uint2tenbytefloat (unsigned int num, unsigned char *bytes) ;
 
-static 
-void    endswap_comm_fmt (COMM_CHUNK *comm)
-{	comm->numChannels     = ENDSWAP_SHORT (comm->numChannels) ;
-	comm->numSampleFrames = ENDSWAP_INT (comm->numSampleFrames) ;
-	comm->sampleSize      = ENDSWAP_SHORT (comm->sampleSize) ;
-} /* endswap_comm_fmt */
+static  int  	aiff_read_comm_chunk (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt) ;
 
-static 
-void    endswap_ssnd_fmt (SSND_CHUNK *ssnd)
-{	ssnd->offset 	= ENDSWAP_INT (ssnd->offset) ;
-	ssnd->blocksize = ENDSWAP_INT (ssnd->blocksize) ;
-} /* endswap_ssnd_fmt */
+static int		aiff_write_header (SF_PRIVATE *psf) ;
+static int		aiff_write_tailer (SF_PRIVATE *psf) ;
 
-
 /*------------------------------------------------------------------------------
 ** Public functions.
 */
 
-int 	aiff_open_read	(SF_PRIVATE *psf)
+int
+aiff_open_read	(SF_PRIVATE *psf)
 {	COMM_CHUNK	comm_fmt ;
 	SSND_CHUNK	ssnd_fmt ;
 	int			marker, dword ;
-	long		FORMsize, commsize, SSNDsize ;
-	int			filetype, parsestage = 0, done = 0 ;
-	
+	long		FORMsize, SSNDsize ;
+	int			filetype, found_chunk = 0, done = 0, error = 0 ;
+	char		*cptr ;
+
+	psf->sf.seekable = SF_TRUE ;
+
+	/* Set position to start of file to begin reading header. */
+	psf_binheader_readf (psf, "p", 0) ;	
+
+	memset (&comm_fmt, 0, sizeof (comm_fmt)) ;
+
+	/* Until recently AIF* file were all BIG endian. */ 	
+	psf->endian = SF_ENDIAN_BIG ;
+
+	/* 	AIFF files can apparently have their chunks in any order. However, they must
+	**	a FORM chunk. Approach here is to read allthe chunks one by one and then 
+	**	check for the mandatory chunks at the end.
+	*/
 	while (! done)
-	{	fread (&marker, sizeof (marker), 1, psf->file) ;
+	{	psf_binheader_readf (psf, "m", &marker) ;
 		switch (marker)
 		{	case FORM_MARKER :
-					if (parsestage != 0)
+					if (found_chunk)
 						return SFE_AIFF_NO_FORM ;
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-					FORMsize = BE2H_INT (dword) ;
 
+					psf_binheader_readf (psf, "L", &FORMsize) ;
+
 					if (FORMsize != psf->filelength - 2 * sizeof (dword))
 					{	dword = psf->filelength - 2 * sizeof (dword);
-						psf_sprintf (psf, "FORM : %d (should be %d)\n", FORMsize, dword) ;
+						psf_log_printf (psf, "FORM : %d (should be %d)\n", FORMsize, dword) ;
 						FORMsize = dword ;
 						}
 					else
-						psf_sprintf (psf, "FORM : %d\n", FORMsize) ;
-					parsestage = 1 ;
+						psf_log_printf (psf, "FORM : %d\n", FORMsize) ;
+					found_chunk |= HAVE_FORM ;
 					break ;
 					
 			case AIFC_MARKER :
 			case AIFF_MARKER :
-					if (parsestage != 1)
-						return SFE_AIFF_NO_FORM ;
+					if (! (found_chunk & HAVE_FORM))
+						return SFE_AIFF_AIFF_NO_FORM ;
 					filetype = marker ;
-					psf_sprintf (psf, " %D\n", marker) ;
-					parsestage = 2 ;
+					psf_log_printf (psf, " %D\n", marker) ;
+					found_chunk |= HAVE_AIFF ;
 					break ;
 
 			case COMM_MARKER :
-					if (parsestage != 2)
-						return SFE_AIFF_NO_FORM ;
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-					commsize = BE2H_INT (dword) ;
-					
-					/* The COMM chunk has an int aligned to a word boundary. Some procesors 
-					** are not able to deal with this (ie bus fault) so we have to take
-					** special care.
-					*/
+					error = aiff_read_comm_chunk (psf, &comm_fmt) ;
 
-					fread (&(comm_fmt.numChannels), sizeof (comm_fmt.numChannels), 1, psf->file) ;
-					fread (&(comm_fmt.numSampleFrames), sizeof (comm_fmt.numSampleFrames), 1, psf->file) ;
-					fread (&(comm_fmt.sampleSize), sizeof (comm_fmt.sampleSize), 1, psf->file) ;
-					fread (&(comm_fmt.sampleRate), sizeof (comm_fmt.sampleRate), 1, psf->file) ;
-
-					if (CPU_IS_LITTLE_ENDIAN)
-						endswap_comm_fmt (&comm_fmt) ;
-
 					psf->sf.samplerate 		= tenbytefloat2int (comm_fmt.sampleRate) ;
 					psf->sf.samples 		= comm_fmt.numSampleFrames ;
 					psf->sf.channels 		= comm_fmt.numChannels ;
 					psf->sf.pcmbitwidth 	= comm_fmt.sampleSize ;
-					psf->sf.format 			= (SF_FORMAT_AIFF | SF_FORMAT_PCM);
 					psf->sf.sections 		= 1 ;
 					
-					psf_sprintf (psf, " COMM : %d\n", commsize) ;
-					psf_sprintf (psf, "  Sample Rate : %d\n", psf->sf.samplerate) ;
-					psf_sprintf (psf, "  Samples     : %d\n", comm_fmt.numSampleFrames) ;
-					psf_sprintf (psf, "  Channels    : %d\n", comm_fmt.numChannels) ;
-					psf_sprintf (psf, "  Sample Size : %d\n", comm_fmt.sampleSize) ;
+					if (error)
+						return error ;
+						
+					found_chunk |= HAVE_COMM ;
+					break ;
+
+			case PEAK_MARKER :
+					/* Must have COMM chunk before PEAK chunk. */
+					if ((found_chunk & (HAVE_FORM | HAVE_AIFF | HAVE_COMM)) != (HAVE_FORM | HAVE_AIFF | HAVE_COMM))
+						return SFE_AIFF_PEAK_B4_COMM ;
+
+					psf_binheader_readf (psf, "L", &dword) ;
 					
-					if (commsize > REAL_COMM_SIZE)
-					{	fread (&dword, sizeof (dword), 1, psf->file) ;
-						if (dword != NONE_MARKER)
-						{	psf_sprintf (psf, "AIFC : Unimplemented format : %D\n", dword) ;
-							return SFE_UNIMPLEMENTED ;
-							} ;
-						fseek (psf->file, commsize - (long) (sizeof (dword) + REAL_COMM_SIZE), SEEK_CUR) ;
+					psf_log_printf (psf, "%D : %d\n", marker, dword) ;
+					if (dword > sizeof (psf->peak))
+					{	psf_binheader_readf (psf, "j", dword) ;
+						psf_log_printf (psf, "*** File PEAK chunk bigger than sizeof (PEAK_CHUNK).\n") ;
+						return SFE_WAV_BAD_PEAK ;
 						} ;
+					if (dword != sizeof (psf->peak) - sizeof (psf->peak.peak) + psf->sf.channels * sizeof (PEAK_POS))
+					{	psf_binheader_readf (psf, "j", dword) ;
+						psf_log_printf (psf, "*** File PEAK chunk size doesn't fit with number of channels.\n") ;
+						return SFE_WAV_BAD_PEAK ;
+						} ;
 					
-					parsestage = 3 ;
+					/* read in rest of PEAK chunk. */	
+					psf_binheader_readf (psf, "LL", &(psf->peak.version), &(psf->peak.timestamp)) ;
+
+					if (psf->peak.version != 1)
+						psf_log_printf (psf, "  version    : %d *** (should be version 1)\n", psf->peak.version) ;
+					else
+						psf_log_printf (psf, "  version    : %d\n", psf->peak.version) ;
+						
+					psf_log_printf (psf, "  time stamp : %d\n", psf->peak.timestamp) ;
+					psf_log_printf (psf, "    Ch   Position       Value\n") ;
+
+					cptr = (char *) psf->buffer ;
+					for (dword = 0 ; dword < psf->sf.channels ; dword++)
+					{	psf_binheader_readf (psf, "FL", &(psf->peak.peak[dword].value), 
+														&(psf->peak.peak[dword].position)) ;
+					
+						snprintf (cptr, sizeof (psf->buffer), "    %2d   %-12d   %g\n", 
+								dword, psf->peak.peak[dword].position, psf->peak.peak[dword].value) ;
+						cptr [sizeof (psf->buffer) - 1] = 0 ;
+						psf_log_printf (psf, cptr) ;
+						};
+
+					psf->has_peak = SF_TRUE ;
 					break ;
 
 			case SSND_MARKER :
-					if (parsestage != 3)
-						return SFE_AIFF_NO_SSND ;
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-					SSNDsize = BE2H_INT (dword) ;
-					
-					fread (&ssnd_fmt, sizeof (SSND_CHUNK), 1, psf->file) ;
-					if (CPU_IS_LITTLE_ENDIAN)
-						endswap_ssnd_fmt (&ssnd_fmt) ;
-						
+					psf_binheader_readf (psf, "LLL", &SSNDsize, &(ssnd_fmt.offset), &(ssnd_fmt.blocksize)) ;
+											
 					psf->dataoffset = ftell (psf->file) ;
 					psf->datalength = psf->filelength - psf->dataoffset ;
-					if (SSNDsize != psf->datalength + sizeof (SSND_CHUNK))
-						psf_sprintf (psf, " SSND : %d (should be %d)\n", SSNDsize, psf->datalength + sizeof (SSND_CHUNK)) ;
+					if (SSNDsize > psf->datalength + sizeof (SSND_CHUNK))
+						psf_log_printf (psf, " SSND : %d (should be %d)\n", SSNDsize, psf->datalength + sizeof (SSND_CHUNK)) ;
 					else
-						psf_sprintf (psf, " SSND : %d\n", SSNDsize) ;
+						psf_log_printf (psf, " SSND : %d\n", SSNDsize) ;
 					
-					psf_sprintf (psf, "  Offset     : %d\n", ssnd_fmt.offset) ;
-					psf_sprintf (psf, "  Block Size : %d\n", ssnd_fmt.blocksize) ;
+					psf_log_printf (psf, "  Offset     : %d\n", ssnd_fmt.offset) ;
+					psf_log_printf (psf, "  Block Size : %d\n", ssnd_fmt.blocksize) ;
 					
+					found_chunk |= HAVE_SSND ;
 
-					fseek (psf->file, psf->datalength, SEEK_CUR) ;
-					dword = ftell (psf->file) ;
-					if (dword != (off_t) (psf->dataoffset + psf->datalength))
-						psf_sprintf (psf, "*** fseek past end error ***\n", dword, psf->dataoffset + psf->datalength) ;
-					parsestage = 4 ;
+					if (! psf->sf.seekable)
+						break ;
+
+					/* 	Seek to end of SSND chunk. */
+					fseek (psf->file, SSNDsize - 8, SEEK_CUR) ;
 					break ;
 
-			case NAME_MARKER :
-			case AUTH_MARKER :
-			case ANNO_MARKER :
 			case c_MARKER :
+			case ANNO_MARKER :
+			case AUTH_MARKER :
+			case COMT_MARKER :
+			case NAME_MARKER :
+					psf_binheader_readf (psf, "L", &dword);
+					dword += (dword & 1) ;
+					if (dword == 0)
+						break ;
+					if (dword > sizeof (psf->buffer))
+					{	psf_log_printf (psf, "  *** %D : %d (too big)\n", marker, dword) ;
+						return SFE_INTERNAL ;
+						} ;
+					psf_binheader_readf (psf, "B", psf->buffer, dword) ;
+					psf->buffer [dword - 1] = 0 ;
+					psf_log_printf (psf, "***    %D : %s\n", marker, psf->buffer) ;
+					break ;
+
 			case FVER_MARKER :
-					if (parsestage < 2)
-						return SFE_AIFF_NO_FORM ;
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-					dword = BE2H_INT (dword) ;
-					psf_sprintf (psf, " %D : %d\n", marker, dword) ;
-					fseek (psf->file, dword, SEEK_CUR) ;					
+			case SFX_MARKER :
+					psf_binheader_readf (psf, "L", &dword) ;
+					psf_log_printf (psf, " %D : %d\n", marker, dword) ;
+
+					psf_binheader_readf (psf, "j", dword) ;
 					break ;
 
-			case MARK_MARKER :
-			case INST_MARKER :
 			case APPL_MARKER :
-					if (parsestage < 2)
-						return SFE_AIFF_NO_FORM ;
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-					dword = BE2H_INT (dword) ;
-					psf_sprintf (psf, " %D : %d\n", marker, dword) ;
-					fseek (psf->file, dword, SEEK_CUR) ;					
+			case INST_MARKER :
+			case MARK_MARKER :
+					psf_binheader_readf (psf, "L", &dword) ;
+					psf_log_printf (psf, " %D : %d\n", marker, dword) ;
+
+					psf_binheader_readf (psf, "j", dword) ;
 					break ;
 
 			default : 
 					if (isprint ((marker >> 24) & 0xFF) && isprint ((marker >> 16) & 0xFF)
 						&& isprint ((marker >> 8) & 0xFF) && isprint (marker & 0xFF))
-					{	fread (&dword, sizeof (dword), 1, psf->file) ;
-						psf_sprintf (psf, "%D : %d (unknown marker)\n", marker, dword) ;
-						fseek (psf->file, dword, SEEK_CUR) ;
+					{	psf_binheader_readf (psf, "L", &dword) ;
+						psf_log_printf (psf, "%D : %d (unknown marker)\n", marker, dword) ;
+
+						psf_binheader_readf (psf, "j", dword) ;
 						break ;
 						} ;
 					if ((dword = ftell (psf->file)) & 0x03)
-					{	psf_sprintf (psf, "  Unknown chunk marker at position %d. Resynching.\n", dword - 4) ;
-						fseek (psf->file, -3, SEEK_CUR) ;
+					{	psf_log_printf (psf, "  Unknown chunk marker at position %d. Resyncing.\n", dword - 4) ;
+
+						psf_binheader_readf (psf, "j", -3) ;
 						break ;
 						} ;
-					psf_sprintf (psf, "*** Unknown chunk marker : %X. Exiting parser.\n", marker) ;
+					psf_log_printf (psf, "*** Unknown chunk marker : %X. Exiting parser.\n", marker) ;
 					done = 1 ;
 					break ;
 			} ;	/* switch (marker) */
+			
+		if ((! psf->sf.seekable) && (found_chunk & HAVE_SSND))
+			break ;
 
 		if (ferror (psf->file))
-		{	psf_sprintf (psf, "*** Error on file handle. ***\n") ;
+		{	psf_log_printf (psf, "*** Error on file handle. ***\n") ;
 			clearerr (psf->file) ;
 			break ;
 			} ;
 
-		if (ftell (psf->file) >= (off_t) (psf->filelength - (2 * sizeof (dword))))
+		if (ftell (psf->file) >= (long) (psf->filelength - (2 * sizeof (dword))))
 			break ;
 		} ; /* while (1) */
 		
+	if (! (found_chunk & HAVE_FORM))
+		return SFE_AIFF_NO_FORM ;
+
+	if (! (found_chunk & HAVE_AIFF))
+		return SFE_AIFF_COMM_NO_FORM ;
+
+	if (! (found_chunk & HAVE_COMM))
+		return SFE_AIFF_SSND_NO_COMM ;
+
 	if (! psf->dataoffset)
 		return SFE_AIFF_NO_DATA ;
 
 	psf->current     = 0 ;
-	psf->endian      = SF_ENDIAN_BIG ;			/* All AIF* files are big endian. */
 	psf->sf.seekable = SF_TRUE ;
 	psf->bytewidth   = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
 
@@ -283,155 +356,96 @@
 
 	psf->close = (func_close) aiff_close ;
 
-	switch (psf->bytewidth)
-	{	case  1 :
-				psf->read_short  = (func_short) pcm_read_sc2s ;
-				psf->read_int    = (func_int) pcm_read_sc2i ;
-				psf->read_double = (func_double) pcm_read_sc2d ;
+	switch (psf->sf.format & SF_FORMAT_SUBMASK)
+	{	case SF_FORMAT_PCM :
+		case SF_FORMAT_PCM_LE :
+		case SF_FORMAT_PCM_BE :
+				if (psf->bytewidth == 1)
+					psf->chars = SF_CHARS_SIGNED ;
+
+				error = pcm_read_init (psf) ;
 				break ;
-		case  2 :
-				psf->read_short  = (func_short) pcm_read_bes2s ;
-				psf->read_int    = (func_int) pcm_read_bes2i ;
-				psf->read_double = (func_double) pcm_read_bes2d ;
+				
+		case SF_FORMAT_FLOAT :
+				error = float32_read_init (psf) ;
 				break ;
-		case  3 :
-				psf->read_short  = (func_short) pcm_read_bet2s ;
-				psf->read_int    = (func_int) pcm_read_bet2i ;
-				psf->read_double = (func_double) pcm_read_bet2d ;
-				break ;
-		case  4 :
-				psf->read_short  = (func_short) pcm_read_bei2s ;
-				psf->read_int    = (func_int) pcm_read_bei2i ;
-				psf->read_double = (func_double) pcm_read_bei2d ;
-				break ;
-		default : 
-				/* printf ("Weird bytewidth (%d)\n", psf->bytewidth) ; */
-				return SFE_UNIMPLEMENTED ;
+
+		default : return SFE_UNIMPLEMENTED ;
 		} ;
 
-	return 0 ;
+	return error ;
 } /* aiff_open_read */
 
 /*------------------------------------------------------------------------------
  */
 
-int 	aiff_open_write	(SF_PRIVATE *psf)
-{	COMM_CHUNK			comm_fmt ;
-	SSND_CHUNK			ssnd_fmt ;
-	unsigned int		dword, FORMsize ;
-	
+int
+aiff_open_write	(SF_PRIVATE *psf)
+{	int error ;
+
 	if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_AIFF)
 		return	SFE_BAD_OPEN_FORMAT ;
-	if ((psf->sf.format & SF_FORMAT_SUBMASK) != SF_FORMAT_PCM)
-		return	SFE_BAD_OPEN_FORMAT ;
 	
-	psf->endian      = SF_ENDIAN_BIG ;			/* All AIF* files are big endian. */
 	psf->sf.seekable = SF_TRUE ;
+	psf->error       = 0 ;
+
 	psf->bytewidth   = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
 	psf->blockwidth  = psf->bytewidth * psf->sf.channels ;
-	psf->dataoffset  = 5 * sizeof (dword) + REAL_COMM_SIZE + 4 * sizeof (dword) ;
-	psf->datalength  = psf->blockwidth * psf->sf.samples ;
-	psf->filelength  = psf->datalength + psf->dataoffset ;
-	psf->error       = 0 ;
 
-	FORMsize   = 0x7FFFFFFF ;  /* Correct this when closing file. */
+	/* Set sample count artifically high and fix later. */ 
+	psf->sf.samples = 0x7FFFFFFF / psf->blockwidth ; 
 	
-	comm_fmt.numChannels     = psf->sf.channels ;
-	comm_fmt.numSampleFrames = psf->sf.samples ;
-	comm_fmt.sampleSize      = psf->sf.pcmbitwidth ;
-	uint2tenbytefloat (psf->sf.samplerate, comm_fmt.sampleRate)  ;
+	psf->datalength  = psf->blockwidth * psf->sf.samples ;
+	psf->filelength  = 0x7FFFFFFF ;
 
-	if (CPU_IS_LITTLE_ENDIAN)
-		endswap_comm_fmt (&comm_fmt) ;
+	if ((error = aiff_write_header (psf)))
+		return error ;
 
-	ssnd_fmt.offset    = 0 ;
-	ssnd_fmt.blocksize = 0 ;  /* Not normally used. */
+	psf->close        = (func_close)  aiff_close ;
+	psf->write_header = (func_wr_hdr) aiff_write_header ;
 
-	if (CPU_IS_LITTLE_ENDIAN)
-		endswap_ssnd_fmt (&ssnd_fmt) ;
+	switch (psf->sf.format & SF_FORMAT_SUBMASK)
+	{	case SF_FORMAT_PCM :
+		case SF_FORMAT_PCM_LE :
+		case SF_FORMAT_PCM_BE :
+				if (psf->bytewidth == 1)
+					psf->chars = SF_CHARS_SIGNED ;
 
-	dword = FORM_MARKER ;
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
- 	dword = H2BE_INT (FORMsize) ;
- 	fwrite (&dword, sizeof (dword), 1, psf->file) ;
-	
-	dword = AIFF_MARKER ;
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
-	dword = COMM_MARKER ;
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
-	
-	dword = H2BE_INT (REAL_COMM_SIZE) ;
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
-
-	fwrite (&(comm_fmt.numChannels), sizeof (comm_fmt.numChannels), 1, psf->file) ;
-	fwrite (&(comm_fmt.numSampleFrames), sizeof (comm_fmt.numSampleFrames), 1, psf->file) ;
-	fwrite (&(comm_fmt.sampleSize), sizeof (comm_fmt.sampleSize), 1, psf->file) ;
-	fwrite (&(comm_fmt.sampleRate), sizeof (comm_fmt.sampleRate), 1, psf->file) ;
-
-	dword = SSND_MARKER ;
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
-	dword = H2BE_INT (psf->datalength + sizeof (SSND_CHUNK)) ;
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
-
-	fwrite (&ssnd_fmt, sizeof (ssnd_fmt), 1, psf->file) ;
-	
-	psf->close = (func_close) aiff_close ;
-
-	switch (psf->bytewidth)
-	{	case  1 :
-				psf->write_short  = (func_short) pcm_write_s2sc ;
-				psf->write_int    = (func_int) pcm_write_i2sc ;
-				psf->write_double = (func_double) pcm_write_d2sc ;
+				error = pcm_write_init (psf) ;
 				break ;
-		case  2 :
-				psf->write_short  = (func_short) pcm_write_s2bes ;
-				psf->write_int    = (func_int) pcm_write_i2bes ;
-				psf->write_double = (func_double) pcm_write_d2bes ;
+				
+		case SF_FORMAT_FLOAT :
+				error = float32_write_init (psf) ;
 				break ;
-		case  3 :
-				psf->write_short  = (func_short) pcm_write_s2bet ;
-				psf->write_int    = (func_int) pcm_write_i2bet ;
-				psf->write_double = (func_double) pcm_write_d2bet ;
-				break ;
-		case  4 :
-				psf->write_short  = (func_short) pcm_write_s2bei ;
-				psf->write_int    = (func_int) pcm_write_i2bei ;
-				psf->write_double = (func_double) pcm_write_d2bei ;
-				break ;
+
 		default : return SFE_UNIMPLEMENTED ;
 		} ;
 
-	return 0 ;
+	return error ;
 } /* aiff_open_write */
 
-/*------------------------------------------------------------------------------
- */
+/*==========================================================================================
+** Private functions.
+*/
 
-int	aiff_close	(SF_PRIVATE  *psf)
-{	unsigned int	dword ;
-
+static int	
+aiff_close	(SF_PRIVATE  *psf)
+{
 	if (psf->mode == SF_MODE_WRITE)
 	{	/*  Now we know for certain the length of the file we can re-write 
 		**	correct values for the FORM, COMM and SSND chunks.
 		*/
 		 
-		fseek (psf->file, 0, SEEK_END) ;
+		aiff_write_tailer (psf) ;
+
+		fseek (psf->file, 0, SEEK_END) ;		
 		psf->filelength = ftell (psf->file) ;
+		fseek (psf->file, 0, SEEK_SET) ;
 		
- 		dword = psf->filelength - 2 * sizeof (dword) ;
- 		fseek (psf->file, sizeof (dword), SEEK_SET) ;
- 		dword = H2BE_INT (dword) ;
- 		fwrite (&dword, sizeof (dword), 1, psf->file) ;		/* FORM */
-		
-		fseek (psf->file, psf->dataoffset - (long)((sizeof (SSND_CHUNK) + sizeof (dword))), SEEK_SET) ;
 		psf->datalength = psf->filelength - psf->dataoffset ;
- 		dword = H2BE_INT (psf->datalength + sizeof (SSND_CHUNK)) ;
- 		fwrite (&dword, sizeof (dword), 1, psf->file) ;		/* SSND */
+ 		psf->sf.samples = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
 		
- 		fseek (psf->file, 5 * sizeof (dword) + sizeof (short), SEEK_SET) ;
-		dword = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
-		dword = H2BE_INT (dword) ;
- 		fwrite (&dword, sizeof (dword), 1, psf->file) ;		/* COMM.numSampleFrames */
+		aiff_write_header (psf) ;
 		} ;
 
 	if (psf->fdata)
@@ -441,6 +455,193 @@
 	return 0 ;
 } /* aiff_close */
 
+static int
+aiff_read_comm_chunk (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
+{	int error = 0, bytesread ;
+
+	bytesread = psf_binheader_readf (psf, "L", &(comm_fmt->size)) ;
+	
+	/* The COMM chunk has an int aligned to an odd word boundary. Some 
+	** procesors are not able to deal with this (ie bus fault) so we have 
+	** to take special care.
+	*/
+
+	bytesread +=
+	psf_binheader_readf (psf, "WLWB", &(comm_fmt->numChannels), &(comm_fmt->numSampleFrames), 
+			&(comm_fmt->sampleSize), &(comm_fmt->sampleRate), sizeof (comm_fmt->sampleRate)) ;
+
+	if (comm_fmt->size == AIFF_COMM_SIZE)
+		comm_fmt->encoding = NONE_MARKER ;
+	else if (comm_fmt->size >= AIFC_COMM_SIZE)
+	{	bytesread +=
+		psf_binheader_readf (psf, "mB", &(comm_fmt->encoding), &(comm_fmt->zero_bytes), 2) ;
+
+		psf_binheader_readf (psf, "B", psf->header, comm_fmt->size - AIFC_COMM_SIZE) ;
+		} ;
+		
+	psf_log_printf (psf, " COMM : %d\n", comm_fmt->size) ;
+	psf_log_printf (psf, "  Sample Rate : %d\n", tenbytefloat2int (comm_fmt->sampleRate)) ;
+	psf_log_printf (psf, "  Samples     : %d\n", comm_fmt->numSampleFrames) ;
+	psf_log_printf (psf, "  Channels    : %d\n", comm_fmt->numChannels) ;
+
+	/*	Found some broken 'fl32' files with comm.samplesize == 16. Fix it here. */ 
+
+	if ((comm_fmt->encoding == fl32_MARKER || comm_fmt->encoding == FL32_MARKER) && comm_fmt->sampleSize != 32)
+	{	psf_log_printf (psf, "  Sample Size : %d (should be 32)\n", comm_fmt->sampleSize) ;
+		comm_fmt->sampleSize = 32 ;
+		}
+	else
+		psf_log_printf (psf, "  Sample Size : %d\n", comm_fmt->sampleSize) ;
+
+	switch (comm_fmt->encoding)
+	{	case NONE_MARKER :
+				psf->endian = SF_ENDIAN_BIG ;
+				psf->sf.format = (SF_FORMAT_AIFF | SF_FORMAT_PCM) ;
+				break ;
+				
+		case twos_MARKER :
+				psf->endian = SF_ENDIAN_BIG ;
+				psf->sf.format = (SF_FORMAT_AIFF | SF_FORMAT_PCM_BE) ;
+				break ;
+
+		case sowt_MARKER :
+				psf->endian = SF_ENDIAN_LITTLE ;
+				psf->sf.format = (SF_FORMAT_AIFF | SF_FORMAT_PCM_LE) ;
+				break ;
+				
+		case fl32_MARKER :
+		case FL32_MARKER :
+				psf->endian = SF_ENDIAN_BIG ;
+				psf->sf.format = (SF_FORMAT_AIFF | SF_FORMAT_FLOAT) ;
+				break ;
+
+		default :
+			psf_log_printf (psf, "AIFC : Unimplemented format : %D\n", comm_fmt->encoding) ;
+			error = SFE_UNIMPLEMENTED ;
+		} ;
+
+	psf_log_printf (psf, "  Encoding    : %D\n", comm_fmt->encoding) ;
+	
+	return error ;
+} /* aiff_read_comm_chunk */
+
+static int
+aiff_write_header (SF_PRIVATE *psf)
+{	unsigned char 	comm_sample_rate [10], comm_zero_bytes [2] = { 0, 0 } ;
+	unsigned int 	comm_type, comm_size, comm_encoding ;
+	int				k ;
+	
+	switch (psf->sf.format & SF_FORMAT_SUBMASK)
+	{	case SF_FORMAT_PCM :					/* Standard big endian AIFF. */
+				psf->endian = SF_ENDIAN_BIG ;			
+				comm_type = AIFF_MARKER ;
+				comm_size = AIFF_COMM_SIZE ;
+				comm_encoding = 0 ;
+				break ;
+
+		case SF_FORMAT_PCM_BE :					/* Big endian AIFC. */
+				psf->endian = SF_ENDIAN_BIG ;
+				comm_type = AIFC_MARKER ;
+				comm_size = AIFC_COMM_SIZE ;
+				comm_encoding = twos_MARKER ;
+				break ;
+				
+		case SF_FORMAT_PCM_LE :					/* Little endian AIFC. */
+				psf->endian = SF_ENDIAN_LITTLE ;
+				comm_type = AIFC_MARKER ;
+				comm_size = AIFC_COMM_SIZE ;
+				comm_encoding = sowt_MARKER ;
+				break ;
+
+		case SF_FORMAT_FLOAT :					/* Big endian floating point. */
+				psf->endian = SF_ENDIAN_BIG ;
+				comm_type = AIFC_MARKER ;
+				comm_size = AIFC_COMM_SIZE ;
+				comm_encoding = FL32_MARKER ; /* Use 'FL32' because its easier to read. */
+				psf->has_peak = SF_TRUE ;
+				psf->peak_loc = SF_PEAK_START ;
+				break ;
+
+		default :	return	SFE_BAD_OPEN_FORMAT ;
+		} ;
+	
+	/* Reset the current header length to zero. */
+	psf->header [0] = 0 ;
+	psf->headindex = 0 ;
+	fseek (psf->file, 0, SEEK_SET) ;
+
+	psf_binheader_writef (psf, "mL", FORM_MARKER, psf->filelength - 8) ;
+	
+	/* Write COMM chunk. */
+	psf_binheader_writef (psf, "mmL", comm_type, COMM_MARKER, comm_size) ;
+
+	uint2tenbytefloat (psf->sf.samplerate, comm_sample_rate)  ;
+
+	psf_binheader_writef (psf, "WLW", psf->sf.channels, psf->sf.samples, psf->sf.pcmbitwidth) ;
+	psf_binheader_writef (psf, "B", comm_sample_rate, sizeof (comm_sample_rate)) ;
+	
+	/* AIFC chunks have some extra data. */
+	if (comm_type == AIFC_MARKER)
+		psf_binheader_writef (psf, "mB", comm_encoding, comm_zero_bytes, sizeof (comm_zero_bytes)) ;
+		
+	if (psf->has_peak && psf->peak_loc == SF_PEAK_START)
+	{	psf_binheader_writef (psf, "mL", PEAK_MARKER, 
+			sizeof (psf->peak) - sizeof (psf->peak.peak) + psf->sf.channels * sizeof (PEAK_POS)) ;
+		psf_binheader_writef (psf, "LL", 1, time (NULL)) ;
+		for (k = 0 ; k < psf->sf.channels ; k++)
+			psf_binheader_writef (psf, "FL", psf->peak.peak[k].value, psf->peak.peak[k].position) ; /* XXXXX */
+		} ;
+		
+	/* Write SSND chunk. */
+	psf_binheader_writef (psf, "mLLL", SSND_MARKER, psf->datalength + SSND_CHUNK_SIZE, 0, 0) ;
+
+	/* Header cunstruction complete so write it out. */
+	fwrite (psf->header, psf->headindex, 1, psf->file) ;
+
+	psf->dataoffset = psf->headindex ;
+
+	return 0 ;
+} /* aiff_write_header */
+
+static int
+aiff_write_tailer (SF_PRIVATE *psf)
+{	int		k ;
+	
+	/* Reset the current header length to zero. */
+	psf->header [0] = 0 ;
+	psf->headindex = 0 ;
+	fseek (psf->file, 0, SEEK_SET) ;
+
+	if (psf->has_peak && psf->peak_loc == SF_PEAK_END)
+	{	psf_binheader_writef (psf, "mL", PEAK_MARKER, 
+			sizeof (psf->peak) - sizeof (psf->peak.peak) + psf->sf.channels * sizeof (PEAK_POS)) ;
+		psf_binheader_writef (psf, "LL", 1, time (NULL)) ;
+		for (k = 0 ; k < psf->sf.channels ; k++)
+			psf_binheader_writef (psf, "FL", psf->peak.peak[k].value, psf->peak.peak[k].position) ; /* XXXXX */
+		} ;
+		
+	if (psf->headindex)
+		fwrite (psf->header, psf->headindex, 1, psf->file) ;
+
+	return 0 ;
+} /* aiff_write_tailer */
+
+/*-
+static void
+endswap_comm_fmt (COMM_CHUNK *comm)
+{	comm->size            = ENDSWAP_INT (comm->size) ;
+	comm->numChannels     = ENDSWAP_SHORT (comm->numChannels) ;
+	comm->numSampleFrames = ENDSWAP_INT (comm->numSampleFrames) ;
+	comm->sampleSize      = ENDSWAP_SHORT (comm->sampleSize) ;
+} /+* endswap_comm_fmt *+/
+
+static void
+endswap_ssnd_fmt (SSND_CHUNK *ssnd)
+{	ssnd->offset 	= ENDSWAP_INT (ssnd->offset) ;
+	ssnd->blocksize = ENDSWAP_INT (ssnd->blocksize) ;
+} /+* endswap_ssnd_fmt *+/
+-*/
+
 /*==========================================================================================
 **	Rough hack at converting from 80 bit IEEE float in AIFF header to an int and
 **	back again. It assumes that all sample rates are between 1 and 800MHz, which 
@@ -450,8 +651,8 @@
 **	has a copyright which probably prevents it from being allowable as GPL/LGPL.
 */
 
-static
-int     tenbytefloat2int (unsigned char *bytes)
+static int
+tenbytefloat2int (unsigned char *bytes)
 {       int val = 3 ;
 
 	if (bytes [0] & 0x80)   /* Negative number. */
@@ -475,8 +676,8 @@
 	return val ;
 } /* tenbytefloat2int */
 
-static
-void uint2tenbytefloat (unsigned int num, unsigned char *bytes)
+static void
+uint2tenbytefloat (unsigned int num, unsigned char *bytes)
 {	int		count, mask = 0x40000000 ;
 
 	memset (bytes, 0, 10) ;
--- a/common/libsndfile/src/alaw.c
+++ b/common/libsndfile/src/alaw.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -20,18 +20,53 @@
 #include	<unistd.h>
 
 #include	"sndfile.h"
+#include	"floatcast.h"
 #include	"common.h"
 
+static int		alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
+static int		alaw_read_alaw2i (SF_PRIVATE *psf, int *ptr, unsigned int len) ;
+static int		alaw_read_alaw2f (SF_PRIVATE *psf, float *ptr, unsigned int len) ;
+static int		alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, unsigned int len, int normalize) ;
+
+static int		alaw_write_s2alaw (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
+static int		alaw_write_i2alaw (SF_PRIVATE *psf, int *ptr, unsigned int len) ;
+static int		alaw_write_f2alaw (SF_PRIVATE *psf, float *ptr, unsigned int len) ;
+static int		alaw_write_d2alaw (SF_PRIVATE *psf, double *ptr, unsigned int len, int normalize) ;
+
 static  void    alaw2s_array      (unsigned char *buffer, unsigned int count, short *ptr, unsigned int index) ;
 static  void    alaw2i_array      (unsigned char *buffer, unsigned int count, int *ptr, unsigned int index) ;
+static  void    alaw2f_array      (unsigned char *buffer, unsigned int count, float *ptr, unsigned int index, float normfact) ;
 static  void    alaw2d_array      (unsigned char *buffer, unsigned int count, double *ptr, unsigned int index, double normfact) ;
 
 static  void    s2alaw_array      (short *buffer, unsigned int count, unsigned char *ptr, unsigned int index) ;
 static  void    i2alaw_array      (int *buffer, unsigned int count, unsigned char *ptr, unsigned int index) ;
+static  void    f2alaw_array      (float *buffer, unsigned int count, unsigned char *ptr, unsigned int index, float normfact) ;
 static  void    d2alaw_array      (double *buffer, unsigned int count, unsigned char *ptr, unsigned int index, double normfact) ;
 
+int
+alaw_read_init (SF_PRIVATE *psf)
+{
+	psf->read_short  = (func_short)  alaw_read_alaw2s ;
+	psf->read_int    = (func_int)    alaw_read_alaw2i ;
+	psf->read_float  = (func_float)  alaw_read_alaw2f ;
+	psf->read_double = (func_double) alaw_read_alaw2d ;
 
-int		alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, unsigned int len)
+	return 0 ;
+} /* alaw_read_init */
+
+int
+alaw_write_init (SF_PRIVATE *psf)
+{
+	psf->write_short  = (func_short)  alaw_write_s2alaw ;
+	psf->write_int    = (func_int)    alaw_write_i2alaw ;
+	psf->write_float  = (func_float)  alaw_write_f2alaw ;
+	psf->write_double = (func_double) alaw_write_d2alaw ;
+
+	return 0 ;
+} /* alaw_read_init */
+
+static int
+alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, unsigned int len)
 {	unsigned int readcount, thisread, index = 0 ;
 	int		bytecount, bufferlen ;
 	int		total = 0 ;
@@ -56,7 +91,8 @@
 	return total ;
 } /* alaw_read_alaw2s */
 
-int		alaw_read_alaw2i (SF_PRIVATE *psf, int *ptr, unsigned int len)
+static int
+alaw_read_alaw2i (SF_PRIVATE *psf, int *ptr, unsigned int len)
 {	unsigned int readcount, thisread, index = 0 ;
 	int		bytecount, bufferlen ;
 	int		total = 0 ;
@@ -81,10 +117,40 @@
 	return total ;
 } /* alaw_read_alaw2i */
 
-int		alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, unsigned int len, int normalize)
+static int
+alaw_read_alaw2f (SF_PRIVATE *psf, float *ptr, unsigned int len)
 {	unsigned int readcount, thisread, index = 0 ;
 	int		bytecount, bufferlen ;
 	int		total = 0 ;
+	float	normfact ;
+
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
+
+	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+		alaw2f_array ((unsigned char*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* alaw_read_alaw2f */
+
+static int
+alaw_read_alaw2d (SF_PRIVATE *psf, double *ptr, unsigned int len, int normalize)
+{	unsigned int readcount, thisread, index = 0 ;
+	int		bytecount, bufferlen ;
+	int		total = 0 ;
 	double	normfact ;
 	
 	normfact = (normalize ? 1.0 / ((double) 0x8000) : 1.0) ;
@@ -111,7 +177,8 @@
 /*=============================================================================================
 */
 
-int	alaw_write_s2alaw	(SF_PRIVATE *psf, short *ptr, unsigned int len)
+static int
+alaw_write_s2alaw	(SF_PRIVATE *psf, short *ptr, unsigned int len)
 {	unsigned int	writecount, thiswrite, index = 0 ;
 	int		bytecount, bufferlen ;
 	int		total = 0 ;
@@ -136,7 +203,8 @@
 	return total ;
 } /* alaw_write_s2alaw */
 
-int	alaw_write_i2alaw	(SF_PRIVATE *psf, int *ptr, unsigned int len)
+static int
+alaw_write_i2alaw	(SF_PRIVATE *psf, int *ptr, unsigned int len)
 {	unsigned int	writecount, thiswrite, index = 0 ;
 	int		bytecount, bufferlen ;
 	int		total = 0 ;
@@ -161,10 +229,40 @@
 	return total ;
 } /* alaw_write_i2alaw */
 
-int	alaw_write_d2alaw	(SF_PRIVATE *psf, double *ptr, unsigned int len, int normalize)
+static int
+alaw_write_f2alaw	(SF_PRIVATE *psf, float *ptr, unsigned int len)
 {	unsigned int	writecount, thiswrite, index = 0 ;
 	int		bytecount, bufferlen ;
 	int		total = 0 ;
+	float	normfact ;
+
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x8000) : 1.0 ;
+
+	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		f2alaw_array (ptr, index, (unsigned char*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* alaw_write_f2alaw */
+
+static int
+alaw_write_d2alaw	(SF_PRIVATE *psf, double *ptr, unsigned int len, int normalize)
+{	unsigned int	writecount, thiswrite, index = 0 ;
+	int		bytecount, bufferlen ;
+	int		total = 0 ;
 	double	normfact ;
 	
 	normfact = (normalize ? ((double) 0x8000) : 1.0) ;
@@ -189,9 +287,6 @@
 	return total ;
 } /* alaw_write_d2alaw */
 
-
-
-
 /*=============================================================================================
  *	Private static functions and data.
  */
@@ -391,44 +486,56 @@
 	0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0x2A
 } ; /* alaw_encode */
 
-static  
-void	alaw2s_array	(unsigned char *buffer, unsigned int count, short *ptr, unsigned int index)
+static void	
+alaw2s_array	(unsigned char *buffer, unsigned int count, short *ptr, unsigned int index)
 {	int 	k ;
 	for (k = 0 ; k < count ; k++)
 	{	if (buffer [k] & 0x80)
-			ptr [index] = -1 * alaw_decode [((int)buffer [k]) & 0x7F] ;
+			ptr [index] = -1 * alaw_decode [((int) buffer [k]) & 0x7F] ;
 		else
-			ptr [index] = alaw_decode [((int)buffer [k]) & 0x7F] ;
+			ptr [index] = alaw_decode [((int) buffer [k]) & 0x7F] ;
 		index ++ ;
 		} ;
 } /* alaw2s_array */
 
-static  
-void	alaw2i_array	(unsigned char *buffer, unsigned int count, int *ptr, unsigned int index)
+static void	
+alaw2i_array	(unsigned char *buffer, unsigned int count, int *ptr, unsigned int index)
 {	int 	k ;
 	for (k = 0 ; k < count ; k++)
 	{	if (buffer [k] & 0x80)
-			ptr [index] = -1 * alaw_decode [((int)buffer [k]) & 0x7F] ;
+			ptr [index] = -1 * alaw_decode [((int) buffer [k]) & 0x7F] ;
 		else
-			ptr [index] = alaw_decode [((int)buffer [k]) & 0x7F] ;
+			ptr [index] = alaw_decode [((int) buffer [k]) & 0x7F] ;
 		index ++ ;
 		} ;
 } /* alaw2i_array */
 
-static  
-void	alaw2d_array	(unsigned char *buffer, unsigned int count, double *ptr, unsigned int index, double normfact)
+static void	
+alaw2f_array	(unsigned char *buffer, unsigned int count, float *ptr, unsigned int index, float normfact)
 {	int 	k ;
 	for (k = 0 ; k < count ; k++)
 	{	if (buffer [k] & 0x80)
-			ptr [index] = -normfact * alaw_decode [((int)buffer [k]) & 0x7F] ;
+			ptr [index] = -normfact * alaw_decode [((int) buffer [k]) & 0x7F] ;
 		else
-			ptr [index] = normfact * alaw_decode [((int)buffer [k]) & 0x7F] ;
+			ptr [index] = normfact * alaw_decode [((int) buffer [k]) & 0x7F] ;
 		index ++ ;
 		} ;
 } /* alaw2d_array */
 
-static  
-void    s2alaw_array      (short *ptr, unsigned int index, unsigned char *buffer, unsigned int count)
+static void	
+alaw2d_array	(unsigned char *buffer, unsigned int count, double *ptr, unsigned int index, double normfact)
+{	int 	k ;
+	for (k = 0 ; k < count ; k++)
+	{	if (buffer [k] & 0x80)
+			ptr [index] = -normfact * alaw_decode [((int) buffer [k]) & 0x7F] ;
+		else
+			ptr [index] = normfact * alaw_decode [((int) buffer [k]) & 0x7F] ;
+		index ++ ;
+		} ;
+} /* alaw2d_array */
+
+static void    
+s2alaw_array      (short *ptr, unsigned int index, unsigned char *buffer, unsigned int count)
 {	unsigned int	k ;
 
 	for (k = 0 ; k < count ; k++)
@@ -440,8 +547,8 @@
 		} ;
 } /* s2alaw_array */
 
-static  
-void    i2alaw_array      (int *ptr, unsigned int index, unsigned char *buffer, unsigned int count)
+static void    
+i2alaw_array      (int *ptr, unsigned int index, unsigned char *buffer, unsigned int count)
 {	unsigned int	k ;
 
 	for (k = 0 ; k < count ; k++)
@@ -453,15 +560,28 @@
 		} ;
 } /* i2alaw_array */
 
-static  
-void    d2alaw_array      (double *ptr, unsigned int index, unsigned char *buffer, unsigned int count, double normfact)
+static void    
+f2alaw_array      (float *ptr, unsigned int index, unsigned char *buffer, unsigned int count, float normfact)
 {	unsigned int	k ;
 
 	for (k = 0 ; k < count ; k++)
 	{	if (ptr [index] >= 0) 
-			buffer [k] = alaw_encode [((int) (normfact * ptr [index])) / 16] ;
+			buffer [k] = alaw_encode [(FLOAT_TO_INT (normfact * ptr [index])) / 16] ;
 		else
-			buffer [k] = 0x7F & alaw_encode [((int) (normfact * ptr [index])) / -16] ;
+			buffer [k] = 0x7F & alaw_encode [(FLOAT_TO_INT (normfact * ptr [index])) / -16] ;
+		index ++ ;
+		} ;
+} /* f2alaw_array */
+
+static void    
+d2alaw_array      (double *ptr, unsigned int index, unsigned char *buffer, unsigned int count, double normfact)
+{	unsigned int	k ;
+
+	for (k = 0 ; k < count ; k++)
+	{	if (ptr [index] >= 0) 
+			buffer [k] = alaw_encode [(DOUBLE_TO_INT (normfact * ptr [index])) / 16] ;
+		else
+			buffer [k] = 0x7F & alaw_encode [(DOUBLE_TO_INT (normfact * ptr [index])) / -16] ;
 		index ++ ;
 		} ;
 } /* d2alaw_array */
--- a/common/libsndfile/src/alaw.h
+++ /dev/null
@@ -1,27 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU Lesser General Public License for more details.
-** 
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-int		alaw_read_alaw2s (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
-int		alaw_read_alaw2i (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
-int		alaw_read_alaw2d (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
-
-int		alaw_write_s2alaw (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
-int		alaw_write_i2alaw (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
-int		alaw_write_d2alaw (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
-
--- a/common/libsndfile/src/au.c
+++ b/common/libsndfile/src/au.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -27,27 +27,17 @@
 #include	"config.h"
 #include	"sfendian.h"
 #include	"common.h"
-#include	"pcm.h"
 #include	"au.h"
-#include	"ulaw.h"
-#include	"alaw.h"
 
-
 /*------------------------------------------------------------------------------
 ** Macros to handle big/little endian issues.
 */
 
-#if (CPU_IS_LITTLE_ENDIAN == 1)
-	#define	MAKE_MARKER(a,b,c,d)		((a)|((b)<<8)|((c)<<16)|((d)<<24))
-#elif (CPU_IS_BIG_ENDIAN == 1)
-	#define	MAKE_MARKER(a,b,c,d)		(((a)<<24)|((b)<<16)|((c)<<8)|(d))
-#else
-	#error "Cannot determine endian-ness of processor."
-#endif
-
 #define DOTSND_MARKER	(MAKE_MARKER ('.', 's', 'n', 'd')) 
 #define DNSDOT_MARKER	(MAKE_MARKER ('d', 'n', 's', '.')) 
 
+#define AU_DATA_OFFSET	24
+
 /*------------------------------------------------------------------------------
 ** Known AU file encoding types.
 */
@@ -102,55 +92,63 @@
 ** Private static functions.
 */
 
-static	int		au_close		(SF_PRIVATE *psf) ;
+static	int				au_close		(SF_PRIVATE *psf) ;
 
-static	int 	get_encoding	(unsigned int format, unsigned int	bitwidth) ;
-static	char* 	get_encoding_str(int format) ;
-static	void	endswap_au_fmt	(AU_FMT *pau_fmt) ;
+static	int 			get_encoding	(unsigned int format, unsigned int	bitwidth) ;
+static	char const* 	get_encoding_str(int format) ;
 
+static int				au_write_header (SF_PRIVATE *psf) ;
 
+/*
+static	void			endswap_au_fmt	(AU_FMT *pau_fmt) ;
+*/
+
 /*------------------------------------------------------------------------------
 ** Public functions.
 */
 
-int 	au_open_read	(SF_PRIVATE *psf)
+int
+au_open_read	(SF_PRIVATE *psf)
 {	AU_FMT			au_fmt ;
 	unsigned int	marker, dword ;
-	int				big_endian_file, error = SFE_NO_ERROR ;
+	int				error = SFE_NO_ERROR ;
 	
-	fread (&marker, sizeof (marker), 1, psf->file) ;
+	psf_binheader_readf (psf, "pm", 0, &marker) ;
+	psf_log_printf (psf, "%D\n", marker) ;
+
 	if (marker == DOTSND_MARKER)
-		big_endian_file = 1 ;
+	{	psf->endian = SF_ENDIAN_BIG ;
+
+		psf_binheader_readf (psf, "LLLLL", &(au_fmt.dataoffset), &(au_fmt.datasize),
+					&(au_fmt.encoding), &(au_fmt.samplerate), &(au_fmt.channels)) ;
+		}
 	else if (marker == DNSDOT_MARKER)
-		big_endian_file = 0 ;
+	{	psf->endian = SF_ENDIAN_LITTLE ;
+		psf_binheader_readf (psf, "lllll", &(au_fmt.dataoffset), &(au_fmt.datasize),
+					&(au_fmt.encoding), &(au_fmt.samplerate), &(au_fmt.channels)) ;
+		}
 	else
 		return SFE_AU_NO_DOTSND ;
 		
-	psf_sprintf (psf, "%D\n", marker) ;
 	
-	fread (&au_fmt, sizeof (AU_FMT), 1, psf->file) ;
+	psf_log_printf (psf, "  Data Offset : %d\n", au_fmt.dataoffset) ;
 	
-	if (CPU_IS_LITTLE_ENDIAN && big_endian_file)
-		endswap_au_fmt (&au_fmt) ;
-	else if (CPU_IS_BIG_ENDIAN && ! big_endian_file)
-		endswap_au_fmt (&au_fmt) ;
-
-	psf_sprintf (psf, "  Data Offset : %d\n", au_fmt.dataoffset) ;
-	
-	if (au_fmt.dataoffset + au_fmt.datasize != psf->filelength)
-	{	dword = psf->filelength - au_fmt.dataoffset ;
-		psf_sprintf (psf, "  Data Size   : %d (should be %d)\n", au_fmt.datasize, dword) ;
-		au_fmt.datasize = dword ;
+	if (au_fmt.datasize == 0xFFFFFFFF || au_fmt.dataoffset + au_fmt.datasize == psf->filelength)
+		psf_log_printf (psf, "  Data Size   : %d\n", au_fmt.datasize) ;
+	else if (au_fmt.dataoffset + au_fmt.datasize < psf->filelength)
+	{	psf->filelength = au_fmt.dataoffset + au_fmt.dataoffset ;
+		psf_log_printf (psf, "  Data Size   : %d\n", au_fmt.datasize) ;
 		}
 	else
-		psf_sprintf (psf, "  Data Size   : %d\n", au_fmt.datasize) ;
+	{	dword = psf->filelength - au_fmt.dataoffset ;
+		psf_log_printf (psf, "  Data Size   : %d (should be %d)\n", au_fmt.datasize, dword) ;
+		au_fmt.datasize = dword ;
+		} ;
 		
  	psf->dataoffset = au_fmt.dataoffset ;
 	psf->datalength = psf->filelength - psf->dataoffset ;
 
  	psf->current  = 0 ;
-	psf->endian   = big_endian_file ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ;
-	psf->sf.seekable = SF_TRUE ;
  	
  	if (fseek (psf->file, psf->dataoffset, SEEK_SET))
 		return SFE_BAD_SEEK ;
@@ -161,39 +159,30 @@
 	psf->sf.channels 	= au_fmt.channels ;
 					
 	/* Only fill in type major. */
-	psf->sf.format = big_endian_file ? SF_FORMAT_AU : SF_FORMAT_AULE ;
+	if (psf->endian == SF_ENDIAN_BIG)
+		psf->sf.format = SF_FORMAT_AU ;
+	else if (psf->endian == SF_ENDIAN_LITTLE)
+		psf->sf.format = SF_FORMAT_AULE ;
 
 	psf->sf.sections 	= 1 ;
 
-	psf_sprintf (psf, "  Encoding    : %d => %s\n", au_fmt.encoding, get_encoding_str (au_fmt.encoding)) ;
+	psf_log_printf (psf, "  Encoding    : %d => %s\n", au_fmt.encoding, get_encoding_str (au_fmt.encoding)) ;
 
-	psf_sprintf (psf, "  Sample Rate : %d\n", au_fmt.samplerate) ;
-	psf_sprintf (psf, "  Channels    : %d\n", au_fmt.channels) ;
+	psf_log_printf (psf, "  Sample Rate : %d\n", au_fmt.samplerate) ;
+	psf_log_printf (psf, "  Channels    : %d\n", au_fmt.channels) ;
 	
 	switch (au_fmt.encoding)
-	{	case  AU_ENCODING_ULAW_8 :	
-				psf->sf.pcmbitwidth = 16 ;	/* After decoding */
-				psf->bytewidth   	= 1 ;	/* Before decoding */
-				psf->blockwidth = psf->sf.channels * psf->bytewidth ;
-					
-				psf->sf.format |= SF_FORMAT_ULAW ;
-					
-				psf->read_short  = (func_short)  ulaw_read_ulaw2s ;
-				psf->read_int    = (func_int)    ulaw_read_ulaw2i ;
-				psf->read_double = (func_double) ulaw_read_ulaw2d ;
-
-				break ;
-										
-		case  AU_ENCODING_PCM_8 :	
+	{	case  AU_ENCODING_PCM_8 :	
 				psf->sf.pcmbitwidth = 8 ;
 				psf->bytewidth      = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
 				psf->blockwidth = psf->sf.channels * psf->bytewidth ;
 
 				psf->sf.format |= SF_FORMAT_PCM ;
-					
-				psf->read_short  = (func_short)  pcm_read_sc2s ;
-				psf->read_int    = (func_int)    pcm_read_sc2i ;
-				psf->read_double = (func_double) pcm_read_sc2d ;
+
+				psf->chars = SF_CHARS_SIGNED ;
+									
+				if ((error = pcm_read_init (psf)))
+					return error ;
 				break ;
 
 		case  AU_ENCODING_PCM_16 :	
@@ -203,16 +192,8 @@
 
 				psf->sf.format |= SF_FORMAT_PCM ;
 					
-				if (big_endian_file)
-				{	psf->read_short  = (func_short)  pcm_read_bes2s ;
-					psf->read_int    = (func_int)    pcm_read_bes2i ;
-					psf->read_double = (func_double) pcm_read_bes2d ;
-					}
-				else
-				{	psf->read_short  = (func_short)  pcm_read_les2s ;
-					psf->read_int    = (func_int)    pcm_read_les2i ;
-					psf->read_double = (func_double) pcm_read_les2d ;
-					} ;
+				if ((error = pcm_read_init (psf)))
+					return error ;
 				break ;
 
 		case  AU_ENCODING_PCM_24 :	
@@ -222,16 +203,8 @@
 					
 				psf->sf.format |= SF_FORMAT_PCM ;
 
-				if (big_endian_file)
-				{	psf->read_short  = (func_short)  pcm_read_bet2s ;
-					psf->read_int    = (func_int)    pcm_read_bet2i ;
-					psf->read_double = (func_double) pcm_read_bet2d ;
-					}
-				else
-				{	psf->read_short  = (func_short)  pcm_read_let2s ;
-					psf->read_int    = (func_int)    pcm_read_let2i ;
-					psf->read_double = (func_double) pcm_read_let2d ;
-					} ;
+				if ((error = pcm_read_init (psf)))
+					return error ;
 				break ;
 
 		case  AU_ENCODING_PCM_32 :	
@@ -241,59 +214,19 @@
 					
 				psf->sf.format |= SF_FORMAT_PCM ;
 					
-				if (big_endian_file)
-				{	psf->read_short  = (func_short)  pcm_read_bei2s ;
-					psf->read_int    = (func_int)    pcm_read_bei2i ;
-					psf->read_double = (func_double) pcm_read_bei2d ;
-					}
-				else
-				{	psf->read_short  = (func_short)  pcm_read_lei2s ;
-					psf->read_int    = (func_int)    pcm_read_lei2i ;
-					psf->read_double = (func_double) pcm_read_lei2d ;
-					} ;
+				if ((error = pcm_read_init (psf)))
+					return error ;
 				break ;
 					
-		case  AU_ENCODING_ALAW_8 :
-				psf->sf.pcmbitwidth = 16 ;	/* After decoding */
-				psf->bytewidth   	= 1 ;	/* Before decoding */
+		case  AU_ENCODING_FLOAT :	
+				psf->sf.pcmbitwidth = 32 ;
+				psf->bytewidth      = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
 				psf->blockwidth = psf->sf.channels * psf->bytewidth ;
-				
-				psf->sf.format |= SF_FORMAT_ALAW ;
-				
-				psf->read_short  = (func_short)  alaw_read_alaw2s ;
-				psf->read_int    = (func_int)    alaw_read_alaw2i ;
-				psf->read_double = (func_double) alaw_read_alaw2d ;
-				break ;
 					
-		case  AU_ENCODING_ADPCM_G721_32 :  /* G721 32kbs ADPCM */
-				if (psf->sf.channels != 1)
-				{	psf_sprintf (psf, "Channels != 1\n") ;
-					break ;
-					} ;
-				psf->sf.pcmbitwidth = 16 ;	/* After decoding */
-				
-				psf->sf.format |= SF_FORMAT_G721_32 ;
-				
-				error = au_g72x_reader_init (psf, AU_H_G721_32) ;
-				psf->sf.seekable = SF_FALSE ;
+				psf->sf.format |= SF_FORMAT_FLOAT ;
+
+				float32_read_init (psf) ;
 				break ;
-										
-		case  AU_ENCODING_ADPCM_G723_24 :  /* G723 24kbs ADPCM */
-				if (psf->sf.channels != 1)
-				{	psf_sprintf (psf, "Channels != 1\n") ;
-					break ;
-					} ;
-				psf->sf.pcmbitwidth = 16 ;	/* After decoding */
-				
-				psf->sf.format |= SF_FORMAT_G723_24 ;
-				
-				error = au_g72x_reader_init (psf, AU_H_G723_24) ;
-				psf->sf.seekable = SF_FALSE ;
-				break ;
-										
-		case  AU_ENCODING_NEXT :	
-				error = SFE_AU_UNKNOWN_FORMAT ;
-				break ;
 
 		default : 
 				error = SFE_AU_UNKNOWN_FORMAT ;
@@ -310,53 +243,21 @@
 	return 0 ;
 } /* au_open_read */
 
-/*------------------------------------------------------------------------------
-*/
 
-int 	au_nh_open_read	(SF_PRIVATE *psf)
-{	if (fseek (psf->file, psf->dataoffset, SEEK_SET))
-		return SFE_BAD_SEEK ;
-
-	psf_sprintf (psf, "Setting up for 8kHz, mono, u-law.\n") ;
-	
-	psf->sf.format = SF_FORMAT_AU | SF_FORMAT_ULAW ;
-
- 	psf->dataoffset = 0 ;
- 	psf->current  = 0 ;
-	psf->endian   = 0 ;  /* Irrelevant but it must be something. */
-	psf->sf.seekable = SF_TRUE ;
-	psf->sf.samplerate	= 8000 ;
-	psf->sf.channels 	= 1 ;
-	psf->sf.sections 	= 1 ;
-	psf->sf.pcmbitwidth = 16 ;	/* After decoding */
-	psf->bytewidth   	= 1 ;	/* Before decoding */
-					
-	psf->read_short  = (func_short)  ulaw_read_ulaw2s ;
-	psf->read_int    = (func_int)    ulaw_read_ulaw2i ;
-	psf->read_double = (func_double) ulaw_read_ulaw2d ;
-	psf->close 	     = (func_close)  au_close ;
-
-	psf->blockwidth = 1 ;
-	psf->sf.samples = psf->filelength ;
-	psf->datalength = psf->filelength ;
-
-	return 0 ;
-} /* au_open_read */
-
 /*------------------------------------------------------------------------------
 */
 
-int 	au_open_write	(SF_PRIVATE *psf)
-{	AU_FMT			au_fmt ;
-	unsigned int	dword, encoding, format, subformat, big_endian_file ;
+int
+au_open_write	(SF_PRIVATE *psf)
+{	unsigned int	encoding, format, subformat ;
 	int				error = 0 ;
-	
+
 	format = psf->sf.format & SF_FORMAT_TYPEMASK ;
 	subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
 	if (format == SF_FORMAT_AU)
-		big_endian_file = 1 ;
+		psf->endian = SF_ENDIAN_BIG ;
 	else if (format == SF_FORMAT_AULE)
-		big_endian_file = 0 ;
+		psf->endian = SF_ENDIAN_LITTLE ;
 	else
 		return	SFE_BAD_OPEN_FORMAT ;
 		
@@ -366,122 +267,37 @@
 	else
 		psf->bytewidth = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
 		
-	psf->endian      = big_endian_file ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ;
 	psf->sf.seekable = SF_TRUE ;
+	psf->error       = 0 ;
+
 	psf->blockwidth  = psf->bytewidth * psf->sf.channels ;
- 	psf->dataoffset  = 6 * sizeof (dword) ;
+ 	psf->dataoffset  = AU_DATA_OFFSET ;
 	psf->datalength  = psf->blockwidth * psf->sf.samples ;
 	psf->filelength  = psf->datalength + psf->dataoffset ;
-	psf->error       = 0 ;
 
-	encoding = get_encoding (subformat, psf->bytewidth * 8) ;
-	if (! encoding)
-		return	SFE_BAD_OPEN_FORMAT ;
+	if (! (encoding = au_write_header (psf)))
+		return psf->error ;
 
-	au_fmt.dataoffset = 24 ;
-	au_fmt.datasize   = psf->datalength ;
-	au_fmt.encoding   = encoding ;
-	au_fmt.samplerate = psf->sf.samplerate ;
-	au_fmt.channels   = psf->sf.channels ;
+	psf->close        = (func_close)  au_close ;
+	psf->write_header = (func_wr_hdr) au_write_header ;
 	
-	if (CPU_IS_LITTLE_ENDIAN && big_endian_file)
-		endswap_au_fmt (&au_fmt) ;
-	else if (CPU_IS_BIG_ENDIAN && ! big_endian_file)
-		endswap_au_fmt (&au_fmt) ;
-	
-	dword = big_endian_file ? DOTSND_MARKER : DNSDOT_MARKER ;	/* Marker */
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
-	
-	fwrite (&au_fmt, sizeof (AU_FMT), 1, psf->file) ;
-	
-	psf->close = (func_close) au_close ;
-	
 	switch (encoding)
-	{	case  AU_ENCODING_ULAW_8 :	/* 8-bit Ulaw encoding. */
-				psf->write_short  = (func_short)  ulaw_write_s2ulaw ;
-				psf->write_int    = (func_int)    ulaw_write_i2ulaw ;
-				psf->write_double = (func_double) ulaw_write_d2ulaw ;
-				break ;
-	
-		case  AU_ENCODING_PCM_8 :	/* 8-bit linear PCM. */
-				psf->write_short  = (func_short)  pcm_write_s2sc ;
-				psf->write_int    = (func_int)    pcm_write_i2sc ;
-				psf->write_double = (func_double) pcm_write_d2sc ;
-				break ;
+	{	case  AU_ENCODING_PCM_8 :	/* 8-bit linear PCM. */
+				psf->chars = SF_CHARS_SIGNED ;
 
-		case  AU_ENCODING_PCM_16 :	/* 16-bit linear PCM. */
-				if (big_endian_file)
-				{	psf->write_short  = (func_short)  pcm_write_s2bes ;
-					psf->write_int    = (func_int)    pcm_write_i2bes ;
-					psf->write_double = (func_double) pcm_write_d2bes ;
-					}
-				else
-				{	psf->write_short  = (func_short)  pcm_write_s2les ;
-					psf->write_int    = (func_int)    pcm_write_i2les ;
-					psf->write_double = (func_double) pcm_write_d2les ;
-					} ;
+				error = pcm_write_init (psf) ;				
 				break ;
 
+		case  AU_ENCODING_PCM_16 :	/* 16-bit linear PCM. */
 		case  AU_ENCODING_PCM_24 :	/* 24-bit linear PCM */
-				if (big_endian_file)
-				{	psf->write_short  = (func_short)  pcm_write_s2bet ;
-					psf->write_int    = (func_int)    pcm_write_i2bet ;
-					psf->write_double = (func_double) pcm_write_d2bet ;
-					}
-				else
-				{	psf->write_short  = (func_short)  pcm_write_s2let ;
-					psf->write_int    = (func_int)    pcm_write_i2let ;
-					psf->write_double = (func_double) pcm_write_d2let ;
-					} ;
-				break ;
-
 		case  AU_ENCODING_PCM_32 :	/* 32-bit linear PCM. */
-				if (big_endian_file)
-				{	psf->write_short  = (func_short)  pcm_write_s2bei ;
-					psf->write_int    = (func_int)    pcm_write_i2bei ;
-					psf->write_double = (func_double) pcm_write_d2bei ;
-					}
-				else
-				{	psf->write_short  = (func_short)  pcm_write_s2lei ;
-					psf->write_int    = (func_int)    pcm_write_i2lei ;
-					psf->write_double = (func_double) pcm_write_d2lei ;
-					} ;
+				error = pcm_write_init (psf) ;
 				break ;
-				
-		case  AU_ENCODING_ALAW_8 :	/* 8-bit Alaw encoding. */
-				psf->write_short  = (func_short)  alaw_write_s2alaw ;
-				psf->write_int    = (func_int)    alaw_write_i2alaw ;
-				psf->write_double = (func_double) alaw_write_d2alaw ;
-				break ;
-	
-		case  AU_ENCODING_ADPCM_G721_32 :  
-				if (psf->sf.channels != 1)
-				{	psf_sprintf (psf, "Channels != 1\n") ;
-					break ;
-					} ;
-				psf->sf.pcmbitwidth = 16 ;	/* After decoding */
-				psf->bytewidth   	= 0 ;
-				psf->blockwidth = psf->sf.channels * psf->bytewidth ;
-				
-				psf->sf.format |= SF_FORMAT_G721_32 ;
-				
-				error = au_g72x_writer_init (psf, AU_H_G721_32) ;
-				break ;
 
-		case  AU_ENCODING_ADPCM_G723_24 :  
-				if (psf->sf.channels != 1)
-				{	psf_sprintf (psf, "Channels != 1\n") ;
-					break ;
-					} ;
-				psf->sf.pcmbitwidth = 16 ;	/* After decoding */
-				psf->bytewidth   	= 0 ;
-				psf->blockwidth = psf->sf.channels * psf->bytewidth ;
-				
-				psf->sf.format |= SF_FORMAT_G721_32 ;
-				
-				error = au_g72x_writer_init (psf, AU_H_G723_24) ;
+		case  AU_ENCODING_FLOAT :	/* 32-bit linear PCM. */
+				error = float32_write_init (psf) ;
 				break ;
-
+				
 		default :   break ;
 		} ;
 		
@@ -491,9 +307,9 @@
 /*------------------------------------------------------------------------------
 */
 
-int	au_close	(SF_PRIVATE  *psf)
-{	unsigned int	dword ;
-
+static int
+au_close	(SF_PRIVATE  *psf)
+{
 	if (psf->mode == SF_MODE_WRITE)
 	{	/*  Now we know for certain the length of the file we can
 		 *  re-write correct values for the datasize header element.
@@ -502,16 +318,11 @@
 		fseek (psf->file, 0, SEEK_END) ;
 		psf->filelength = ftell (psf->file) ;
 
-		psf->datalength = psf->filelength - psf->dataoffset ;
-		fseek (psf->file, 2 * sizeof (dword), SEEK_SET) ;
+		psf->datalength = psf->filelength - AU_DATA_OFFSET ;
+		fseek (psf->file, 0, SEEK_SET) ;
 		
-		if (psf->endian == SF_ENDIAN_BIG)
-			dword = H2BE_INT (psf->datalength) ;
-		else if (psf->endian == SF_ENDIAN_LITTLE)
-			dword = H2LE_INT (psf->datalength) ;
-		else
-			dword = 0xFFFFFFFF ;
-		fwrite (&dword, sizeof (dword), 1, psf->file) ;
+		psf->sf.samples = psf->datalength / psf->blockwidth ;
+		au_write_header (psf) ;
 		} ;
 
 	if (psf->fdata)
@@ -521,8 +332,44 @@
 	return 0 ;
 } /* au_close */
 
-static	
-int get_encoding (unsigned int format, unsigned int	bitwidth)
+static int
+au_write_header (SF_PRIVATE *psf)
+{	int		encoding ;
+
+	encoding = get_encoding (psf->sf.format & SF_FORMAT_SUBMASK, psf->bytewidth * 8) ;
+	if (! encoding)
+	{	psf->error = SFE_BAD_OPEN_FORMAT ;
+		return	encoding ;
+		} ;
+
+	/* Reset the current header length to zero. */
+	psf->header [0] = 0 ;
+	psf->headindex = 0 ;
+	fseek (psf->file, 0, SEEK_SET) ;
+
+	if (psf->endian == SF_ENDIAN_BIG)
+	{	psf_binheader_writef (psf, "mL", DOTSND_MARKER, AU_DATA_OFFSET) ;
+		psf_binheader_writef (psf, "LLLL", psf->datalength, encoding, psf->sf.samplerate, psf->sf.channels) ;
+		}
+	else if  (psf->endian == SF_ENDIAN_LITTLE)
+	{	psf_binheader_writef (psf, "ml", DNSDOT_MARKER, AU_DATA_OFFSET) ;
+		psf_binheader_writef (psf, "llll", psf->datalength, encoding, psf->sf.samplerate, psf->sf.channels) ;
+		}
+	else
+	{	psf->error = SFE_BAD_OPEN_FORMAT ;
+		return	encoding ;
+		} ;
+
+	/* Header construction complete so write it out. */
+	fwrite (psf->header, psf->headindex, 1, psf->file) ;
+
+	psf->dataoffset = psf->headindex ;
+	
+	return encoding ;
+} /* au_write_header */ 
+
+static int
+get_encoding (unsigned int format, unsigned int	bitwidth)
 {	if (format == SF_FORMAT_ULAW)
 		return AU_ENCODING_ULAW_8 ;
 		
@@ -535,6 +382,9 @@
 	if (format == SF_FORMAT_G723_24)
 		return AU_ENCODING_ADPCM_G723_24 ;
 
+	if (format == SF_FORMAT_FLOAT)
+		return AU_ENCODING_FLOAT ;
+
 	if (format != SF_FORMAT_PCM)
 		return 0 ;
 
@@ -547,19 +397,21 @@
 		default : break ;
 		} ;
 	return 0 ;
-} /* get encoding */
+} /* get_encoding */
 
-static
-void	endswap_au_fmt (AU_FMT *pau_fmt)
+/*-
+static void
+endswap_au_fmt (AU_FMT *pau_fmt)
 {	pau_fmt->dataoffset = ENDSWAP_INT (pau_fmt->dataoffset) ;
 	pau_fmt->datasize   = ENDSWAP_INT (pau_fmt->datasize) ;
 	pau_fmt->encoding   = ENDSWAP_INT (pau_fmt->encoding) ;
     pau_fmt->samplerate = ENDSWAP_INT (pau_fmt->samplerate) ;
     pau_fmt->channels   = ENDSWAP_INT (pau_fmt->channels) ;
-} /* endswap_au_fmt */
+} /+* endswap_au_fmt *+/
+-*/
 
-static	
-char* get_encoding_str (int format)
+static	char const* 
+get_encoding_str (int format)
 {	switch (format)
 	{	case  AU_ENCODING_ULAW_8 :	
 				return "8-bit ISDN u-law" ;
@@ -575,6 +427,9 @@
 
 		case  AU_ENCODING_PCM_32 :	
 				return "32-bit linear PCM" ;
+					
+		case  AU_ENCODING_FLOAT :	
+				return "32-bit float" ;
 					
 		case  AU_ENCODING_ALAW_8 :
 				return "8-bit ISDN A-law" ;
--- a/common/libsndfile/src/au.h
+++ b/common/libsndfile/src/au.h
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
--- a/common/libsndfile/src/au_g72x.c
+++ b/common/libsndfile/src/au_g72x.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -16,15 +16,15 @@
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
-
 #include	<stdio.h>
 #include	<unistd.h>
 #include	<string.h>
 #include	<math.h>
 
-#include	"sndfile.h"
 #include	"config.h"
+#include	"sndfile.h"
 #include	"sfendian.h"
+#include	"floatcast.h"
 #include	"common.h"
 #include	"au.h"
 #include	"G72x/g72x.h"
@@ -37,13 +37,15 @@
 
 static	int	au_g72x_read_s (SF_PRIVATE *psf, short *ptr, int len) ;
 static	int	au_g72x_read_i (SF_PRIVATE *psf, int *ptr, int len) ;
+static	int	au_g72x_read_f (SF_PRIVATE *psf, float *ptr, int len) ;
 static	int	au_g72x_read_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
 
 static	int	au_g72x_write_s (SF_PRIVATE *psf, short *ptr, int len) ;
 static	int	au_g72x_write_i (SF_PRIVATE *psf, int *ptr, int len) ;
+static	int	au_g72x_write_f (SF_PRIVATE *psf, float *ptr, int len) ;
 static	int	au_g72x_write_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
 
-static  off_t au_g72x_seek (SF_PRIVATE *psf, off_t offset, int whence) ;
+static  long au_g72x_seek (SF_PRIVATE *psf, long offset, int whence) ;
 
 static	int	au_g72x_close	(SF_PRIVATE  *psf) ;
 
@@ -52,7 +54,8 @@
 ** WAV G721 Reader initialisation function.
 */
 
-int	au_g72x_reader_init (SF_PRIVATE *psf, int codec)
+int	
+au_g72x_reader_init (SF_PRIVATE *psf, int codec)
 {	G72x_DATA	*pg72x ;
 	int	bitspersample ;
 	
@@ -86,6 +89,7 @@
 				
 	psf->read_short  = (func_short)  au_g72x_read_s ;
 	psf->read_int    = (func_int)    au_g72x_read_i ;
+	psf->read_float  = (func_float)  au_g72x_read_f ;
 	psf->read_double = (func_double) au_g72x_read_d ;
  
  	psf->seek_func   = (func_seek)   au_g72x_seek ;
@@ -99,7 +103,7 @@
 	psf->sf.samples = (8 * psf->datalength) / bitspersample ;
 
 	if ((psf->sf.samples * bitspersample) / 8 != psf->datalength)
-		psf_sprintf (psf, "*** Warning : weird psf->datalength.\n") ;
+		psf_log_printf (psf, "*** Warning : weird psf->datalength.\n") ;
 			
 	psf->blockwidth = psf->bytewidth = 1 ;
 
@@ -112,7 +116,8 @@
 ** WAV G721 writer initialisation function.
 */
 
-int	au_g72x_writer_init (SF_PRIVATE *psf, int codec)
+int	
+au_g72x_writer_init (SF_PRIVATE *psf, int codec)
 {	G72x_DATA	*pg72x ;
 	
 	psf->sf.seekable = SF_FALSE ;
@@ -143,6 +148,7 @@
 
 	psf->write_short  = (func_short)  au_g72x_write_s ;
 	psf->write_int    = (func_int)    au_g72x_write_i ;
+	psf->write_float  = (func_float)  au_g72x_write_f ;
 	psf->write_double = (func_double) au_g72x_write_d ;
  
  	psf->seek_func   = (func_seek)    au_g72x_seek ;
@@ -159,8 +165,8 @@
 ** G721 Read Functions.
 */
 
-static
-int		au_g72x_read_block (SF_PRIVATE *psf, G72x_DATA *pg72x)
+static int
+au_g72x_read_block (SF_PRIVATE *psf, G72x_DATA *pg72x)
 {	int	k ;
 	
 	pg72x->blockcount ++ ;
@@ -172,7 +178,7 @@
 		} ;
 
 	if ((k = fread (pg72x->block, 1, pg72x->bytesperblock, psf->file)) != pg72x->bytesperblock)
-		psf_sprintf (psf, "*** Warning : short read (%d != %d).\n", k, pg72x->bytesperblock) ;
+		psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, pg72x->bytesperblock) ;
 
 	pg72x->blocksize = k ;
 	g72x_decode_block (pg72x) ;
@@ -180,8 +186,8 @@
 	return 1 ;
 } /* au_g72x_read_block */
 
-static
-int au_g72x_read (SF_PRIVATE *psf, G72x_DATA *pg72x, short *ptr, int len)
+static int 
+au_g72x_read (SF_PRIVATE *psf, G72x_DATA *pg72x, short *ptr, int len)
 {	int		count, total = 0, index = 0 ;
 
 	while (index < len)
@@ -205,8 +211,8 @@
 	return total ;		
 } /* au_g72x_read */
 
-static
-int		au_g72x_read_s (SF_PRIVATE *psf, short *ptr, int len)
+static int		
+au_g72x_read_s (SF_PRIVATE *psf, short *ptr, int len)
 {	G72x_DATA 	*pg72x ; 
 	int				total ;
 
@@ -219,8 +225,8 @@
 	return total ;
 } /* au_g72x_read_s */
 
-static
-int		au_g72x_read_i  (SF_PRIVATE *psf, int *ptr, int len)
+static int		
+au_g72x_read_i  (SF_PRIVATE *psf, int *ptr, int len)
 {	G72x_DATA *pg72x ; 
 	short		*sptr ;
 	int			k, bufferlen, readcount = 0, count ;
@@ -244,17 +250,20 @@
 	return total ;
 } /* au_g72x_read_i */
 
-static
-int		au_g72x_read_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+au_g72x_read_f  (SF_PRIVATE *psf, float *ptr, int len)
 {	G72x_DATA *pg72x ; 
 	short		*sptr ;
 	int			k, bufferlen, readcount = 0, count ;
 	int			index = 0, total = 0 ;
+	float 		normfact ;
 
 	if (! psf->fdata)
 		return 0 ;
 	pg72x = (G72x_DATA*) psf->fdata ;
 	
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
+
 	sptr = (short*) psf->buffer ;
 	bufferlen = SF_BUFFER_LEN / sizeof (short) ;
 	while (len > 0)
@@ -261,7 +270,7 @@
 	{	readcount = (len >= bufferlen) ? bufferlen : len ;
 		count = au_g72x_read (psf, pg72x, sptr, readcount) ;
 		for (k = 0 ; k < readcount ; k++)
-			ptr [index+k] = (double) (sptr [k]) ;
+			ptr [index+k] = normfact * sptr [k] ;
 		index += readcount ;
 		total += count ;
 		len -= readcount ;
@@ -268,10 +277,39 @@
 		} ;
 
 	return total ;
+} /* au_g72x_read_f */
+
+static int		
+au_g72x_read_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	G72x_DATA *pg72x ; 
+	short		*sptr ;
+	int			k, bufferlen, readcount = 0, count ;
+	int			index = 0, total = 0 ;
+	double		normfact ;
+	
+	if (! psf->fdata)
+		return 0 ;
+	pg72x = (G72x_DATA*) psf->fdata ;
+	
+	normfact = (normalize) ? 1.0 / ((double) 0x8000) : 1.0 ;
+
+	sptr = (short*) psf->buffer ;
+	bufferlen = SF_BUFFER_LEN / sizeof (short) ;
+	while (len > 0)
+	{	readcount = (len >= bufferlen) ? bufferlen : len ;
+		count = au_g72x_read (psf, pg72x, sptr, readcount) ;
+		for (k = 0 ; k < readcount ; k++)
+			ptr [index+k] = normfact * (double) (sptr [k]) ;
+		index += readcount ;
+		total += count ;
+		len -= readcount ;
+		} ;
+
+	return total ;
 } /* au_g72x_read_d */
 
-static
-off_t    au_g72x_seek   (SF_PRIVATE *psf, off_t offset, int whence)
+static long    
+au_g72x_seek   (SF_PRIVATE *psf, long offset, int whence)
 {
 
 	/*	No simple solution. To do properly, would need to seek
@@ -290,7 +328,7 @@
 **	
 **		if (! (psf->datalength && psf->dataoffset))
 **		{	psf->error = SFE_BAD_SEEK ;
-**			return	((off_t) -1) ;
+**			return	((long) -1) ;
 **			} ;
 **			
 **		samplecount = (8 * psf->datalength) / G721_32_BITS_PER_SAMPLE ;
@@ -299,7 +337,7 @@
 **		{	case SEEK_SET :
 **					if (offset < 0 || offset > samplecount)
 **					{	psf->error = SFE_BAD_SEEK ;
-**						return	((off_t) -1) ;
+**						return	((long) -1) ;
 **						} ;
 **					newblock  = offset / pg72x->samplesperblock ;
 **					newsample = offset % pg72x->samplesperblock ;
@@ -308,7 +346,7 @@
 **			case SEEK_CUR :
 **					if (psf->current + offset < 0 || psf->current + offset > samplecount)
 **					{	psf->error = SFE_BAD_SEEK ;
-**						return	((off_t) -1) ;
+**						return	((long) -1) ;
 **						} ;
 **					newblock  = (8 * (psf->current + offset)) / pg72x->samplesperblock ;
 **					newsample = (8 * (psf->current + offset)) % pg72x->samplesperblock ;
@@ -317,7 +355,7 @@
 **			case SEEK_END :
 **					if (offset > 0 || samplecount + offset < 0)
 **					{	psf->error = SFE_BAD_SEEK ;
-**						return	((off_t) -1) ;
+**						return	((long) -1) ;
 **						} ;
 **					newblock  = (samplecount + offset) / pg72x->samplesperblock ;
 **					newsample = (samplecount + offset) % pg72x->samplesperblock ;
@@ -325,7 +363,7 @@
 **					
 **			default : 
 **					psf->error = SFE_BAD_SEEK ;
-**					return	((off_t) -1) ;
+**					return	((long) -1) ;
 **			} ;
 **			
 **		if (psf->mode == SF_MODE_READ)
@@ -337,7 +375,7 @@
 **		else
 **		{	/+* What to do about write??? *+/ 
 **			psf->error = SFE_BAD_SEEK ;
-**			return	((off_t) -1) ;
+**			return	((long) -1) ;
 **			} ;
 **	
 **		psf->current = newblock * pg72x->samplesperblock + newsample ;
@@ -347,16 +385,11 @@
 } /* au_g72x_seek */
 
 /*==========================================================================================
-** G721 Write Functions.
+** G72x Write Functions.
 */
 
-
-
-/*==========================================================================================
-*/
-
-static
-int		au_g72x_write_block (SF_PRIVATE *psf, G72x_DATA *pg72x)
+static int		
+au_g72x_write_block (SF_PRIVATE *psf, G72x_DATA *pg72x)
 {	int k ;
 
 	/* Encode the samples. */
@@ -364,7 +397,7 @@
 
 	/* Write the block to disk. */
 	if ((k = fwrite (pg72x->block, 1, pg72x->blocksize, psf->file)) != pg72x->blocksize)
-		psf_sprintf (psf, "*** Warning : short write (%d != %d).\n", k, pg72x->blocksize) ;
+		psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, pg72x->blocksize) ;
 
 	pg72x->samplecount = 0 ;
 	pg72x->blockcount ++ ;
@@ -375,8 +408,8 @@
 	return 1 ;
 } /* au_g72x_write_block */
 
-static
-int au_g72x_write (SF_PRIVATE *psf, G72x_DATA *pg72x, short *ptr, int len)
+static int 
+au_g72x_write (SF_PRIVATE *psf, G72x_DATA *pg72x, short *ptr, int len)
 {	int		count, total = 0, index = 0 ;
 	
 	while (index < len)
@@ -397,8 +430,8 @@
 	return total ;		
 } /* au_g72x_write */
 
-static
-int		au_g72x_write_s (SF_PRIVATE *psf, short *ptr, int len)
+static int		
+au_g72x_write_s (SF_PRIVATE *psf, short *ptr, int len)
 {	G72x_DATA 	*pg72x ; 
 	int				total ;
 
@@ -411,8 +444,8 @@
 	return total ;
 } /* au_g72x_write_s */
 
-static
-int		au_g72x_write_i  (SF_PRIVATE *psf, int *ptr, int len)
+static int		
+au_g72x_write_i  (SF_PRIVATE *psf, int *ptr, int len)
 {	G72x_DATA *pg72x ; 
 	short		*sptr ;
 	int			k, bufferlen, writecount = 0, count ;
@@ -427,7 +460,7 @@
 	while (len > 0)
 	{	writecount = (len >= bufferlen) ? bufferlen : len ;
 		for (k = 0 ; k < writecount ; k++)
-			sptr [k] = (short) ptr [index+k] ;
+			sptr [k] = ptr [index+k] ;
 		count = au_g72x_write (psf, pg72x, sptr, writecount) ;
 		index += writecount ;
 		total += count ;
@@ -436,23 +469,54 @@
 	return total ;
 } /* au_g72x_write_i */
 
-static
-int		au_g72x_write_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int		
+au_g72x_write_f  (SF_PRIVATE *psf, float *ptr, int len)
 {	G72x_DATA *pg72x ; 
 	short		*sptr ;
 	int			k, bufferlen, writecount = 0, count ;
 	int			index = 0, total = 0 ;
+	float		normfact ;
+	
+	if (! psf->fdata)
+		return 0 ;
+	pg72x = (G72x_DATA*) psf->fdata ;
+	
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x8000) : 1.0 ;
 
+	sptr = (short*) psf->buffer ;
+	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
+	while (len > 0)
+	{	writecount = (len >= bufferlen) ? bufferlen : len ;
+		for (k = 0 ; k < writecount ; k++)
+			sptr [k] = FLOAT_TO_SHORT (normfact * ptr [index+k])  ;
+		count = au_g72x_write (psf, pg72x, sptr, writecount) ;
+		index += writecount ;
+		total += count ;
+		len -= writecount ;
+		} ;
+	return total ;
+} /* au_g72x_write_f */
+
+static int		
+au_g72x_write_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	G72x_DATA *pg72x ; 
+	short		*sptr ;
+	int			k, bufferlen, writecount = 0, count ;
+	int			index = 0, total = 0 ;
+	double		normfact ;
+
 	if (! psf->fdata)
 		return 0 ;
 	pg72x = (G72x_DATA*) psf->fdata ;
 	
+	normfact = (normalize) ? ((float) 0x8000) : 1.0 ;
+
 	sptr = (short*) psf->buffer ;
 	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
 	while (len > 0)
 	{	writecount = (len >= bufferlen) ? bufferlen : len ;
 		for (k = 0 ; k < writecount ; k++)
-			sptr [k] = (short) ptr [index+k]  ;
+			sptr [k] = DOUBLE_TO_SHORT (normfact * ptr [index+k])  ;
 		count = au_g72x_write (psf, pg72x, sptr, writecount) ;
 		index += writecount ;
 		total += count ;
@@ -461,8 +525,8 @@
 	return total ;
 } /* au_g72x_write_d */
 
-static
-int	au_g72x_close	(SF_PRIVATE  *psf)
+static int	
+au_g72x_close	(SF_PRIVATE  *psf)
 {	G72x_DATA *pg72x ; 
 
 	if (! psf->fdata)
@@ -478,12 +542,18 @@
 		if (pg72x->samplecount && pg72x->samplecount < G72x_BLOCK_SIZE)
 			au_g72x_write_block (psf, pg72x) ;	
 
-
-
 		/*  Now we know for certain the length of the file we can
 		**  re-write correct values for the RIFF and data chunks.
 		*/
-		 
+		
+		fseek (psf->file, 0, SEEK_END) ;
+		psf->filelength = ftell (psf->file) ;
+
+		psf->sf.samples = pg72x->samplesperblock * pg72x->blockcount ;
+		psf->datalength = psf->filelength - psf->dataoffset ;
+
+		if (psf->write_header)
+			psf->write_header (psf) ; 
 		} ;
 
 	if (psf->fdata)
--- a/common/libsndfile/src/common.c
+++ b/common/libsndfile/src/common.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -18,6 +18,7 @@
 
 #include	<stdarg.h>
 #include	<string.h>
+#include	<math.h>
 
 #include	"sndfile.h"
 #include	"sfendian.h"
@@ -24,15 +25,18 @@
 #include	"common.h"
 
 /*-----------------------------------------------------------------------------------------------
- */
+** Generic functions for performing endian swapping on short and int arrays.
+*/
 
-void	endswap_short_array (short *ptr, int len)
+void
+endswap_short_array (short *ptr, int len)
 {	int k ;
 	for (k = 0 ; k < len ; k++)
 		ptr[k] = ((((ptr[k])>>8)&0xFF)|(((ptr[k])&0xFF)<<8)) ;
 } /* endswap_short_array */
 
-void	endswap_int_array (int *ptr, int len)
+void
+endswap_int_array (int *ptr, int len)
 {	int k ;
 	for (k = 0 ; k < len ; k++)
 		ptr[k] = ((((ptr[k])>>24)&0xFF)|(((ptr[k])>>8)&0xFF00)|
@@ -40,15 +44,22 @@
 } /* endswap_int_array */
 
 /*-----------------------------------------------------------------------------------------------
- */
+** psf_log_printf allows libsndfile internal functions to print to an internal logbuffer which
+** can later be displayed. 
+** The format specifiers are as for printf but without the field width and other modifiers.
+** Printing is performed to the logbuffer char array of the SF_PRIVATE struct. 
+** Printing is done in such a way as to guarantee that the log never overflows the end of the
+** logbuffer array.  
+*/
 
 #define psf_putchar(a,b)									\
-			if ((a)->strindex < SF_BUFFER_LEN - 1)			\
-			{	(a)->strbuffer [(a)->strindex++] = (b) ;	\
-				(a)->strbuffer [(a)->strindex] = 0 ;		\
+			if ((a)->logindex < SF_BUFFER_LEN - 1)			\
+			{	(a)->logbuffer [(a)->logindex++] = (b) ;	\
+				(a)->logbuffer [(a)->logindex] = 0 ;		\
 				} ;
 
-void psf_sprintf (SF_PRIVATE *psf, char *format, ...)
+void
+psf_log_printf (SF_PRIVATE *psf, char *format, ...)
 {	va_list	ap ;
 	int     d, tens, shift ;
 	char    c, *strptr, istr [5] ;
@@ -55,7 +66,7 @@
 
 	va_start(ap, format);
 	
-	/* printf ("psf_sprintf : %s\n", format) ; */
+	/* printf ("psf_log_printf : %s\n", format) ; */
 	
 	while ((c = *format++))
 	{	if (c != '%')
@@ -136,9 +147,9 @@
 					break;
 					
 			default :
-					psf_putchar (psf, '?') ;
+					psf_putchar (psf, '*') ;
 					psf_putchar (psf, c) ;
-					psf_putchar (psf, '?') ;
+					psf_putchar (psf, '*') ;
 					break ;
 			} /* switch */
 		} /* while */
@@ -145,24 +156,65 @@
 
 	va_end(ap);
 	return ;
-} /* psf_sprintf */
+} /* psf_log_printf */
 
-/*------------------------------------------------------------------------------
-**  Format specifiers for psf_hprintf are as follows
-**		m	- marker - four bytes - no endian problems
+/*-----------------------------------------------------------------------------------------------
+**  ASCII header printf functions.
+**  Some formats (ie NIST) use ascii text in their headers.
+**  Format specifiers are the same as the standard printf specifiers (uses vsnprintf).
+**  If this generates a compile error on any system, the author should be notified
+**  so an alternative vsnprintf can be provided.
+*/
+
+void
+psf_asciiheader_printf (SF_PRIVATE *psf, char *format, ...)
+{	va_list	argptr ;
+	int  maxlen ;
+	char *start ;
+	
+	start  = (char*) psf->header + strlen ((char*) psf->header) ;
+	maxlen = sizeof (psf->header) - strlen ((char*) psf->header) ;
+	
+	va_start (argptr, format) ;
+	vsnprintf (start, maxlen, format, argptr) ;
+	va_end (argptr) ;
+
+	/* Make sure the string is properly terminated. */
+	start [maxlen - 1] = 0 ;	
+
+	return ;
+} /* psf_asciiheader_printf */
+
+/*-----------------------------------------------------------------------------------------------
+**  Binary header writing functions. Returns number of bytes written.
+**
+**  Format specifiers for psf_binheader_writef are as follows
+**		m	- marker - four bytes - no endian manipulation
+**
+**		b   - byte
+**
 **		w	- two byte value - little endian
 **		W	- two byte value - big endian
 **		l	- four byte value - little endian
 **		L	- four byte value - big endian
+**
 **		s   - string preceded by a little endian four byte length
 **		S   - string preceded by a big endian four byte length
-**		b	- binary data (see below)
 **
+**		f	- little endian 32 bit float
+**		F   - big endian 32 bit float
+**
+**		B	- binary data (see below)
+**		z   - zero bytes (se below)
+**
 **	To write a word followed by a long (both little endian) use:
-**		psf_hprintf ("wl", wordval, longval) ;
+**		psf_binheader_writef ("wl", wordval, longval) ;
 **
 **	To write binary data use:
-**		psf_hprintf ("b", &bindata, sizeof (bindata)) ;
+**		psf_binheader_writef ("B", &bindata, sizeof (bindata)) ;
+**
+**	To write N zero bytes use:
+**		psf_binheader_writef ("z", N) ;
 */
 
 /* These macros may seem a bit messy but do prevent problems with processors which 
@@ -170,20 +222,25 @@
 */
 
 #if (CPU_IS_BIG_ENDIAN == 1)
-#define	put_int(psf,x)		{	(psf)->header [(psf)->headindex++] = ((x) >> 24) & 0xFF ;		\
+#define	PUT_INT(psf,x)		if ((psf)->headindex < sizeof ((psf)->header) - 4)					\
+							{	(psf)->header [(psf)->headindex++] = ((x) >> 24) & 0xFF ;		\
 								(psf)->header [(psf)->headindex++] = ((x) >> 16) & 0xFF ;		\
 								(psf)->header [(psf)->headindex++] = ((x) >>  8) & 0xFF ;		\
 								(psf)->header [(psf)->headindex++] = (x) & 0xFF ;   }
-                                                                        
-#define	put_short(psf,x)	{	(psf)->header [(psf)->headindex++] = ((x) >> 8) & 0xFF ;		\
+								                                                                   
+#define	PUT_SHORT(psf,x)	if ((psf)->headindex < sizeof ((psf)->header) - 2)					\
+							{	(psf)->header [(psf)->headindex++] = ((x) >> 8) & 0xFF ;		\
 								(psf)->header [(psf)->headindex++] = (x) & 0xFF ;   }
+
 #elif (CPU_IS_LITTLE_ENDIAN == 1)
-#define	put_int(psf,x)		{	(psf)->header [(psf)->headindex++] = (x) & 0xFF ;				\
+#define	PUT_INT(psf,x)		if ((psf)->headindex < sizeof ((psf)->header) - 4)					\
+							{	(psf)->header [(psf)->headindex++] = (x) & 0xFF ;				\
 								(psf)->header [(psf)->headindex++] = ((x) >>  8) & 0xFF ;		\
 								(psf)->header [(psf)->headindex++] = ((x) >> 16) & 0xFF ;		\
 								(psf)->header [(psf)->headindex++] = ((x) >> 24) & 0xFF ;   }
                                                                         
-#define	put_short(psf,x)	{	(psf)->header [(psf)->headindex++] = (x) & 0xFF ;				\
+#define	PUT_SHORT(psf,x)	if ((psf)->headindex < sizeof ((psf)->header) - 2)					\
+							{	(psf)->header [(psf)->headindex++] = (x) & 0xFF ;				\
 								(psf)->header [(psf)->headindex++] = ((x) >> 8) & 0xFF ;   }
 
 #else
@@ -190,13 +247,18 @@
 #       error "Cannot determine endian-ness of processor."
 #endif
 
-void	psf_hprintf (SF_PRIVATE *psf, char *format, ...)
+#define	PUT_BYTE(psf,x)		if ((psf)->headindex < sizeof ((psf)->header) - 1)					\
+							{	(psf)->header [(psf)->headindex++] = (x) & 0xFF ;   }
+
+int
+psf_binheader_writef (SF_PRIVATE *psf, char *format, ...)
 {	va_list	argptr ;
-	unsigned int 	longdata ;
-	unsigned short	worddata ;
-	void	*bindata ;
-	size_t	size ;
-	char    c, *strptr ;
+	unsigned int 	data ;
+	float			floatdata ;
+	void			*bindata ;
+	size_t			size ;
+	char    		c, *strptr ;
+	int				count = 0 ;
 	
 	va_start(argptr, format);
 	
@@ -203,165 +265,419 @@
 	while ((c = *format++))
 	{	switch (c)
 		{	case 'm' : 
-					longdata = va_arg (argptr, unsigned int) ;
-					put_int (psf, longdata) ;
+					data = va_arg (argptr, unsigned int) ;
+					PUT_INT (psf, data) ;
+					count += 4 ;
 					break ;
 					
-			case 'l' :
-					longdata = va_arg (argptr, unsigned int) ;
-					longdata = H2LE_INT (longdata) ;
-					put_int (psf, longdata) ;
+			case 'b' :
+					data = va_arg (argptr, unsigned int) ;
+					PUT_BYTE (psf, data) ;
+					count += 1 ;
 					break ;
-
-			case 'L' :
-					longdata = va_arg (argptr, unsigned int) ;
-					longdata = H2BE_INT (longdata) ;
-					put_int (psf, longdata) ;
-					break ;
 					
 			case 'w' :
-					worddata = va_arg (argptr, int) & 0xFFFF ;
-					worddata = H2LE_SHORT (worddata) ;
-					put_short (psf, worddata) ;
+					data = va_arg (argptr, unsigned int) ;
+					data = H2LE_SHORT (data) ;
+					PUT_SHORT (psf, data) ;
+					count += 2 ;
 					break ;
 
 			case 'W' :
-					worddata = va_arg (argptr, int) & 0xFFFF ;
-				worddata = H2BE_SHORT (worddata) ;
-					put_short (psf, worddata) ;
+					data = va_arg (argptr, unsigned int) ;
+					data = H2BE_SHORT (data) ;
+					PUT_SHORT (psf, data) ;
+					count += 2 ;
 					break ;
 					
-			case 'b' :
-					bindata = va_arg (argptr, void *) ;
-					size    = va_arg (argptr, size_t) ;
-					memcpy (&(psf->header [psf->headindex]), bindata, size) ;
-					psf->headindex += size ;
+			case 'l' :
+					data = va_arg (argptr, unsigned int) ;
+					data = H2LE_INT (data) ;
+					PUT_INT (psf, data) ;
+					count += 4 ;
 					break ;
-					
+
+			case 'L' :
+					data = va_arg (argptr, unsigned int) ;
+					data = H2BE_INT (data) ;
+					PUT_INT (psf, data) ;
+					count += 4 ;
+					break ;
+
+			case 'f' :
+					floatdata = (float) va_arg (argptr, double) ;
+					float32_write (floatdata, (unsigned char *) &data) ;
+					data = H2LE_INT (data) ;
+					PUT_INT (psf, data) ;
+					count += 4 ;
+					break ;
+
+			case 'F' :
+					floatdata = (float) va_arg (argptr, double) ;
+					float32_write (floatdata, (unsigned char *) &data) ;
+					data = H2BE_INT (data) ;
+					PUT_INT (psf, data) ;
+					count += 4 ;
+					break ;
+
 			case 's' :
 					strptr = va_arg (argptr, char *) ;
-					size    = strlen (strptr) + 1 ;
-					size   += (size & 1) ;
-					longdata = H2LE_INT (size) ;
-					put_int (psf, longdata) ;
+					size   = strlen (strptr) + 1 ;
+					size  += (size & 1) ;
+					data = H2LE_INT (size) ;
+					PUT_INT (psf, data) ;
 					memcpy (&(psf->header [psf->headindex]), strptr, size) ;
 					psf->headindex += size ;
+					count += 4 + size ;
 					break ;
 					
 			case 'S' :
 					strptr = va_arg (argptr, char *) ;
-					size    = strlen (strptr) + 1 ;
-					size   += (size & 1) ;
-					longdata = H2BE_INT (size) ;
-					put_int (psf, longdata) ;
+					size   = strlen (strptr) + 1 ;
+					size  += (size & 1) ;
+					data = H2BE_INT (size) ;
+					PUT_INT (psf, data) ;
 					memcpy (&(psf->header [psf->headindex]), strptr, size) ;
 					psf->headindex += size ;
+					count += 4 + size ;
 					break ;
 					
-			default : break ;
+			case 'B' :
+					bindata = va_arg (argptr, void *) ;
+					size    = va_arg (argptr, size_t) ;
+					memcpy (&(psf->header [psf->headindex]), bindata, size) ;
+					psf->headindex += size ;
+					count += size ;
+					break ;
+					
+			case 'z' :
+					size    = va_arg (argptr, size_t) ;
+					count += size ;
+					while (size)
+					{	psf->header [psf->headindex] = 0 ;
+						psf->headindex ++ ;
+						size -- ;
+						} ;
+					break ;
+					
+			default : 
+				psf_log_printf (psf, "*** Invalid format specifier `%c'\n", c) ;
+				psf->error = SFE_INTERNAL ; 
+				break ;
 			} ;
 		} ;
 	
 	va_end(argptr);
-	return ;
-} /* psf_hprintf */
+	return count ;
+} /* psf_binheader_writef */
 
-
 /*-----------------------------------------------------------------------------------------------
+**  Binary header reading functions. Returns number of bytes read.
+**
+**	Format specifiers are the same as for header write function above with the following
+**	additions:
+**
+**		p   - jump a given number of position from start of file.
+**
+**	If format is NULL, psf_binheader_readf returns the current offset.
 */
 
-void	psf_hsetf (SF_PRIVATE *psf, unsigned int marker, char *format, ...)
-{	va_list	argptr ;
-	unsigned int 	longdata, oldheadindex ;
-	unsigned short	worddata ;
-	void	*bindata ;
-	size_t	size ;
-	char    c, *strptr ;
-	
-	/* Save old head index. */
-	oldheadindex = psf->headindex ;
-	psf->headindex = 0 ;
-	
-	/* Find the marker. */
-	while (psf->headindex < oldheadindex)
-	{	if (*((unsigned int*) &(psf->header[psf->headindex])) == marker)
-			break ;
-		psf->headindex += 4 ;
-		} ;
-		
-	/* If not found return. */
-	if (psf->headindex >= oldheadindex)
-		return ;
+#if (CPU_IS_BIG_ENDIAN == 1)
+#define	GET_INT(psf)	( ((psf)->header [0] << 24) + ((psf)->header [1] << 16) +	\
+						  ((psf)->header [2] <<  8) + ((psf)->header [3]) )
 
-	/* Move past marker. */
-	psf->headindex += 4 ;
+#define	GET_3BYTE(psf)	( ((psf)->header [0] << 16) + ((psf)->header [1] << 8) +	\
+						  ((psf)->header [2]) )
 
+#define	GET_SHORT(psf)	( ((psf)->header [0] <<  8) + ((psf)->header [1]) )
+
+#elif (CPU_IS_LITTLE_ENDIAN == 1)
+#define	GET_INT(psf)	( ((psf)->header [0]      ) + ((psf)->header [1] <<  8) +	\
+						  ((psf)->header [2] << 16) + ((psf)->header [3] << 24) )
+
+#define	GET_3BYTE(psf)	( ((psf)->header [0]      ) + ((psf)->header [1] <<  8) +	\
+						  ((psf)->header [2] << 16) )
+
+#define	GET_SHORT(psf)	( ((psf)->header [0]) + ((psf)->header [1] <<  8) )
+
+#else
+#       error "Cannot determine endian-ness of processor."
+#endif
+
+#define	GET_BYTE(psf)	( (psf)->header [0] )
+
+int
+psf_binheader_readf (SF_PRIVATE *psf, char const *format, ...)
+{	va_list	argptr ;
+	unsigned int 	*longptr, longdata ;
+	unsigned short	*wordptr, worddata ;
+	char    		*charptr ;
+	int				position ;
+	float			*floatptr ;
+	size_t			size ;
+	char			c ;
+	int				count = 0 ;
+	
+	if (! format)
+		return ftell (psf->file) ;
+			
 	va_start(argptr, format);
 	
 	while ((c = *format++))
 	{	switch (c)
 		{	case 'm' : 
-					longdata = va_arg (argptr, unsigned int) ;
-					put_int (psf, longdata) ;
+					longptr = va_arg (argptr, unsigned int*) ;
+					fread (psf->header, 1, sizeof (int), psf->file) ;
+					*longptr = GET_INT (psf) ;
+					count += 4 ;
 					break ;
 					
-			case 'l' :
-					longdata = va_arg (argptr, unsigned int) ;
-					longdata = H2LE_INT (longdata) ;
-					put_int (psf, longdata) ;
+			case 'b' :
+					charptr = va_arg (argptr, char*) ;
+					fread (psf->header, 1, sizeof (char), psf->file) ;
+					*charptr = GET_BYTE (psf) ;
+					count += 1 ;
 					break ;
-
-			case 'L' :
-					longdata = va_arg (argptr, unsigned int) ;
-					longdata = H2BE_INT (longdata) ;
-					put_int (psf, longdata) ;
-					break ;
 					
 			case 'w' :
-					worddata = va_arg (argptr, int) & 0xFFFF ;
-				worddata = H2LE_SHORT (worddata) ;
-					put_short (psf, worddata) ;
+					wordptr = va_arg (argptr, unsigned short*) ;
+					fread (psf->header, 1, sizeof (short), psf->file) ;
+					worddata = GET_SHORT (psf) ;
+					*wordptr = H2LE_SHORT (worddata) ;
+					count += 2 ;
 					break ;
 
 			case 'W' :
-					worddata = va_arg (argptr, int) & 0xFFFF ;
-					worddata = H2BE_SHORT (worddata) ;
-					put_short (psf, worddata) ;
+					wordptr = va_arg (argptr, unsigned short*) ;
+					fread (psf->header, 1, sizeof (short), psf->file) ;
+					worddata = GET_SHORT (psf) ;
+					*wordptr = H2BE_SHORT (worddata) ;
+					count += 2 ;
 					break ;
 					
-			case 'b' :
-					bindata = va_arg (argptr, void *) ;
-					size    = va_arg (argptr, size_t) ;
-					memcpy (&(psf->header [psf->headindex]), bindata, size) ;
-					psf->headindex += size ;
+			case 'l' :
+					longptr = va_arg (argptr, unsigned int*) ;
+					fread (psf->header, 1, sizeof (int), psf->file) ;
+					longdata = GET_INT (psf) ;
+					*longptr = H2LE_INT (longdata) ;
+					count += 4 ;
 					break ;
-					
+
+			case 'L' :
+					longptr = va_arg (argptr, unsigned int*) ;
+					fread (psf->header, 1, sizeof (int), psf->file) ;
+					longdata = GET_INT (psf) ;
+					*longptr = H2BE_INT (longdata) ;
+					count += 4 ;
+					break ;
+
+			case 't' :
+					longptr = va_arg (argptr, unsigned int*) ;
+					fread (psf->header, 1, 3, psf->file) ;
+					longdata = GET_3BYTE (psf) ;
+					*longptr = H2LE_INT (longdata) ;
+					count += 3 ;
+					break ;
+
+			case 'T' :
+					longptr = va_arg (argptr, unsigned int*) ;
+					fread (psf->header, 1, 3, psf->file) ;
+					longdata = GET_3BYTE (psf) ;
+					*longptr = H2BE_INT (longdata) ;
+					count += 3 ;
+					break ;
+
+			case 'f' :
+					floatptr = va_arg (argptr, float *) ;
+					fread (psf->header, 1, sizeof (float), psf->file) ;
+					longdata = GET_INT (psf) ;
+					longdata = H2LE_INT (longdata) ;
+					*floatptr = float32_read ((unsigned char*) &longdata) ;
+					count += 4 ;
+					break ;
+
+			case 'F' :
+					floatptr = va_arg (argptr, float *) ;
+					fread (psf->header, 1, sizeof (float), psf->file) ;
+					longdata = GET_INT (psf) ;
+					longdata = H2BE_INT (longdata) ;
+					*floatptr = float32_read ((unsigned char*) &longdata) ;
+					count += 4 ;
+					break ;
+
 			case 's' :
+					printf ("Format conversion not implemented yet.\n") ;
+					/*
 					strptr = va_arg (argptr, char *) ;
-					size    = strlen (strptr) + 1 ;
-					size   += (size & 1) ;
+					size   = strlen (strptr) + 1 ;
+					size  += (size & 1) ;
 					longdata = H2LE_INT (size) ;
-					put_int (psf, longdata) ;
+					get_int (psf, longdata) ;
 					memcpy (&(psf->header [psf->headindex]), strptr, size) ;
 					psf->headindex += size ;
+					*/
 					break ;
 					
 			case 'S' :
+					printf ("Format conversion not implemented yet.\n") ;
+					/*
 					strptr = va_arg (argptr, char *) ;
-					size    = strlen (strptr) + 1 ;
-					size   += (size & 1) ;
+					size   = strlen (strptr) + 1 ;
+					size  += (size & 1) ;
 					longdata = H2BE_INT (size) ;
-					put_int (psf, longdata) ;
+					get_int (psf, longdata) ;
 					memcpy (&(psf->header [psf->headindex]), strptr, size) ;
 					psf->headindex += size ;
+					*/
 					break ;
 					
-			default : break ;
+			case 'B' :
+					charptr = va_arg (argptr, char*) ;
+					size = va_arg (argptr, size_t) ;
+					if (size > 0)
+					{	memset (charptr, 0, size) ;
+						fread (charptr, 1, size, psf->file) ;
+						count += size ;
+						} ;
+					break ;
+					
+			case 'z' :
+					printf ("Format conversion not implemented yet.\n") ;
+					/*
+					size    = va_arg (argptr, size_t) ;
+					while (size)
+					{	psf->header [psf->headindex] = 0 ;
+						psf->headindex ++ ;
+						size -- ;
+						} ;
+					*/
+					break ;
+					
+			case 'p' :
+					/* Get the seek position first. */ 
+					position = va_arg (argptr, int) ;
+					fseek (psf->file, position, SEEK_SET) ;
+					count = 0 ;
+					break ;
+
+			case 'j' :
+					/* Get the seek position first. */ 
+					position = va_arg (argptr, int) ;
+					fseek (psf->file, position, SEEK_CUR) ;
+					count = 0 ;
+					break ;
+
+			default :
+				psf_log_printf (psf, "*** Invalid format specifier `%c'\n", c) ;
+				psf->error = SFE_INTERNAL ; 
+				break ;
 			} ;
 		} ;
 	
-	va_end(argptr);
+	va_end (argptr);
 	
-	psf->headindex = oldheadindex ;
-	return ;
-} /* psf_hsetf */
+	return count ;
+} /* psf_binheader_readf */
+
+/*-----------------------------------------------------------------------------------------------
+*/
+
+void
+psf_log_SF_INFO (SF_PRIVATE *psf)
+{	psf_log_printf (psf, "---------------------------------\n") ;
+
+	psf_log_printf (psf, " Sample rate :   %d\n", psf->sf.samplerate) ;
+	psf_log_printf (psf, " Samples     :   %d\n", psf->sf.samples) ;
+	psf_log_printf (psf, " Channels    :   %d\n", psf->sf.channels) ;
+
+	psf_log_printf (psf, " Bit width   :   %d\n", psf->sf.pcmbitwidth) ;
+	psf_log_printf (psf, " Format      :   %X\n", psf->sf.format) ;
+	psf_log_printf (psf, " Sections    :   %d\n", psf->sf.sections) ;
+	psf_log_printf (psf, " Seekable    :   %s\n", psf->sf.seekable ? "TRUE" : "FALSE") ;
+	
+	psf_log_printf (psf, "---------------------------------\n") ;
+} /* psf_dump_SFINFO */ 
+
+/*========================================================================================
+**	Functions used in the write function for updating the peak chunk. 
+*/
+
+/*-void	
+peak_update_short	(SF_PRIVATE *psf, short *ptr, size_t items)
+{	int		chan, k, position ;
+	short	maxval ;
+	float	fmaxval ;
+	
+	for (chan = 0 ; chan < psf->sf.channels ; chan++)
+	{	maxval = abs (ptr [chan]) ;
+		position = 0 ;
+		for (k = chan ; k < items ; k += psf->sf.channels)
+			if (maxval < abs (ptr [k]))
+			{	maxval = abs (ptr [k]) ;
+				position = k ;
+				} ;
+				
+		fmaxval   = maxval / 32767.0 ;
+		position /= psf->sf.channels ;
+		
+		if (fmaxval > psf->peak.peak[chan].value)
+		{	psf->peak.peak[chan].value = fmaxval ;
+			psf->peak.peak[chan].position = psf->current - position ;
+			} ;
+		} ;
+	
+	return ;		
+} /+* peak_update_short *+/
+
+void	
+peak_update_int		(SF_PRIVATE *psf, int *ptr, size_t items)
+{	int		chan, k, position ;
+	int		maxval ;
+	float	fmaxval ;
+	
+	for (chan = 0 ; chan < psf->sf.channels ; chan++)
+	{	maxval = abs (ptr [chan]) ;
+		position = 0 ;
+		for (k = chan ; k < items ; k += psf->sf.channels)
+			if (maxval < abs (ptr [k]))
+			{	maxval = abs (ptr [k]) ;
+				position = k ;
+				} ;
+				
+		fmaxval   = maxval / 0x7FFFFFFF ;
+		position /= psf->sf.channels ;
+		
+		if (fmaxval > psf->peak.peak[chan].value)
+		{	psf->peak.peak[chan].value = fmaxval ;
+			psf->peak.peak[chan].position = psf->current - position ;
+			} ;
+		} ;
+	
+	return ;		
+} /+* peak_update_int *+/
+
+void	
+peak_update_double	(SF_PRIVATE *psf, double *ptr, size_t items)
+{	int		chan, k, position ;
+	double	fmaxval ;
+	
+	for (chan = 0 ; chan < psf->sf.channels ; chan++)
+	{	fmaxval = fabs (ptr [chan]) ;
+		position = 0 ;
+		for (k = chan ; k < items ; k += psf->sf.channels)
+			if (fmaxval < fabs (ptr [k]))
+			{	fmaxval = fabs (ptr [k]) ;
+				position = k ;
+				} ;
+
+		position /= psf->sf.channels ;
+		
+		if (fmaxval > psf->peak.peak[chan].value)
+		{	psf->peak.peak[chan].value = fmaxval ;
+			psf->peak.peak[chan].position = psf->current - position ;
+			} ;
+		} ;
+	
+	return ;		
+} /+* peak_update_double *+/
+-*/
--- a/common/libsndfile/src/common.h
+++ b/common/libsndfile/src/common.h
@@ -1,18 +1,18 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
+**  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
 ** the Free Software Foundation; either version 2.1 of the License, or
 ** (at your option) any later version.
-**
+** 
 ** This program is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU Lesser General Public License for more details.
-**
+** 
 ** You should have received a copy of the GNU Lesser General Public License
-** along with this program; if not, write to the Free Software
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
@@ -24,74 +24,163 @@
 #endif
 
 
-#define	SF_BUFFER_LEN		(4096)
-#define	SF_FILENAME_LEN		(256)
-#define	SF_HEADER_LEN		(2048)
+#define	SF_BUFFER_LEN			(4096)
+#define	SF_FILENAME_LEN			(256)
+#define	SF_HEADER_LEN			(2048)
+#define	SF_TEXT_LEN				(1024)
 
 #define		BITWIDTH2BYTES(x)	(((x) + 7) / 8)
 
+#define		PEAK_CHANNEL_COUNT	16
+
 enum
-{	SF_MODE_READ = 1,
-	SF_MODE_WRITE = 2,
-	SF_MODE_RW = 3
-} ;
+{	SF_MODE_READ		= 11, 
+	SF_MODE_WRITE		= 12,
+	SF_MODE_RW			= 13,	/* Unlikely that RW will ever be implemented. */ 
+	
+	/* PEAK chunk location. */
+	SF_PEAK_START		= 42,
+	SF_PEAK_END			= 43,
 
+	/* Two endian enums. */
+	SF_ENDIAN_LITTLE	= 100, 
+	SF_ENDIAN_BIG		= 101,
+	
+	/* Char type for 8 bit files. */
+	SF_CHARS_SIGNED		= 200,
+	SF_CHARS_UNSIGNED	= 201
+} ; 
+
+/*	Processor floating point capabilities. float32_get_capabilities () in
+**	src/float32.c returns one of the latter three values.
+*/
 enum
-{	SF_ENDIAN_LITTLE = 100,
-	SF_ENDIAN_BIG = 200
+{	FLOAT_UNKNOWN		= 0x00,
+	FLOAT_CAN_RW_LE		= 0x23,
+	FLOAT_CAN_RW_BE		= 0x34,
+	FLOAT_BROKEN_LE		= 0x35,
+	FLOAT_BROKEN_BE		= 0x36
 } ;
 
 enum
-{	SF_FALSE = 0,
+{	SF_FALSE = 0, 
 	SF_TRUE = 1
+} ; 
+
+/* Command values for sf_command (). These are obtained using the Python
+** script sf_command.py in the top level directory of the libsndfile sources.
+*/
+enum
+{	SFC_LIB_VERSION	= 0x1048C,
+	SFC_READ_TEXT	= 0x054F0,
+	SFC_WRITE_TEXT	= 0x0B990,
+	SFC_NORM_FLOAT	= 0x0914A,
+	SFC_NORM_DOUBLE	= 0x1226D,
+	SFC_SCALE_MODE	= 0x0A259,
+	SFC_ADD_PEAK	= 0x96F53
 } ;
 
-typedef	int	(*func_seek) 	(void*, int, int) ;
+/*	Function pointer typedefs. */
 
+typedef	int	(*func_seek) 	(void*, long, int) ;
+
 typedef	int	(*func_short)	(void*, short *ptr, unsigned int len) ;
 typedef	int	(*func_int)		(void*, int *ptr, unsigned int len) ;
+typedef	int	(*func_float)	(void*, float *ptr, unsigned int len) ;
 typedef	int	(*func_double)	(void*, double *ptr, unsigned int len, int normalize) ;
 
+typedef	int	(*func_wr_hdr)	(void*) ;
+typedef	int	(*func_command)	(void*, int command, void *data, int datasize) ;
+
 typedef	int	(*func_close)	(void*) ;
 
+/*---------------------------------------------------------------------------------------
+**	PEAK_CHUNK - This chunk type is common to both AIFF and WAVE files although their 
+**	endian encodings are different. 
+*/
+
+typedef struct 
+{	float        value ;    	/* signed value of peak */ 
+	unsigned int position ; 	/* the sample frame for the peak */ 
+} PEAK_POS ; 
+
+typedef struct 
+{	unsigned int  version ;						/* version of the PEAK chunk */ 
+	unsigned int  timestamp ;					/* secs since 1/1/1970  */ 
+	PEAK_POS      peak [PEAK_CHANNEL_COUNT] ;	/* the peak info */ 
+} PEAK_CHUNK ; 
+
+/*=======================================================================================
+**	SF_PRIVATE stuct - a pointer to this struct is passed back to the caller of the
+**	sf_open_XXXX functions. The caller however has no knowledge of the struct's
+**	contents. 
+*/
+
 typedef struct
 {	/* Force the compiler to double align the start of buffer. */
 	double			buffer		[SF_BUFFER_LEN/sizeof(double)] ;
-	char			strbuffer	[SF_BUFFER_LEN] ;
 	char			filename	[SF_FILENAME_LEN] ;
-	char			header		[SF_HEADER_LEN] ;
+
+	/* logbuffer and logindex should only be changed within the logging functions 
+	** of common.c
+	*/
+	char			logbuffer	[SF_BUFFER_LEN] ;
+	unsigned char	header		[SF_HEADER_LEN] ;
+
+	/* For storing text from header. */
+	char			headertext	[SF_TEXT_LEN] ;
+	
+	/* Guard value. If this changes the buffers above have overflowed. */ 
 	int				Magick ;
-	unsigned int	strindex ;
-	unsigned int	headindex ;
+	
+	/* Index variables for maintaining logbuffer and header above. */
+	unsigned int	logindex ;
+	unsigned int	headindex, headcurrent ;
+	int				has_text ;
+	
 	FILE 			*file ;
-	int				mode ;
 	int				error ;
-	int				endian ;
+	
+	int				mode ;			/* Open mode : SF_MODE_READ or SF_MODE_WRITE. */
+	int				endian ;		/* File endianness : SF_ENDIAN_LITTLE or SF_ENDIAN_BIG. */
+	int				chars ;			/* Chars are SF_CHARS_SIGNED or SF_CHARS_UNSIGNED. */
+	int				fl32_endswap ;	/* Need to endswap float32s? */
+	
+	SF_INFO			sf ; 	
 
-	SF_INFO			sf ;
+	int				has_peak ;		/* Has a PEAK chunk (AIFF and WAVE) been read? */
+	int				peak_loc ;		/* Write a PEAK chunk at the start or end of the file? */
+	PEAK_CHUNK		peak ;			
+	
+	long			dataoffset ;	/* Offset in number of bytes from beginning of file. */
+	long			datalength ;	/* Length in bytes of the audio data. */
+	long			tailstart ;		/* Offset to file tailer. */
+	unsigned int	blockwidth ;	/* Size in bytes of one set of interleaved samples. */
+	unsigned int	bytewidth ;		/* Size in bytes of one sample (one channel). */
 
-	long			dataoffset ;		/* Offset in number of bytes from beginning of file. */
-	long			datalength ;		/* Length in bytes of the audio data. */
-	unsigned int	blockwidth ;		/* Size in bytes of one set of interleaved samples. */
-	unsigned int	bytewidth ;			/* Size in bytes of one sample (one channel). */
-
 	long			filelength ;
 	long			current ;
 
 	void			*fdata ;
+	
+	int				scale_mode ;
+	int				norm_double ;
+	int				norm_float ;
 
-	double			normfactor ;
-
 	func_seek		seek_func ;
 
 	func_short		read_short ;
 	func_int		read_int ;
+	func_float		read_float ;
 	func_double		read_double ;
 
 	func_short		write_short ;
 	func_int		write_int ;
+	func_float		write_float ;
 	func_double		write_double ;
 
+	func_wr_hdr		write_header ;
+	func_command	command ;
 	func_close		close ;
 
 } SF_PRIVATE ;
@@ -106,8 +195,8 @@
 	SFE_BAD_SF_INFO_PTR,
 	SFE_BAD_INT_FD,
 	SFE_BAD_INT_PTR,
-	SFE_MALLOC_FAILED,
-	SFE_BAD_SEEK,
+	SFE_MALLOC_FAILED, 
+	SFE_BAD_SEEK, 
 	SFE_NOT_SEEKABLE,
 	SFE_UNIMPLEMENTED,
 	SFE_BAD_READ_ALIGN,
@@ -120,12 +209,16 @@
 	SFE_SHORT_READ,
 	SFE_SHORT_WRITE,
 	SFE_INTERNAL,
-
+	SFE_BAD_CONTROL_CMD,
+	
 	SFE_WAV_NO_RIFF,
 	SFE_WAV_NO_WAVE,
 	SFE_WAV_NO_FMT,
 	SFE_WAV_FMT_SHORT,
 	SFE_WAV_FMT_TOO_BIG,
+	SFE_WAV_BAD_FACT,
+	SFE_WAV_BAD_PEAK,
+	SFE_WAV_PEAK_B4_FMT,
 	SFE_WAV_BAD_FORMAT,
 	SFE_WAV_BAD_BLOCKALIGN,
 	SFE_WAV_NO_DATA,
@@ -135,65 +228,145 @@
 	SFE_WAV_UNKNOWN_CHUNK,
 
 	SFE_AIFF_NO_FORM,
+	SFE_AIFF_AIFF_NO_FORM,
+	SFE_AIFF_COMM_NO_FORM,
+	SFE_AIFF_SSND_NO_COMM,
 	SFE_AIFF_UNKNOWN_CHUNK,
-	SFE_COMM_CHUNK_SIZE,
+	SFE_AIFF_COMM_CHUNK_SIZE,
+	SFE_AIFF_BAD_COMM_CHUNK,
+	SFE_AIFF_PEAK_B4_COMM,
+	SFE_AIFF_BAD_PEAK,
 	SFE_AIFF_NO_SSND,
 	SFE_AIFF_NO_DATA,
 
 	SFE_AU_UNKNOWN_FORMAT,
 	SFE_AU_NO_DOTSND,
-
+	
 	SFE_RAW_READ_BAD_SPEC,
 	SFE_RAW_BAD_BITWIDTH,
-
+	
 	SFE_PAF_NO_MARKER,
 	SFE_PAF_VERSION,
 	SFE_PAF_UNKNOWN_FORMAT,
 	SFE_PAF_SHORT_HEADER,
-
-	SFE_SVX_NO_FORM,
+	
+	SFE_SVX_NO_FORM, 
 	SFE_SVX_NO_BODY,
 	SFE_SVX_NO_DATA,
-	SFE_SVX_BAD_COMP,
+	SFE_SVX_BAD_COMP, 	
 
 	SFE_NIST_BAD_HEADER,
 	SFE_NIST_BAD_ENCODING,
 
+	SFE_SMTD_NO_SEKD, 
+	SFE_SMTD_NO_SAMR, 
+
+	SFE_VOC_NO_CREATIVE, 
+	SFE_VOC_BAD_VERSION, 
+	SFE_VOC_BAD_MARKER, 
+
+	SFE_IRCAM_NO_MARKER,
+	SFE_IRCAM_BAD_CHANNELS,
+	SFE_IRCAM_UNKNOWN_FORMAT,
+
 	SFE_MAX_ERROR			/* This must be last in list. */
 } ;
 
+/* Get the float32 capability of the processor at run time.
+**	Implemented in src/float32.c.
+*/
+int		float32_get_capability (int endianness) ;
+float	float32_read  (unsigned char *cptr) ;
+void	float32_write (float in, unsigned char *out) ;
+
+
+/* Endian swapping routines implemented in src/common.h. */
+
 void	endswap_short_array	(short *ptr, int len) ;
 void	endswap_int_array 	(int *ptr, int len) ;
 
-void	psf_sprintf		(SF_PRIVATE *psf, char *format, ...) ;
-void	psf_hprintf		(SF_PRIVATE *psf, char *format, ...) ;
-void	psf_hsetf			(SF_PRIVATE *psf, unsigned int marker, char *format, ...) ;
+/* Functions for writing to the internal logging buffer. */
 
+void	psf_log_printf		(SF_PRIVATE *psf, char *format, ...) ;
+void	psf_log_SF_INFO 		(SF_PRIVATE *psf) ;
+
+/* Functions used when writing file headers. */
+
+int		psf_binheader_writef	(SF_PRIVATE *psf, char *format, ...) ;
+void	psf_asciiheader_printf	(SF_PRIVATE *psf, char *format, ...) ;
+
+/* Functions used when reading file headers. */
+
+int		psf_binheader_readf	(SF_PRIVATE *psf, char const *format, ...) ;
+
+/* Functions used in the write function for updating the peak chunk. */
+
+void	peak_update_short	(SF_PRIVATE *psf, short *ptr, size_t items) ;
+void	peak_update_int		(SF_PRIVATE *psf, int *ptr, size_t items) ;
+void	peak_update_double	(SF_PRIVATE *psf, double *ptr, size_t items) ;
+
+/* Init functions for a number of common data encodings. */
+
+int 	pcm_read_init  (SF_PRIVATE *psf) ;
+int 	pcm_write_init (SF_PRIVATE *psf) ;
+
+int 	ulaw_read_init  (SF_PRIVATE *psf) ;
+int 	ulaw_write_init (SF_PRIVATE *psf) ;
+
+int 	alaw_read_init  (SF_PRIVATE *psf) ;
+int 	alaw_write_init (SF_PRIVATE *psf) ;
+
+int 	float32_read_init  (SF_PRIVATE *psf) ;
+int 	float32_write_init (SF_PRIVATE *psf) ;
+
+/* Functions for reading and writing different file formats.*/
+
 int		aiff_open_read	(SF_PRIVATE *psf) ;
 int		aiff_open_write	(SF_PRIVATE *psf) ;
 
-int		au_open_read		(SF_PRIVATE *psf) ;
-int		au_nh_open_read	(SF_PRIVATE *psf) ;
-int		au_open_write		(SF_PRIVATE *psf) ;
+int		au_open_read	(SF_PRIVATE *psf) ;
+int		au_nh_open_read	(SF_PRIVATE *psf) ;	/* Headerless version of AU. */
+int		au_open_write	(SF_PRIVATE *psf) ;
 
-int		wav_open_read		(SF_PRIVATE *psf) ;
+int		wav_open_read	(SF_PRIVATE *psf) ;
 int		wav_open_write	(SF_PRIVATE *psf) ;
 
-int		raw_open_read		(SF_PRIVATE *psf) ;
+int		raw_open_read	(SF_PRIVATE *psf) ;
 int		raw_open_write	(SF_PRIVATE *psf) ;
 
-int		paf_open_read		(SF_PRIVATE *psf) ;
+int		paf_open_read	(SF_PRIVATE *psf) ;
 int		paf_open_write	(SF_PRIVATE *psf) ;
 
-int		svx_open_read		(SF_PRIVATE *psf) ;
+int		svx_open_read	(SF_PRIVATE *psf) ;
 int		svx_open_write	(SF_PRIVATE *psf) ;
 
-int		aunist_open_read	(SF_PRIVATE *psf) ;
-int		aunist_open_write	(SF_PRIVATE *psf) ;
+int		nist_open_read	(SF_PRIVATE *psf) ;
+int		nist_open_write	(SF_PRIVATE *psf) ;
 
+int		smpltd_open_read	(SF_PRIVATE *psf) ;
+int		smpltd_open_write	(SF_PRIVATE *psf) ;
 
+int		voc_open_read	(SF_PRIVATE *psf) ;
+int		voc_open_write	(SF_PRIVATE *psf) ;
+
+int		rx2_open_read	(SF_PRIVATE *psf) ;
+int		rx2_open_write	(SF_PRIVATE *psf) ;
+
+int		ircam_open_read		(SF_PRIVATE *psf) ;
+int		ircam_open_write	(SF_PRIVATE *psf) ;
+
+
+/*	Win32 does seem to have snprintf and vsnprintf but prepends
+**	the names with an underscore. Why?
+*/
+
+#ifdef	WIN32
+#define	snprintf	_snprintf
+#define	vsnprintf	_vsnprintf
+#endif
+
 #ifdef _WIN32
-//	#pragma pack(pop,1)
+	#pragma pack(pop,1)
 #endif
 
 #endif /* COMMON_H_INCLUDED */
--- a/common/libsndfile/src/config.h.in
+++ b/common/libsndfile/src/config.h.in
@@ -1,4 +1,4 @@
-/* src/config.h.in.  Generated automatically from configure.in by autoheader.  */
+/* src/config.h.in.  Generated automatically from configure.in by autoheader 2.13.  */
 
 /* Define to `long' if <sys/types.h> doesn't define.  */
 #undef off_t
@@ -24,9 +24,9 @@
 /* Set to 1 if the processor is little endian, otherwise set to 0.  */
 #undef GUESS_LITTLE_ENDIAN
 
-/* Set to 1 if the processor can read and write Intel x86 32 bit floats.  */
+/* Set to 1 to force the use of code for processors with broken floats */
 /* Otherwise set it to 0.  */
-#undef CAN_READ_WRITE_x86_IEEE
+#undef FORCE_BROKEN_FLOAT
 
 /* The number of bytes in a double.  */
 #undef SIZEOF_DOUBLE
@@ -45,6 +45,36 @@
 
 /* The number of bytes in a void*.  */
 #undef SIZEOF_VOIDP
+
+/* Define if you have the fclose function.  */
+#undef HAVE_FCLOSE
+
+/* Define if you have the fopen function.  */
+#undef HAVE_FOPEN
+
+/* Define if you have the fread function.  */
+#undef HAVE_FREAD
+
+/* Define if you have the free function.  */
+#undef HAVE_FREE
+
+/* Define if you have the fseek function.  */
+#undef HAVE_FSEEK
+
+/* Define if you have the ftell function.  */
+#undef HAVE_FTELL
+
+/* Define if you have the fwrite function.  */
+#undef HAVE_FWRITE
+
+/* Define if you have the malloc function.  */
+#undef HAVE_MALLOC
+
+/* Define if you have the snprintf function.  */
+#undef HAVE_SNPRINTF
+
+/* Define if you have the vsnprintf function.  */
+#undef HAVE_VSNPRINTF
 
 /* Define if you have the <endian.h> header file.  */
 #undef HAVE_ENDIAN_H
--- /dev/null
+++ b/common/libsndfile/src/float32.c
@@ -1,0 +1,968 @@
+/*
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
+**  
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU Lesser General Public License for more details.
+** 
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software 
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+#include	<stdio.h>
+#include	<unistd.h>
+#include	<string.h>
+#include	<math.h>
+
+#include	"sndfile.h"
+#include	"config.h"
+#include	"sfendian.h"
+#include	"common.h"
+
+/*--------------------------------------------------------------------------------------------
+*/
+
+/*--------------------------------------------------------------------------------------------
+**	Prototypes for private functions.
+*/
+
+static int		host_read_f2s   (SF_PRIVATE *psf, short *ptr, int len) ;
+static int		host_read_f2i   (SF_PRIVATE *psf, int *ptr, int len) ;
+static int		host_read_f     (SF_PRIVATE *psf, float *ptr, int len) ;
+static int		host_read_f2d   (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+
+static int		host_write_s2f   (SF_PRIVATE *psf, short *ptr, int len) ;
+static int		host_write_i2f   (SF_PRIVATE *psf, int *ptr, int len) ;
+static int		host_write_f     (SF_PRIVATE *psf, float *ptr, int len) ;
+static int		host_write_d2f   (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+
+static	void	f2s_array 	(float *buffer, unsigned int count, short *ptr, int index) ;
+static	void	f2i_array 	(float *buffer, unsigned int count, int *ptr, int index) ;
+static	void	f2d_array 	(float *buffer, unsigned int count, double *ptr, int index) ;
+
+static 	void	s2f_array 	(short *ptr, int index, float *buffer, unsigned int count) ;
+static 	void	i2f_array 	(int *ptr, int index, float *buffer, unsigned int count) ;
+static 	void	d2f_array 	(double *ptr, int index, float *buffer, unsigned int count) ;
+
+static void		float32_peak_update (SF_PRIVATE *psf, float *buffer, int count, int index) ;
+
+static int		broken_read_f2s (SF_PRIVATE *psf, short *ptr, int len) ;
+static int		broken_read_f2i (SF_PRIVATE *psf, int *ptr, int len) ;
+static int		broken_read_f   (SF_PRIVATE *psf, float *ptr, int len) ;
+static int		broken_read_f2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+
+static int		broken_write_s2f (SF_PRIVATE *psf, short *ptr, int len) ;
+static int		broken_write_i2f (SF_PRIVATE *psf, int *ptr, int len) ;
+static int		broken_write_f   (SF_PRIVATE *psf, float *ptr, int len) ;
+static int		broken_write_d2f (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+
+static	void	bf2f_array (float *buffer, unsigned int count) ;
+static	void	f2bf_array (float *buffer, unsigned int count) ;
+
+/*--------------------------------------------------------------------------------------------
+**	Exported functions.
+*/
+
+int
+float32_read_init (SF_PRIVATE *psf)
+{	static int float_caps = FLOAT_UNKNOWN ;
+
+	if (float_caps == FLOAT_UNKNOWN)
+		float_caps = float32_get_capability (psf->endian) ;
+	
+	switch (psf->endian + 0x1000 * float_caps)
+	{	case (SF_ENDIAN_BIG + 0x1000 * FLOAT_CAN_RW_BE) :
+				psf->fl32_endswap = SF_FALSE ;
+				psf->read_short  = (func_short)  host_read_f2s ;
+				psf->read_int    = (func_int)    host_read_f2i ;
+				psf->read_float  = (func_float)  host_read_f ;
+				psf->read_double = (func_double) host_read_f2d ;
+				break ;
+				
+		case (SF_ENDIAN_LITTLE + 0x1000 * FLOAT_CAN_RW_LE) :
+				psf->fl32_endswap = SF_FALSE ;
+				psf->read_short  = (func_short)  host_read_f2s ;
+				psf->read_int    = (func_int)    host_read_f2i ;
+				psf->read_float  = (func_float)  host_read_f ;
+				psf->read_double = (func_double) host_read_f2d ;
+				break ;
+
+		case (SF_ENDIAN_BIG + 0x1000 * FLOAT_CAN_RW_LE) :
+				psf->fl32_endswap = SF_TRUE ;
+				psf->read_short  = (func_short)  host_read_f2s ;
+				psf->read_int    = (func_int)    host_read_f2i ;
+				psf->read_float  = (func_float)  host_read_f ;
+				psf->read_double = (func_double) host_read_f2d ;
+				break ;
+				
+		case (SF_ENDIAN_LITTLE + 0x1000 * FLOAT_CAN_RW_BE) :
+				psf->fl32_endswap = SF_TRUE ;
+				psf->read_short  = (func_short)  host_read_f2s ;
+				psf->read_int    = (func_int)    host_read_f2i ;
+				psf->read_float  = (func_float)  host_read_f ;
+				psf->read_double = (func_double) host_read_f2d ;
+				break ;
+				
+		case (SF_ENDIAN_BIG + 0x1000 * FLOAT_BROKEN_LE) :
+				psf->fl32_endswap = SF_TRUE ;
+				psf->read_short  = (func_short)  broken_read_f2s ;
+				psf->read_int    = (func_int)    broken_read_f2i ;
+				psf->read_float  = (func_float)  broken_read_f ;
+				psf->read_double = (func_double) broken_read_f2d ;
+				break ;
+				
+		case (SF_ENDIAN_LITTLE + 0x1000 * FLOAT_BROKEN_LE) :
+				psf->fl32_endswap = SF_FALSE ;
+				psf->read_short  = (func_short)  broken_read_f2s ;
+				psf->read_int    = (func_int)    broken_read_f2i ;
+				psf->read_float  = (func_float)  broken_read_f ;
+				psf->read_double = (func_double) broken_read_f2d ;
+				break ;
+				
+		case (SF_ENDIAN_BIG + 0x1000 * FLOAT_BROKEN_BE) :
+				psf->fl32_endswap = SF_FALSE ;
+				psf->read_short  = (func_short)  broken_read_f2s ;
+				psf->read_int    = (func_int)    broken_read_f2i ;
+				psf->read_float  = (func_float)  broken_read_f ;
+				psf->read_double = (func_double) broken_read_f2d ;
+				break ;
+				
+		case (SF_ENDIAN_LITTLE + 0x1000 * FLOAT_BROKEN_BE) :
+				psf->fl32_endswap = SF_TRUE ;
+				psf->read_short  = (func_short)  broken_read_f2s ;
+				psf->read_int    = (func_int)    broken_read_f2i ;
+				psf->read_float  = (func_float)  broken_read_f ;
+				psf->read_double = (func_double) broken_read_f2d ;
+				break ;
+				
+		default : break ;
+		} ;
+
+	return 0 ;
+} /* float32_read_init */
+
+int
+float32_write_init (SF_PRIVATE *psf)
+{	static int float_caps = FLOAT_UNKNOWN ;
+
+	if (float_caps == FLOAT_UNKNOWN)
+		float_caps = float32_get_capability (psf->endian) ;
+	
+	switch (psf->endian + 0x1000 * float_caps)
+	{	case (SF_ENDIAN_LITTLE + 0x1000 * FLOAT_CAN_RW_LE) :
+				psf->fl32_endswap = SF_FALSE ;
+				psf->write_short  = (func_short)  host_write_s2f ;
+				psf->write_int    = (func_int)    host_write_i2f ;
+				psf->write_float  = (func_float)  host_write_f ;
+				psf->write_double = (func_double) host_write_d2f ;
+				break ;
+
+		case (SF_ENDIAN_BIG + 0x1000 * FLOAT_CAN_RW_BE) :
+				psf->fl32_endswap = SF_FALSE ;
+				psf->write_short  = (func_short)  host_write_s2f ;
+				psf->write_int    = (func_int)    host_write_i2f ;
+				psf->write_float  = (func_float)  host_write_f ;
+				psf->write_double = (func_double) host_write_d2f ;
+				break ;
+				
+		case (SF_ENDIAN_BIG + 0x1000 * FLOAT_CAN_RW_LE) :
+				psf->fl32_endswap = SF_TRUE ;
+				psf->write_short  = (func_short)  host_write_s2f ;
+				psf->write_int    = (func_int)    host_write_i2f ;
+				psf->write_float  = (func_float)  host_write_f ;
+				psf->write_double = (func_double) host_write_d2f ;
+				break ;
+				
+		case (SF_ENDIAN_LITTLE + 0x1000 * FLOAT_CAN_RW_BE) :
+				psf->fl32_endswap = SF_TRUE ;
+				psf->write_short  = (func_short)  host_write_s2f ;
+				psf->write_int    = (func_int)    host_write_i2f ;
+				psf->write_float  = (func_float)  host_write_f ;
+				psf->write_double = (func_double) host_write_d2f ;
+				break ;
+				
+		case (SF_ENDIAN_BIG + 0x1000 * FLOAT_BROKEN_LE) :
+				psf->fl32_endswap = SF_TRUE ;
+				psf->write_short  = (func_short)  broken_write_s2f ;
+				psf->write_int    = (func_int)    broken_write_i2f ;
+				psf->write_float  = (func_float)  broken_write_f ;
+				psf->write_double = (func_double) broken_write_d2f ;
+				break ;
+				
+		case (SF_ENDIAN_LITTLE + 0x1000 * FLOAT_BROKEN_LE) :
+				psf->fl32_endswap = SF_FALSE ;
+				psf->write_short  = (func_short)  broken_write_s2f ;
+				psf->write_int    = (func_int)    broken_write_i2f ;
+				psf->write_float  = (func_float)  broken_write_f ;
+				psf->write_double = (func_double) broken_write_d2f ;
+				break ;
+				
+		case (SF_ENDIAN_BIG + 0x1000 * FLOAT_BROKEN_BE) :
+				psf->fl32_endswap = SF_FALSE ;
+				psf->write_short  = (func_short)  broken_write_s2f ;
+				psf->write_int    = (func_int)    broken_write_i2f ;
+				psf->write_float  = (func_float)  broken_write_f ;
+				psf->write_double = (func_double) broken_write_d2f ;
+				break ;
+				
+		case (SF_ENDIAN_LITTLE + 0x1000 * FLOAT_BROKEN_BE) :
+				psf->fl32_endswap = SF_TRUE ;
+				psf->write_short  = (func_short)  broken_write_s2f ;
+				psf->write_int    = (func_int)    broken_write_i2f ;
+				psf->write_float  = (func_float)  broken_write_f ;
+				psf->write_double = (func_double) broken_write_d2f ;
+				break ;
+				
+		default : break ;
+		} ;
+
+	return 0 ;
+} /* float32_write_init */	
+
+float	
+float32_read (unsigned char *cptr)
+{	int		exponent, mantissa, negative ;
+	float	fvalue ;
+
+	if (CPU_IS_LITTLE_ENDIAN)
+	{	negative = cptr [3] & 0x80 ;
+		exponent = ((cptr [3] & 0x7F) << 1) | ((cptr [2] & 0x80) ? 1 : 0);
+		mantissa = ((cptr [2] & 0x7F) << 16) | (cptr [1] << 8) | (cptr [0]) ;
+		}
+	else
+	{	negative = cptr [0] & 0x80 ;
+		exponent = ((cptr [0] & 0x7F) << 1) | ((cptr [1] & 0x80) ? 1 : 0);
+		mantissa = ((cptr [1] & 0x7F) << 16) | (cptr [2] << 8) | (cptr [3]) ;
+		} ;
+
+	if (! (exponent || mantissa))
+		return 0.0 ;
+
+	mantissa |= 0x800000 ;
+	exponent = exponent ? exponent - 127 : 0 ;
+                
+	fvalue = mantissa ? ((float) mantissa) / ((float) 0x800000) : 0.0 ;
+                
+	if (negative)
+		fvalue *= -1 ;
+                
+	if (exponent > 0)
+		fvalue *= (1 << exponent) ;
+	else if (exponent < 0)
+		fvalue /= (1 << abs (exponent)) ;
+
+	return fvalue ;
+} /* float32_read */
+
+void	
+float32_write (float in, unsigned char *out)
+{	int		exponent, mantissa, negative = 0 ;
+
+	*((int*) out) = 0 ;
+	
+	if (in == 0.0)
+		return ;
+	
+	if (in < 0.0)
+	{	in *= -1.0 ;
+		negative = 1 ;
+		} ;
+		
+	in = frexp (in, &exponent) ;
+	
+	exponent += 126 ;
+	
+	in *= (float) 0x1000000 ;
+	mantissa = (((int) in) & 0x7FFFFF) ;
+
+	if (CPU_IS_LITTLE_ENDIAN)	
+	{	if (negative)
+			out [3] |= 0x80 ;
+			
+		if (exponent & 0x01)
+			out [2] |= 0x80 ;
+	
+		out [0]  = mantissa & 0xFF ;
+		out [1]  = (mantissa >> 8) & 0xFF ;
+		out [2] |= (mantissa >> 16) & 0x7F ;
+		out [3] |= (exponent >> 1) & 0x7F ;
+		}
+	else
+	{	if (negative)
+			out [0] |= 0x80 ;
+			
+		if (exponent & 0x01)
+			out [1] |= 0x80 ;
+	
+		out [3]  = mantissa & 0xFF ;
+		out [2]  = (mantissa >> 8) & 0xFF ;
+		out [1] |= (mantissa >> 16) & 0x7F ;
+		out [0] |= (exponent >> 1) & 0x7F ;
+		}
+	
+	return ;
+} /* float32_write */
+
+/*==============================================================================================
+**	Private functions.
+*/
+
+static void
+float32_peak_update (SF_PRIVATE *psf, float *buffer, int count, int index)
+{	int		k, chan, position ;
+	float	fmaxval;
+	
+	for (chan = 0 ; chan < psf->sf.channels ; chan++)
+	{	fmaxval = fabs (buffer [chan]) ;
+		position = 0 ;
+		for (k = chan ; k < count ; k += psf->sf.channels)
+			if (fmaxval < fabs (buffer [k]))
+			{	fmaxval = fabs (buffer [k]) ;
+				position = k ;
+				} ;
+				
+		if (fmaxval > psf->peak.peak[chan].value)
+		{	psf->peak.peak[chan].value = fmaxval ;
+			psf->peak.peak[chan].position = psf->current + index + (position /psf->sf.channels) ;
+			} ;
+		} ;
+
+	return ;	
+} /* float32_peak_update */
+
+int
+float32_get_capability (int endianness)
+{	union 
+	{	float			f ;
+		int				i ;
+		unsigned char	c [4] ;
+	} data ;
+
+	data.f = 1.23456789 ; /* Some abitrary value. */
+	
+	if (FORCE_BROKEN_FLOAT || data.i != 0x3f9e0652)
+		return (CPU_IS_LITTLE_ENDIAN) ? FLOAT_BROKEN_LE : FLOAT_BROKEN_BE ;
+
+	/* If this test is true ints and floats are compatible and little endian. */
+	if (data.c [0] == 0x52 && data.c [1] == 0x06 && data.c [2] == 0x9e && data.c [3] == 0x3f)
+		return FLOAT_CAN_RW_LE ;
+
+	/* If this test is true ints and floats are compatible and big endian. */
+	if (data.c [3] == 0x52 && data.c [2] == 0x06 && data.c [1] == 0x9e && data.c [0] == 0x3f)
+		return FLOAT_CAN_RW_BE ;
+		
+	/* Floats are broken. Don't expect reading or writing to be fast. */
+	return 0 ;
+} /* float32_get_capability */
+
+/*----------------------------------------------------------------------------------------------
+*/
+
+
+static int
+host_read_f2s (SF_PRIVATE *psf, short *ptr, int len)
+{	unsigned int readcount, thisread ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+		
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, readcount / sizeof (int)) ;
+
+		f2s_array ((float*) (psf->buffer), thisread / psf->bytewidth, ptr, index) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* host_read_f2s */
+
+static int
+host_read_f2i (SF_PRIVATE *psf, int *ptr, int len)
+{	unsigned int readcount, thisread ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+		
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, readcount / sizeof (int)) ;
+
+		f2i_array ((float*) (psf->buffer), thisread / psf->bytewidth, ptr, index) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* host_read_f2i */
+
+static int
+host_read_f (SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int readcount, thisread ;
+	int		bytecount, bufferlen ;
+	int	index = 0, total = 0 ;
+	
+	if (psf->fl32_endswap != SF_TRUE)
+		return fread (ptr, sizeof (float), len, psf->file) ; 
+	
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+		
+		endswap_int_array ((int*) psf->buffer, readcount / sizeof (int)) ;
+
+		memcpy (ptr + index, psf->buffer, thisread) ;
+
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* host_read_f */
+
+static int
+host_read_f2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	unsigned int readcount, thisread ;
+	int		bytecount, bufferlen ;
+	int	index = 0, total = 0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+		
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, readcount / sizeof (int)) ;
+
+		f2d_array ((float*) (psf->buffer), thisread / psf->bytewidth, ptr, index) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* host_read_f2d */
+
+static int
+host_write_s2f	(SF_PRIVATE *psf, short *ptr, int len)
+{	unsigned int	writecount, thiswrite ;
+	int	bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		s2f_array (ptr, index, (float*) (psf->buffer), writecount / psf->bytewidth) ;
+		
+		float32_peak_update (psf, (float *) (psf->buffer), writecount / psf->bytewidth, index / psf->sf.channels) ;
+		
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, writecount / sizeof (int)) ;
+			
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* host_write_s2f */
+
+static int
+host_write_i2f	(SF_PRIVATE *psf, int *ptr, int len)
+{	unsigned int	writecount, thiswrite ;
+	int	bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		i2f_array (ptr, index, (float*) (psf->buffer), writecount / psf->bytewidth) ;
+		
+		float32_peak_update (psf, (float *) (psf->buffer), writecount / psf->bytewidth, index / psf->sf.channels) ;
+		
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, writecount / sizeof (int)) ;
+			
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* host_write_i2f */
+
+static int
+host_write_f (SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int	writecount, thiswrite ;
+	int	bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+
+	float32_peak_update (psf, ptr, len, 0) ;
+			
+	if (psf->fl32_endswap != SF_TRUE)
+		return fwrite (ptr, sizeof (float), len, psf->file) ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+
+		memcpy (psf->buffer, ptr + index, writecount) ;
+		
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, writecount / sizeof (int)) ;
+			
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* host_write_f */
+
+static int
+host_write_d2f	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	unsigned int	writecount, thiswrite ;
+	int	bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		d2f_array (ptr, index, (float*) (psf->buffer), writecount / psf->bytewidth) ;
+		
+		float32_peak_update (psf, (float *) (psf->buffer), writecount / psf->bytewidth, index / psf->sf.channels) ;
+		
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, writecount / sizeof (int)) ;
+			
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* host_write_d2f */
+
+/*=======================================================================================
+*/
+
+static void	
+f2s_array (float *buffer, unsigned int count, short *ptr, int index)
+{	int	k ;
+	for (k = 0 ; k < count ; k++)
+	{	ptr [index] = ((double) buffer [k]) ;
+		index ++ ;
+		} ;
+} /* f2s_array */
+
+static void	
+f2i_array (float *buffer, unsigned int count, int *ptr, int index)
+{	int	k ;
+	for (k = 0 ; k < count ; k++)
+	{	ptr [index] = (int) ((double) buffer [k]) ;
+		index ++ ;
+		} ;
+} /* f2i_array */
+
+static void	
+f2d_array (float *buffer, unsigned int count, double *ptr, int index)
+{	int	k ;
+	for (k = 0 ; k < count ; k++)
+	{	ptr [index] = ((double) buffer [k]) ;
+		index ++ ;
+		} ;
+} /* f2d_array */
+
+static  void	
+s2f_array (short *ptr, int index, float *buffer, unsigned int count)
+{	int		k ;
+	for (k = 0 ; k < count ; k++)
+	{	buffer [k] = (float) (ptr [index]) ;
+		index ++ ;
+		} ;
+		
+} /* s2f_array */
+
+static void	
+i2f_array (int *ptr, int index, float *buffer, unsigned int count)
+{	int	k ;
+	for (k = 0 ; k < count ; k++)
+	{	buffer [k] = (float) (ptr [index]) ;
+		index ++ ;
+		} ;
+} /* i2f_array */
+
+static void	
+d2f_array (double *ptr, int index, float *buffer, unsigned int count)
+{	int	k ;
+	for (k = 0 ; k < count ; k++)
+	{	buffer [k] = (float) (ptr [index]) ;
+		index ++ ;
+		} ;
+} /* d2f_array */
+
+/*=======================================================================================
+*/
+
+static int		
+broken_read_f2s (SF_PRIVATE *psf, short *ptr, int len)
+{	unsigned int	bytecount, readcount, bufferlen, thisread ;
+	int				index = 0, total = 0 ;
+		
+	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, readcount / sizeof (int)) ;
+
+		bf2f_array ((float *) (psf->buffer), readcount / psf->bytewidth) ;
+
+		f2s_array ((float*) (psf->buffer), thisread / psf->bytewidth, ptr, index) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* broken_read_f2s */
+
+static int		
+broken_read_f2i (SF_PRIVATE *psf, int *ptr, int len)
+{	unsigned int	bytecount, readcount, bufferlen, thisread ;
+	int				index = 0, total = 0 ;
+
+	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, readcount / sizeof (int)) ;
+
+		bf2f_array ((float *) (psf->buffer), readcount / psf->bytewidth) ;
+
+		f2i_array ((float*) (psf->buffer), thisread / psf->bytewidth, ptr, index) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* broken_read_f2i */
+
+static int		
+broken_read_f (SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int	bytecount, readcount, bufferlen, thisread ;
+	int				index = 0, total = 0 ;
+	
+	/* FIX THIS */
+
+	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, readcount / sizeof (int)) ;
+
+		bf2f_array ((float *) (psf->buffer), readcount / psf->bytewidth) ;
+
+		memcpy (ptr + index, psf->buffer, readcount) ;
+		
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* broken_read_f */
+
+static int		
+broken_read_f2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	unsigned int	bytecount, readcount, bufferlen, thisread ;
+	int				index = 0, total = 0 ;
+
+	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, readcount / sizeof (int)) ;
+
+		bf2f_array ((float *) (psf->buffer), readcount / psf->bytewidth) ;
+
+		f2d_array ((float*) (psf->buffer), thisread / psf->bytewidth, ptr, index) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* broken_read_f2d */
+
+static int	
+broken_write_s2f (SF_PRIVATE *psf, short *ptr, int len)
+{	unsigned int	bytecount, writecount, bufferlen, thiswrite ;
+	int				index = 0, total = 0 ;
+
+	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		s2f_array (ptr, index, (float*) (psf->buffer), writecount / psf->bytewidth) ;
+
+		float32_peak_update (psf, (float *) (psf->buffer), writecount / psf->bytewidth, index / psf->sf.channels) ;
+
+		f2bf_array ((float *) (psf->buffer), writecount / psf->bytewidth) ;
+
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, writecount / sizeof (int)) ;
+
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* broken_write_s2f */
+
+static int	
+broken_write_i2f (SF_PRIVATE *psf, int *ptr, int len) 
+{	unsigned int	bytecount, writecount, bufferlen, thiswrite ;
+	int				index = 0, total = 0 ;
+
+	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		i2f_array (ptr, index, (float*) (psf->buffer), writecount / psf->bytewidth) ;
+
+		float32_peak_update (psf, (float *) (psf->buffer), writecount / psf->bytewidth, index / psf->sf.channels) ;
+
+		f2bf_array ((float *) (psf->buffer), writecount / psf->bytewidth) ;
+
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, writecount / sizeof (int)) ;
+
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* broken_write_i2f */
+
+static int	
+broken_write_f (SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int	bytecount, writecount, bufferlen, thiswrite ;
+	int				index = 0, total = 0 ;
+	
+	/* FIX THIS */
+	float32_peak_update (psf, ptr, len, 0) ;
+
+	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+
+		memcpy (psf->buffer, ptr + index, writecount) ;
+
+		f2bf_array ((float *) (psf->buffer), writecount / psf->bytewidth) ;
+		
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, writecount / sizeof (int)) ;
+
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* broken_write_f */
+
+static int	
+broken_write_d2f (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	unsigned int	bytecount, writecount, bufferlen, thiswrite ;
+	int				index = 0, total = 0 ;
+
+	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		d2f_array (ptr, index, (float*) (psf->buffer), writecount / psf->bytewidth) ;
+
+		float32_peak_update (psf, (float *) (psf->buffer), writecount / psf->bytewidth, index / psf->sf.channels) ;
+
+		f2bf_array ((float *) (psf->buffer), writecount / psf->bytewidth) ;
+
+		if (psf->fl32_endswap == SF_TRUE)
+			endswap_int_array ((int*) psf->buffer, writecount / sizeof (int)) ;
+
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* broken_write_d2f */
+
+/*==============================================================================
+*/
+
+/*----------------------------------------------------------------------------------------------
+*/
+
+static void	
+bf2f_array (float *buffer, unsigned int count)
+{	int	k ;
+	
+	for (k = 0 ; k < count ; k++)
+		buffer [k] = float32_read ((unsigned char *) (buffer + k)) ;
+} /* bf2f_array */
+
+static void	
+f2bf_array (float *buffer, unsigned int count)
+{	int	k ;
+	
+	for (k = 0 ; k < count ; k++)
+		float32_write (buffer [k], (unsigned char*) (buffer + k)) ;
+} /* f2bf_array */
+
--- /dev/null
+++ b/common/libsndfile/src/floatcast.h
@@ -1,0 +1,37 @@
+/*
+** Copyright (C) 2001 Erik de Castro Lopo <erikd@zip.com.au>
+**  
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU Lesser General Public License for more details.
+** 
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software 
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/* On Intel Pentium processors (especially PIII and probably P4), converting
+** from float to int is very slow. To meet the C specs, the code produced by 
+** most C compilers targeting Pentium needs to change the FPU rounding mode 
+** before the float to int conversion is performed. 
+**
+** Changing the FPU rounding mode causes the FPU pipeline to be flushed. It 
+** is this flushing of the pipeline which is so slow.
+*/
+
+
+/* These macros are place holders for inline functions which will replace 
+** them in the near future.
+*/
+
+#define	FLOAT_TO_INT(x)		((int)(x))
+#define	FLOAT_TO_SHORT(x)	((short)(x))
+
+#define	DOUBLE_TO_INT(x)	((int)(x))
+#define	DOUBLE_TO_SHORT(x)	((short)(x))
--- /dev/null
+++ b/common/libsndfile/src/ircam.c
@@ -1,0 +1,332 @@
+/*
+** Copyright (C) 2001 Erik de Castro Lopo <erikd@zip.com.au>
+**  
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU Lesser General Public License for more details.
+** 
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software 
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+#include	<stdio.h>
+#include	<unistd.h>
+#include	<fcntl.h>
+#include	<string.h>
+#include	<ctype.h>
+
+#include	"sndfile.h"
+#include	"config.h"
+#include	"sfendian.h"
+#include	"common.h"
+
+/*------------------------------------------------------------------------------
+** Macros to handle big/little endian issues.
+*/
+
+/* The IRCAM magic number is weird in that one byte in the number can have
+** values of 0x1, 0x2, 0x03 or 0x04. Hence the need for a marker and a mask.
+*/
+
+#define IRCAM_02_MARKER	(MAKE_MARKER (0x00, 0x02, 0xA3, 0x64)) 
+#define IRCAM_03_MARKER	(MAKE_MARKER (0x64, 0xA3, 0x03, 0x00)) 
+#define IRCAM_04_MARKER	(MAKE_MARKER (0x64, 0xA3, 0x04, 0x00)) 
+
+#define IRCAM_DATA_OFFSET	(1024)
+
+/*------------------------------------------------------------------------------
+** Typedefs.
+*/
+
+enum
+{	IRCAM_PCM_16	= 0x00002,
+	IRCAM_FLOAT		= 0x00004,
+	IRCAM_ALAW		= 0x10001,
+	IRCAM_ULAW		= 0x20001,
+	IRCAM_PCM_32	= 0x40004
+} ;
+
+
+/*------------------------------------------------------------------------------
+** Private static functions.
+*/
+
+static	int		ircam_close		(SF_PRIVATE *psf) ;
+static	int		ircam_write_header (SF_PRIVATE *psf) ;
+
+static	int		get_encoding (SF_PRIVATE *psf) ;
+
+static	char*	get_encoding_str (int encoding) ;
+
+/*------------------------------------------------------------------------------
+** Public functions.
+*/
+
+int
+ircam_open_read	(SF_PRIVATE *psf)
+{	unsigned int	marker, encoding ;
+	float			samplerate ;
+	int				error = SFE_NO_ERROR ;
+	
+	psf_binheader_readf (psf, "pm", 0, &marker) ;
+	
+	if (marker == IRCAM_03_MARKER)
+	{	psf->endian = SF_ENDIAN_LITTLE ;
+		
+		if (CPU_IS_LITTLE_ENDIAN)
+			marker = ENDSWAP_INT (marker) ;
+		psf_log_printf (psf, "marker: 0x%X => little endian\n", marker) ;
+
+		psf_binheader_readf (psf, "fll", &samplerate, &(psf->sf.channels), &encoding) ;
+		
+		psf->sf.samplerate = (int) samplerate ;
+		psf_log_printf (psf, "  Sample Rate : %d\n", psf->sf.samplerate) ;
+		psf_log_printf (psf, "  Channels    : %d\n", psf->sf.channels) ;
+		psf_log_printf (psf, "  Encoding    : %X => %s\n", encoding, get_encoding_str (encoding)) ;
+		}
+	else if (marker == IRCAM_02_MARKER || marker == IRCAM_04_MARKER)
+	{	psf->endian = SF_ENDIAN_BIG ;
+		
+		if (CPU_IS_BIG_ENDIAN)
+			marker = ENDSWAP_INT (marker) ;
+		psf_log_printf (psf, "marker: 0x%X => big endian\n", marker) ;
+
+		psf_binheader_readf (psf, "FLL", &samplerate, &(psf->sf.channels), &encoding) ;
+
+		psf->sf.samplerate = (int) samplerate ;
+		psf_log_printf (psf, "  Sample Rate : %d\n", psf->sf.samplerate) ;
+		psf_log_printf (psf, "  Channels    : %d\n", psf->sf.channels) ;
+		psf_log_printf (psf, "  Encoding    : %X => %s\n", encoding, get_encoding_str (encoding)) ;
+		}
+	else	
+		return SFE_IRCAM_NO_MARKER ;
+		
+	/* Sanit checking for endian-ness detection. */
+	if (psf->sf.channels > 256)
+		return SFE_IRCAM_BAD_CHANNELS ;
+
+	psf->sf.sections = 1 ;
+	psf->sf.seekable = SF_TRUE ;
+
+	switch (encoding)
+	{	case  IRCAM_PCM_16 :	
+				psf->sf.pcmbitwidth = 16 ;
+				psf->bytewidth      = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
+				psf->blockwidth = psf->sf.channels * psf->bytewidth ;
+
+				if (psf->endian == SF_ENDIAN_BIG)
+					psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_BE ;
+				else
+					psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_LE ;
+					
+				error = pcm_read_init (psf) ;
+				break ;
+
+		case IRCAM_PCM_32 :
+				psf->sf.pcmbitwidth = 32 ;
+				psf->bytewidth      = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
+				psf->blockwidth = psf->sf.channels * psf->bytewidth ;
+
+				if (psf->endian == SF_ENDIAN_BIG)
+					psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_BE ;
+				else
+					psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_PCM_LE ;
+					
+				error = pcm_read_init (psf) ;
+				break ;
+	
+		case  IRCAM_FLOAT :
+				psf->sf.pcmbitwidth = 32 ;
+				psf->bytewidth      = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
+				psf->blockwidth = psf->sf.channels * psf->bytewidth ;
+					
+				if (psf->endian == SF_ENDIAN_BIG)
+					psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_FLOAT_BE ;
+				else
+					psf->sf.format = SF_FORMAT_IRCAM | SF_FORMAT_FLOAT_LE ;
+					
+				error = float32_read_init (psf) ;
+				break ;
+
+		default : 
+				error = SFE_IRCAM_UNKNOWN_FORMAT ;
+				break ;
+		} ;
+
+	if (error)
+		return error ;
+		
+	psf->dataoffset = IRCAM_DATA_OFFSET ;
+	psf->datalength = psf->filelength - psf->dataoffset ;
+
+	if (! psf->sf.samples && psf->blockwidth)
+		psf->sf.samples = psf->datalength / psf->blockwidth ;
+
+	psf_log_printf (psf, "  Samples     : %d\n", psf->sf.samples) ;
+
+	psf_binheader_readf (psf, "p", IRCAM_DATA_OFFSET) ;
+
+	return 0 ;
+} /* ircam_open_read */
+
+/*------------------------------------------------------------------------------
+*/
+
+int
+ircam_open_write	(SF_PRIVATE *psf)
+{	unsigned int	encoding, subformat ;
+	int				error = SFE_NO_ERROR ;
+
+	if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_IRCAM)
+		return	SFE_BAD_OPEN_FORMAT ;
+		
+	subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+
+	if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW)
+		psf->bytewidth = 1 ;
+	else
+		psf->bytewidth = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
+		
+	psf->sf.seekable = SF_TRUE ;
+	psf->error       = 0 ;
+
+	psf->blockwidth  = psf->bytewidth * psf->sf.channels ;
+ 	psf->dataoffset  = IRCAM_DATA_OFFSET ;
+	psf->datalength  = psf->blockwidth * psf->sf.samples ;
+	psf->filelength  = psf->datalength + psf->dataoffset ;
+
+	if (! (encoding = ircam_write_header (psf)))
+		return psf->error ;
+
+	psf->close        = (func_close)  ircam_close ;
+	psf->write_header = (func_wr_hdr) ircam_write_header ;
+	
+	switch (encoding)
+	{	case  IRCAM_PCM_16 :	/* 16-bit linear PCM. */
+		case  IRCAM_PCM_32 :	/* 32-bit linear PCM. */
+				error = pcm_write_init (psf) ;
+				break ;
+				
+		case  IRCAM_FLOAT :	/* 32-bit linear PCM. */
+				error = float32_write_init (psf) ;
+				break ;
+				
+		default :   break ;
+		} ;
+		
+	return error ;
+} /* ircam_open_write */
+
+/*------------------------------------------------------------------------------
+*/
+
+static int
+ircam_close	(SF_PRIVATE  *psf)
+{
+	return 0 ;
+} /* ircam_close */
+
+static int
+ircam_write_header (SF_PRIVATE *psf)
+{	int		encoding ;
+	float	samplerate ;
+
+	/* This also sets psf->endian. */
+	encoding = get_encoding (psf) ;
+	
+	if (! encoding)
+	{	psf->error = SFE_BAD_OPEN_FORMAT ;
+		return	encoding ;
+		} ;
+
+	/* Reset the current header length to zero. */
+	psf->header [0] = 0 ;
+	psf->headindex = 0 ;
+	fseek (psf->file, 0, SEEK_SET) ;
+	
+	samplerate = psf->sf.samplerate ;
+
+	if (psf->endian == SF_ENDIAN_BIG)
+	{	psf_binheader_writef (psf, "mF", IRCAM_02_MARKER, samplerate) ;
+		psf_binheader_writef (psf, "LL", psf->sf.channels, encoding) ;
+		}
+	else if  (psf->endian == SF_ENDIAN_LITTLE)
+	{	psf_binheader_writef (psf, "mf", IRCAM_03_MARKER, samplerate) ;
+		psf_binheader_writef (psf, "ll", psf->sf.channels, encoding) ;
+		}
+	else
+	{	psf->error = SFE_BAD_OPEN_FORMAT ;
+		return	encoding ;
+		} ;
+
+	psf_binheader_writef (psf, "z", IRCAM_DATA_OFFSET - psf->headindex) ;
+	
+	/* Header construction complete so write it out. */
+	fwrite (psf->header, psf->headindex, 1, psf->file) ;
+
+	return encoding ;
+} /* ircam_write_header */ 
+
+static int
+get_encoding (SF_PRIVATE *psf)
+{	unsigned int format, bitwidth ;
+
+	format = psf->sf.format & SF_FORMAT_SUBMASK ;
+	bitwidth = psf->bytewidth * 8 ;
+
+	/* Default endian-ness is the same as host processor unless overridden. */
+	if (format == SF_FORMAT_PCM_BE || format == SF_FORMAT_FLOAT_BE)
+		psf->endian = SF_ENDIAN_BIG ;
+	else if (format == SF_FORMAT_PCM_LE || format == SF_FORMAT_FLOAT_LE)
+		psf->endian = SF_ENDIAN_LITTLE ;
+	else if (CPU_IS_BIG_ENDIAN)
+		psf->endian = SF_ENDIAN_BIG ;
+	else	
+		psf->endian = SF_ENDIAN_LITTLE ;
+
+	switch (format)
+	{	case SF_FORMAT_ULAW :	return IRCAM_ULAW ;
+		case SF_FORMAT_ALAW :	return IRCAM_ALAW ;
+
+		case SF_FORMAT_PCM :
+		case SF_FORMAT_PCM_BE :
+		case SF_FORMAT_PCM_LE :
+				/* For PCM encoding, the header encoding field depends on the bitwidth. */
+				switch (bitwidth)
+				{	case	16 : return IRCAM_PCM_16 ;
+					case	32 : return	IRCAM_PCM_32 ;
+					default : break ;
+					} ;
+				break ;
+
+		case SF_FORMAT_FLOAT :
+		case SF_FORMAT_FLOAT_BE :	
+		case SF_FORMAT_FLOAT_LE :	
+				return IRCAM_FLOAT ;
+					
+		default : break ;
+		} ;
+
+	return 0 ;
+} /* get_encoding */
+
+static	char*	
+get_encoding_str (int encoding)
+{	switch (encoding)
+	{	case IRCAM_PCM_16	: return "16 bit PCM" ;
+		case IRCAM_FLOAT	: return "32 bit float" ;
+		case IRCAM_ALAW		: return "A law" ;
+		case IRCAM_ULAW		: return "u law" ;
+		case IRCAM_PCM_32	: return "32 bit PCM" ;
+		} ;
+	return "Unknown encoding" ;
+} /* get_encoding_str */
+
--- a/common/libsndfile/src/newpcm.c
+++ /dev/null
@@ -1,44 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU Lesser General Public License for more details.
-** 
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-#include	<unistd.h>
-
-#include	"config.h"
-#include	"sndfile.h"
-#include	"common.h"
-#include	"sfendian.h"
-#include	"pcm.h"
-
-
-/*==================================================================================
-*/
-
-int pcm_read_init (SF_PRIVATE *psf, int channels, int bytewidth)
-{
-
-	return 0 ;
-} /* pcm_read_init */
-
-int pcm_write_init (SF_PRIVATE *psf, int channels, int bytewidth)
-{
-
-	return 0 ;
-} /* pcm_read_init */
-
-
--- /dev/null
+++ b/common/libsndfile/src/nist.c
@@ -1,0 +1,274 @@
+/*
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
+**  
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU Lesser General Public License for more details.
+** 
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software 
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/*
+**	Some of the information used to read NIST files was gleaned from 
+**	reading the code of Bill Schottstaedt's sndlib library 
+**		ftp://ccrma-ftp.stanford.edu/pub/Lisp/sndlib.tar.gz
+**	However, no code from that package was used.
+*/
+
+#include	<stdio.h>
+#include	<unistd.h>
+#include	<fcntl.h>
+#include	<string.h>
+#include	<ctype.h>
+
+#include	"sndfile.h"
+#include	"config.h"
+#include	"sfendian.h"
+#include	"common.h"
+
+/*------------------------------------------------------------------------------
+*/
+
+#define  NIST_HEADER_LENGTH    1024
+
+/*------------------------------------------------------------------------------
+** Private static functions.
+*/
+
+static	int	nist_close	(SF_PRIVATE *psf) ;
+static	void nist_write_header (SF_PRIVATE  *psf) ;
+
+/*------------------------------------------------------------------------------
+*/
+
+int 	
+nist_open_read	(SF_PRIVATE *psf)
+{	char	*psf_header ;
+	int		error ;
+
+	fseek (psf->file, 0, SEEK_SET) ;
+	
+	psf_header = (char*) psf->header ;
+
+	fgets (psf_header, SF_HEADER_LEN, psf->file) ;
+	psf_log_printf (psf, psf_header) ;
+	if (strlen (psf_header) != 8 || strcmp (psf_header, "NIST_1A\n"))
+		return SFE_NIST_BAD_HEADER ;
+	
+	fgets (psf_header, SF_HEADER_LEN, psf->file) ;
+	psf_log_printf (psf, psf_header) ;
+	if (strlen (psf_header) != 8 || atoi (psf_header) != 1024)
+		return SFE_NIST_BAD_HEADER ;
+
+	while (ftell (psf->file) < 1024 && !ferror (psf->file))
+	{	fgets (psf_header, SF_HEADER_LEN, psf->file) ;
+		psf_log_printf (psf, psf_header) ;
+		
+		if (strstr (psf_header, "channel_count -i ") == psf_header)
+			sscanf (psf_header, "channel_count -i %u", &(psf->sf.channels)) ;
+		
+		if (strstr (psf_header, "sample_count -i ") == psf_header)
+			sscanf (psf_header, "sample_count -i %u", &(psf->sf.samples)) ;
+
+		if (strstr (psf_header, "sample_rate -i ") == psf_header)
+			sscanf (psf_header, "sample_rate -i %u", &(psf->sf.samplerate)) ;
+
+		if (strstr (psf_header, "sample_n_bytes -i ") == psf_header)
+			sscanf (psf_header, "sample_n_bytes -i %u", &(psf->bytewidth)) ;
+
+		if (strstr (psf_header, "sample_sig_bits -i ") == psf_header)
+			sscanf (psf_header, "sample_sig_bits -i %u", &(psf->sf.pcmbitwidth)) ;
+
+		if (strstr (psf_header, "sample_byte_format -s") == psf_header)
+		{	int bytes ;
+			char str [8] = { 0, 0, 0, 0, 0, 0, 0, 0 } ;
+			
+			sscanf (psf_header, "sample_byte_format -s%d %5s", &bytes, str) ;
+			if (bytes < 2 || bytes > 4)
+				return SFE_NIST_BAD_ENCODING ;
+				
+			psf->bytewidth = bytes ;
+				
+			if (strstr (str, "01") == str)
+			{	psf->endian    = SF_ENDIAN_LITTLE ;
+				psf->sf.format = SF_FORMAT_NIST | SF_FORMAT_PCM_LE ;
+				}
+			else if (strstr (str, "10"))
+			{	psf->endian    = SF_ENDIAN_BIG ;
+				psf->sf.format = SF_FORMAT_NIST | SF_FORMAT_PCM_BE ;
+				} ;
+			} ;
+
+		if (strstr (psf_header, "sample_coding -s") == psf_header)
+			return SFE_NIST_BAD_ENCODING ;
+
+		if (strstr (psf_header, "end_head") == psf_header)
+			break ;
+		} ;
+		
+ 	psf->dataoffset = NIST_HEADER_LENGTH ;
+ 	psf->current  = 0 ;
+	psf->sf.seekable = SF_TRUE ;
+	psf->sf.sections = 1 ;
+
+	psf->close = (func_close) nist_close ;
+
+	psf->blockwidth = psf->sf.channels * psf->bytewidth ;
+	psf->datalength = psf->filelength - psf->dataoffset ;
+
+	if ((error = pcm_read_init (psf)))
+		return error ;
+
+	fseek (psf->file, psf->dataoffset, SEEK_SET) ;
+
+	return 0 ;
+} /* nist_open_read */
+
+/*------------------------------------------------------------------------------
+*/
+
+int 	
+nist_open_write	(SF_PRIVATE *psf)
+{	int subformat, error ;
+	
+	if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_NIST)
+		return	SFE_BAD_OPEN_FORMAT ;
+
+	subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+
+	if (subformat == SF_FORMAT_PCM_BE)
+		psf->endian = SF_ENDIAN_BIG ;
+	else if (subformat == SF_FORMAT_PCM_LE)
+		psf->endian = SF_ENDIAN_LITTLE ;
+	else if (CPU_IS_BIG_ENDIAN && subformat == SF_FORMAT_PCM)
+		psf->endian = SF_ENDIAN_BIG ;
+	else if (CPU_IS_LITTLE_ENDIAN && subformat == SF_FORMAT_PCM)
+		psf->endian = SF_ENDIAN_LITTLE ;
+	else
+		return	SFE_BAD_OPEN_FORMAT ;
+		
+	psf->bytewidth = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
+		
+	psf->blockwidth  = psf->bytewidth * psf->sf.channels ;
+ 	psf->dataoffset  = NIST_HEADER_LENGTH ;
+	psf->datalength  = psf->blockwidth * psf->sf.samples ;
+	psf->filelength  = psf->datalength + psf->dataoffset ;
+	psf->error       = 0 ;
+
+	if ((error = pcm_write_init (psf)))
+		return error ;
+
+	psf->close        = (func_close)  nist_close ;
+	psf->write_header = (func_wr_hdr) nist_write_header ;
+		
+	nist_write_header (psf) ;
+	
+	return 0 ;
+} /* nist_open_write */
+
+/*------------------------------------------------------------------------------
+*/
+
+static int	
+nist_close	(SF_PRIVATE  *psf)
+{
+	if (psf->mode == SF_MODE_WRITE)
+	{	/*  Now we know for certain the length of the file we can
+		**  re-write correct values for the datasize header element.
+		*/
+
+		fseek (psf->file, 0, SEEK_END) ;
+		psf->filelength = ftell (psf->file) ;
+
+		psf->dataoffset = NIST_HEADER_LENGTH ;
+		psf->datalength = psf->filelength - psf->dataoffset ;
+
+		psf->sf.samples = psf->datalength / psf->blockwidth ;
+
+		nist_write_header (psf) ;
+		} ;
+
+	if (psf->fdata)
+		free (psf->fdata) ;
+	psf->fdata = NULL ;
+	
+	return 0 ;
+} /* nist_close */
+
+/*=========================================================================
+*/
+
+static void 
+nist_write_header (SF_PRIVATE  *psf)
+{	char	*end_str ;
+
+	if (psf->endian == SF_ENDIAN_BIG)
+		end_str = "10" ;
+	else if (psf->endian == SF_ENDIAN_LITTLE)
+		end_str = "01" ;
+	else
+		end_str = "error" ;
+
+	/* Clear the whole header. */
+	memset (psf->header, 0, sizeof (psf->header)) ;
+		
+	psf_asciiheader_printf (psf, "NIST_1A\n   1024\n") ;
+	psf_asciiheader_printf (psf, "channel_count -i %d\n", psf->sf.channels) ;
+	psf_asciiheader_printf (psf, "sample_rate -i %d\n", psf->sf.samplerate) ;
+	psf_asciiheader_printf (psf, "sample_n_bytes -i %d\n", psf->bytewidth) ;
+	psf_asciiheader_printf (psf, "sample_byte_format -s%d %s\n", psf->bytewidth, end_str) ;
+	psf_asciiheader_printf (psf, "sample_sig_bits -i %d\n", psf->sf.pcmbitwidth) ;
+	psf_asciiheader_printf (psf, "sample_count -i %d\n", psf->sf.samples) ;
+	psf_asciiheader_printf (psf, "end_head\n") ;
+
+	fseek (psf->file, 0, SEEK_SET) ;
+
+	/* Zero fill to dataoffset. */
+	psf_binheader_writef (psf, "z", NIST_HEADER_LENGTH - psf->headindex) ;
+
+	fwrite (psf->header, psf->headindex, 1, psf->file) ;
+
+	return ;		
+} /* nist_write_header */
+
+/*-
+
+These were used to parse the sample_byte_format field but were discarded in favour
+os a simpler method using strstr ().
+
+static  
+int strictly_ascending (char *str)
+{	int  k ;
+
+	if (strlen (str) < 2)
+		return 0 ;
+
+	for (k = 1 ; str [k] ; k++) 
+		if (str [k] != str [k-1] + 1)
+			return 0 ;
+	
+	return 1 ;
+} /+* strictly_ascending *+/
+
+static  int strictly_descending (char *str)
+{	int  k ;
+
+	if (strlen (str) < 2)
+		return 0 ;
+
+	for (k = 1 ; str [k] ; k++) 
+		if (str [k] + 1 != str [k-1])
+			return 0 ;
+	
+	return 1 ;
+} /+* strictly_descending *+/
+
+-*/
--- a/common/libsndfile/src/paf.c
+++ b/common/libsndfile/src/paf.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -23,25 +23,16 @@
 #include	<string.h>
 #include	<ctype.h>
 
-#include	"sndfile.h"
 #include	"config.h"
+#include	"sndfile.h"
 #include	"sfendian.h"
+#include	"floatcast.h"
 #include	"common.h"
-#include	"pcm.h"
 
-
 /*------------------------------------------------------------------------------
 ** Macros to handle big/little endian issues.
 */
 
-#if (CPU_IS_LITTLE_ENDIAN == 1)
-#	define	MAKE_MARKER(a,b,c,d)		((a)|((b)<<8)|((c)<<16)|((d)<<24))
-#elif (CPU_IS_BIG_ENDIAN == 1)
-#	define	MAKE_MARKER(a,b,c,d)		(((a)<<24)|((b)<<16)|((c)<<8)|(d))
-#else
-#	error "Cannot determine endian-ness of processor."
-#endif
-
 #define FAP_MARKER	(MAKE_MARKER ('f', 'a', 'p', ' ')) 
 #define PAF_MARKER	(MAKE_MARKER (' ', 'p', 'a', 'f')) 
 
@@ -68,11 +59,9 @@
 {	unsigned int	index, blocks, channels, samplesperblock, blockcount, blocksize, samplecount ;
 	unsigned char	*block ;
 	int				*samples ;
-	unsigned char	data [4] ;
+	unsigned char	data [1] ; /* Data size fixed during malloc (). */
 } PAF24_PRIVATE ;
 
-
-
 /*------------------------------------------------------------------------------
 ** Private static functions.
 */
@@ -86,51 +75,57 @@
 
 static int paf24_read_s (SF_PRIVATE *psf, short *ptr, int len) ;
 static int paf24_read_i (SF_PRIVATE *psf, int *ptr, int len) ;
+static int paf24_read_f (SF_PRIVATE *psf, float *ptr, int len) ;
 static int paf24_read_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
 
 static int paf24_write_s (SF_PRIVATE *psf, short *ptr, int len) ;
 static int paf24_write_i (SF_PRIVATE *psf, int *ptr, int len) ;
+static int paf24_write_f (SF_PRIVATE *psf, float *ptr, int len) ;
 static int paf24_write_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
 
-static off_t paf24_seek (SF_PRIVATE *psf, off_t offset, int whence) ;
+static long paf24_seek (SF_PRIVATE *psf, long offset, int whence) ;
 
+/*
 static void	endswap_paf_fmt (PAF_FMT *ppaf_fmt) ;
+*/
 
 /*------------------------------------------------------------------------------
 ** Public functions.
 */
 
-int 	paf_open_read	(SF_PRIVATE *psf)
+int
+paf_open_read	(SF_PRIVATE *psf)
 {	PAF_FMT			paf_fmt ;
 	unsigned int	marker ;
 	int				error ;
 	
-	fread (&marker, sizeof (marker), 1, psf->file) ;
-	if (marker != PAF_MARKER && marker != FAP_MARKER)
-		return SFE_PAF_NO_MARKER ;
-		
-	psf_sprintf (psf, "Signature   : %D\n", marker) ;
-
-	fread (&paf_fmt, sizeof (PAF_FMT), 1, psf->file) ;
+	psf_binheader_readf (psf, "pm", 0, &marker) ;
 	
-	if (CPU_IS_LITTLE_ENDIAN && marker == PAF_MARKER)
-		endswap_paf_fmt (&paf_fmt) ;
-	else if (CPU_IS_BIG_ENDIAN && marker == FAP_MARKER)
-		endswap_paf_fmt (&paf_fmt) ;
+	psf_log_printf (psf, "Signature   : %D\n", marker) ;
 
-	psf_sprintf (psf, "Version     : %d\n", paf_fmt.version) ;
+	if (marker == PAF_MARKER)
+	{	psf_binheader_readf (psf, "LLLLLL", &(paf_fmt.version), &(paf_fmt.endianness), 
+			&(paf_fmt.samplerate), &(paf_fmt.format), &(paf_fmt.channels), &(paf_fmt.source)) ;
+		}
+	else if (marker == FAP_MARKER)
+	{	psf_binheader_readf (psf, "llllll", &(paf_fmt.version), &(paf_fmt.endianness), 
+			&(paf_fmt.samplerate), &(paf_fmt.format), &(paf_fmt.channels), &(paf_fmt.source)) ;
+		}
+	else
+		return SFE_PAF_NO_MARKER ;
+		
+	psf_log_printf (psf, "Version     : %d\n", paf_fmt.version) ;
 	if (paf_fmt.version != 0)
-	{	psf_sprintf (psf, "*** Bad version number. Should be zero.\n") ;
+	{	psf_log_printf (psf, "*** Bad version number. should be zero.\n") ;
 		return SFE_PAF_VERSION ;
 		} ;
 		
-	psf_sprintf (psf, "Endianness  : %d => ", paf_fmt.endianness) ;
+	psf_log_printf (psf, "Endianness  : %d => ", paf_fmt.endianness) ;
 	if (paf_fmt.endianness)
-		psf_sprintf (psf, "Little\n", paf_fmt.endianness) ;
+		psf_log_printf (psf, "Little\n", paf_fmt.endianness) ;
 	else
-		psf_sprintf (psf, "Big\n", paf_fmt.endianness) ;
-	psf_sprintf (psf, "Sample Rate : %d\n", paf_fmt.samplerate) ;
-	
+		psf_log_printf (psf, "Big\n", paf_fmt.endianness) ;
+	psf_log_printf (psf, "Sample Rate : %d\n", paf_fmt.samplerate) ;
 
 	if (psf->filelength < PAF_HEADER_LENGTH)
 		return SFE_PAF_SHORT_HEADER ;
@@ -140,11 +135,9 @@
 
  	psf->current  = 0 ;
 	psf->endian   = paf_fmt.endianness ? SF_ENDIAN_LITTLE : SF_ENDIAN_BIG ;
-	psf->sf.seekable = SF_TRUE ;
- 	
- 	if (fseek (psf->file, psf->dataoffset, SEEK_SET))
-		return SFE_BAD_SEEK ;
 
+	psf_binheader_readf (psf, "p", psf->dataoffset) ;
+	
 	psf->sf.samplerate	= paf_fmt.samplerate ;
 	psf->sf.channels 	= paf_fmt.channels ;
 					
@@ -153,38 +146,31 @@
 
 	psf->sf.sections 	= 1 ;
 
-	psf_sprintf (psf, "Format      : %d => ", paf_fmt.format) ;
+	psf_log_printf (psf, "Format      : %d => ", paf_fmt.format) ;
 
 	switch (paf_fmt.format)
-	{	case  0 :	psf_sprintf (psf, "16 bit linear PCM\n") ;
+	{	case  0 :	psf_log_printf (psf, "16 bit linear PCM\n") ;
 					psf->sf.pcmbitwidth = 16 ;
 					psf->bytewidth      = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
 
 					psf->sf.format |= paf_fmt.endianness ? SF_FORMAT_PCM_LE : SF_FORMAT_PCM_BE ; ;
 					
-					if (psf->endian == SF_ENDIAN_BIG)
-					{	psf->read_short  = (func_short)  pcm_read_bes2s ;
-						psf->read_int    = (func_int)    pcm_read_bes2i ;
-						psf->read_double = (func_double) pcm_read_bes2d ;
-						}
-					else
-					{	psf->read_short  = (func_short)  pcm_read_les2s ;
-						psf->read_int    = (func_int)    pcm_read_les2i ;
-						psf->read_double = (func_double) pcm_read_les2d ;
-						} ;
+					if ((error = pcm_read_init (psf)))
+						return error ;
+
 					psf->blockwidth = psf->bytewidth * psf->sf.channels ;
 
-	psf_sprintf (psf, "X blockwidth : %d\n", psf->blockwidth) ;
+	psf_log_printf (psf, "X blockwidth : %d\n", psf->blockwidth) ;
 
 					if (psf->blockwidth)
 						psf->sf.samples = psf->datalength / psf->blockwidth ;
 					else
-						psf_sprintf (psf, "*** Warning : blockwidth == 0.\n") ;
+						psf_log_printf (psf, "*** Warning : blockwidth == 0.\n") ;
 					
-	psf_sprintf (psf, "X samples : %d\n", psf->sf.samples) ;
+	psf_log_printf (psf, "X samples : %d\n", psf->sf.samples) ;
 					break ;
 
-		case  1 :	psf_sprintf (psf, "24 bit linear PCM\n") ;
+		case  1 :	psf_log_printf (psf, "24 bit linear PCM\n") ;
 					psf->sf.pcmbitwidth = 24 ;
 					psf->bytewidth      = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
 
@@ -192,6 +178,7 @@
 					
 					psf->read_short  = (func_short)  paf24_read_s ;
 					psf->read_int    = (func_int)    paf24_read_i ;
+					psf->read_float  = (func_float) paf24_read_f ;
 					psf->read_double = (func_double) paf24_read_d ;
 
 					if ((error = paf24_reader_init (psf)))
@@ -201,29 +188,29 @@
 					psf->close = (func_close) paf24_close ;
 
 					psf->blockwidth = psf->bytewidth * psf->sf.channels ;
-	psf_sprintf (psf, "X blockwidth : %d\n", psf->blockwidth) ;
+	psf_log_printf (psf, "X blockwidth : %d\n", psf->blockwidth) ;
 					psf->sf.samples = 10 * psf->datalength / (32 * psf->sf.channels) ;
-	psf_sprintf (psf, "X samples : %d\n", psf->sf.samples) ;
+	psf_log_printf (psf, "X samples : %d\n", psf->sf.samples) ;
 					break ;
 		
-		default :   psf_sprintf (psf, "Unknown\n") ;
+		default :   psf_log_printf (psf, "Unknown\n") ;
 					return SFE_PAF_UNKNOWN_FORMAT ;
 					break ;
 		} ;
 
-	psf_sprintf (psf, "Channels    : %d\n", paf_fmt.channels) ;
-	psf_sprintf (psf, "Source      : %d => ", paf_fmt.source) ;
+	psf_log_printf (psf, "Channels    : %d\n", paf_fmt.channels) ;
+	psf_log_printf (psf, "Source      : %d => ", paf_fmt.source) ;
 	
 	switch (paf_fmt.source)
-	{	case  1 : psf_sprintf (psf, "Analog Recording\n") ;
+	{	case  1 : psf_log_printf (psf, "Analog Recording\n") ;
 					break ;
-		case  2 : psf_sprintf (psf, "Digital Transfer\n") ;
+		case  2 : psf_log_printf (psf, "Digital Transfer\n") ;
 					break ;
-		case  3 : psf_sprintf (psf, "Multi-track Mixdown\n") ;
+		case  3 : psf_log_printf (psf, "Multi-track Mixdown\n") ;
 					break ;
-		case  5 : psf_sprintf (psf, "Audio Resulting From DSP Processing\n") ;
+		case  5 : psf_log_printf (psf, "Audio Resulting From DSP Processing\n") ;
 					break ;
-		default : psf_sprintf (psf, "Unknown\n") ;
+		default : psf_log_printf (psf, "Unknown\n") ;
 					break ;
 		} ;
 
@@ -233,37 +220,41 @@
 /*------------------------------------------------------------------------------
 */
 
-int 	paf_open_write	(SF_PRIVATE *psf)
+int
+paf_open_write	(SF_PRIVATE *psf)
 {	PAF_FMT			paf_fmt ;
-	int				format, subformat, error, count ;
-	unsigned int	marker, big_endian_file ;
+	int				subformat, error, paf_format ;
 	
-	format = psf->sf.format & SF_FORMAT_TYPEMASK ;
-	subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
-
-	if (format != SF_FORMAT_PAF)
+	if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_PAF)
 		return	SFE_BAD_OPEN_FORMAT ;
 
+	subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+
 	if (subformat == SF_FORMAT_PCM_BE)
-	{	big_endian_file = 1 ;
-		paf_fmt.endianness = 0 ;
-		}
+		psf->endian = SF_ENDIAN_BIG ;
 	else if (subformat == SF_FORMAT_PCM_LE)
-	{	big_endian_file = 0 ;
-		paf_fmt.endianness = 1 ;
-		}
+		psf->endian = SF_ENDIAN_LITTLE ;
+	else if (CPU_IS_BIG_ENDIAN && subformat == SF_FORMAT_PCM)
+		psf->endian = SF_ENDIAN_BIG ;
+	else if (CPU_IS_LITTLE_ENDIAN && subformat == SF_FORMAT_PCM)
+		psf->endian = SF_ENDIAN_LITTLE ;
 	else
 		return	SFE_BAD_OPEN_FORMAT ;
 		
-	paf_fmt.version    = 0 ;
-	paf_fmt.samplerate = psf->sf.samplerate ;
-	
+	psf->bytewidth = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
+
+	psf->blockwidth  = psf->bytewidth * psf->sf.channels ;
+ 	psf->dataoffset  = PAF_HEADER_LENGTH ;
+	psf->datalength  = psf->blockwidth * psf->sf.samples ;
+	psf->filelength  = psf->datalength + psf->dataoffset ;
+	psf->error       = 0 ;
+
 	switch (psf->sf.pcmbitwidth)
-	{	case  16 : 	paf_fmt.format = 0 ;
+	{	case  16 : 	paf_format = 0 ;
 					psf->bytewidth = 2 ;
 					break ;
 
-		case  24 :	paf_fmt.format = 1 ;
+		case  24 :	paf_format = 1 ;
 					psf->bytewidth = 3 ;
 					break ;
 	
@@ -270,36 +261,16 @@
 		default : return SFE_PAF_UNKNOWN_FORMAT ;
 		} ;
 		
-	paf_fmt.channels   = psf->sf.channels ;
-	paf_fmt.source     = 0 ;
-
-	psf->bytewidth = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
-		
-	psf->endian      = big_endian_file ? SF_ENDIAN_BIG : SF_ENDIAN_LITTLE ;
-	psf->sf.seekable = SF_TRUE ;
-	psf->blockwidth  = psf->bytewidth * psf->sf.channels ;
- 	psf->dataoffset  = PAF_HEADER_LENGTH ;
-	psf->datalength  = psf->blockwidth * psf->sf.samples ;
-	psf->filelength  = psf->datalength + psf->dataoffset ;
-	psf->error       = 0 ;
-
-	switch (paf_fmt.format)
+	switch (paf_format)
 	{	case  0 :	/* 16-bit linear PCM. */
-					if (big_endian_file)
-					{	psf->write_short  = (func_short)  pcm_write_s2bes ;
-						psf->write_int    = (func_int)    pcm_write_i2bes ;
-						psf->write_double = (func_double) pcm_write_d2bes ;
-						}
-					else
-					{	psf->write_short  = (func_short)  pcm_write_s2les ;
-						psf->write_int    = (func_int)    pcm_write_i2les ;
-						psf->write_double = (func_double) pcm_write_d2les ;
-						} ;
+					if ((error = pcm_write_init (psf)))
+						return error ;
 					break ;
 
 		case  1 :	/* 24-bit linear PCM */
 					psf->write_short  = (func_short)  paf24_write_s ;
 					psf->write_int    = (func_int)    paf24_write_i ;
+					psf->write_float  = (func_float)  paf24_write_f ;
 					psf->write_double = (func_double) paf24_write_d ;
 					
 					if ((error = paf24_writer_init (psf)))
@@ -311,30 +282,29 @@
 
 		default :   break ;
 		} ;
-		
-	if (big_endian_file)
-	{	if (CPU_IS_LITTLE_ENDIAN)
-			endswap_paf_fmt	(&paf_fmt) ;
-		marker = PAF_MARKER ;
+	
+	/* Reset the current header length to zero. */
+	psf->header [0] = 0 ;
+	psf->headindex = 0 ;
+	
+	if (psf->endian == SF_ENDIAN_BIG)
+	{	/* Marker, version, endianness, samplerate */
+		psf_binheader_writef (psf, "mLLL", PAF_MARKER, 0, 0, psf->sf.samplerate) ;
+		/* format, channels, source */
+		psf_binheader_writef (psf, "LLL", paf_format, psf->sf.channels, paf_fmt.source) ;	
 		}
-	else
-	{	if (CPU_IS_BIG_ENDIAN)
-			endswap_paf_fmt	(&paf_fmt) ;
-		marker = FAP_MARKER ;
+	else if (psf->endian == SF_ENDIAN_LITTLE)
+	{	/* Marker, version, endianness, samplerate */
+		psf_binheader_writef (psf, "mlll", FAP_MARKER, 0, 1, psf->sf.samplerate) ;
+		/* format, channels, source */
+		psf_binheader_writef (psf, "lll", paf_format, psf->sf.channels, 0) ;
 		} ;
-	
-	fwrite (&marker, sizeof (marker), 1, psf->file) ;
-	fwrite (&paf_fmt, sizeof (PAF_FMT), 1, psf->file) ;
 
-	/* Fill the file from current position to dataoffset with zero bytes. */
-	memset (psf->buffer, 0, sizeof (psf->buffer)) ;
-	count = psf->dataoffset - ftell (psf->file) ;
-	while (count > 0)
-	{	int current = (count > sizeof (psf->buffer)) ? sizeof (psf->buffer) : count ; 
-		fwrite (psf->buffer, current, 1, psf->file) ;
-		count -= current ;
-		} ;
-		
+	/* Zero fill to dataoffset. */
+	psf_binheader_writef (psf, "z", psf->dataoffset - psf->headindex) ;
+
+	fwrite (psf->header, psf->headindex, 1, psf->file) ;
+
 	return 0 ;
 } /* paf_open_write */
 
@@ -352,8 +322,8 @@
 **	The code below attempts to gain efficiency while maintaining readability.
 */
 
-static 
-int paf24_reader_init (SF_PRIVATE  *psf)
+static int 
+paf24_reader_init (SF_PRIVATE  *psf)
 {	PAF24_PRIVATE	*ppaf24 ; 
 	unsigned int	paf24size ;	
 	
@@ -372,7 +342,7 @@
 	ppaf24->samplesperblock = 10 ;
 	
 	if (psf->datalength % ppaf24->blocksize)
-	{	psf_sprintf (psf, "*** Warning : file seems to be truncated.\n") ;
+	{	psf_log_printf (psf, "*** Warning : file seems to be truncated.\n") ;
 		ppaf24->blocks = psf->datalength / ppaf24->blocksize  + 1 ;
 		}
 	else
@@ -386,8 +356,8 @@
 } /* paf24_reader_init */
 
 
-static 
-int	paf24_read_block (SF_PRIVATE  *psf, PAF24_PRIVATE *ppaf24)
+static int	
+paf24_read_block (SF_PRIVATE  *psf, PAF24_PRIVATE *ppaf24)
 {	int				k, *iptr, newsample, channel ;
 	unsigned char	*cptr ;
 	
@@ -402,7 +372,7 @@
 	/* Read the block. */
 
 	if ((k = fread (ppaf24->block, 1, ppaf24->blocksize, psf->file)) != ppaf24->blocksize)
-		psf_sprintf (psf, "*** Warning : short read (%d != %d).\n", k, ppaf24->blocksize) ;
+		psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, ppaf24->blocksize) ;
 
 	/* Do endian swapping if necessary. */
 
@@ -425,8 +395,8 @@
 	return 1 ;
 } /* paf24_read_block */
 
-static
-int paf24_read (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24, int *ptr, int len)
+static int 
+paf24_read (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24, int *ptr, int len)
 {	int		count, total = 0, index = 0 ;
 	
 	while (index < len)
@@ -450,8 +420,8 @@
 	return total ;		
 } /* paf24_read */
 
-static 
-int paf24_read_s (SF_PRIVATE *psf, short *ptr, int len)
+static int 
+paf24_read_s (SF_PRIVATE *psf, short *ptr, int len)
 {	PAF24_PRIVATE 	*ppaf24 ; 
 	int				*iptr ;
 	int				k, bufferlen, readcount = 0, count ;
@@ -475,8 +445,8 @@
 	return total ;
 } /* paf24_read_s */
 
-static 
-int paf24_read_i (SF_PRIVATE *psf, int *ptr, int len) 
+static int 
+paf24_read_i (SF_PRIVATE *psf, int *ptr, int len) 
 {	PAF24_PRIVATE *ppaf24 ; 
 	int				total ;
 
@@ -489,8 +459,8 @@
 	return total ;
 } /* paf24_read_i */
 
-static 
-int paf24_read_d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int 
+paf24_read_f (SF_PRIVATE *psf, float *ptr, int len)
 {	PAF24_PRIVATE 	*ppaf24 ; 
 	int				*iptr ;
 	int				k, bufferlen, readcount = 0, count ;
@@ -506,6 +476,31 @@
 	{	readcount = (len >= bufferlen) ? bufferlen : len ;
 		count = paf24_read (psf, ppaf24, iptr, readcount) ;
 		for (k = 0 ; k < readcount ; k++)
+			ptr [index+k] = (float) (iptr [k]) ;
+		index += readcount ;
+		total += count ;
+		len -= readcount ;
+		} ;
+	return total ;
+} /* paf24_read_f */
+
+static int 
+paf24_read_d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	PAF24_PRIVATE 	*ppaf24 ; 
+	int				*iptr ;
+	int				k, bufferlen, readcount = 0, count ;
+	int				index = 0, total = 0 ;
+
+	if (! psf->fdata)
+		return 0 ;
+	ppaf24 = (PAF24_PRIVATE*) psf->fdata ;
+	
+	iptr = (int*) psf->buffer ;
+	bufferlen = psf->sf.channels * ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (int) ;
+	while (len > 0)
+	{	readcount = (len >= bufferlen) ? bufferlen : len ;
+		count = paf24_read (psf, ppaf24, iptr, readcount) ;
+		for (k = 0 ; k < readcount ; k++)
 			ptr [index+k] = (double) (iptr [k]) ;
 		index += readcount ;
 		total += count ;
@@ -517,8 +512,8 @@
 /*---------------------------------------------------------------------------
 */
 
-static 
-int paf24_writer_init (SF_PRIVATE  *psf)
+static int 
+paf24_writer_init (SF_PRIVATE  *psf)
 {	PAF24_PRIVATE	*ppaf24 ; 
 	unsigned int	paf24size ;	
 	
@@ -537,7 +532,7 @@
 	ppaf24->samplesperblock = 10 ;
 	
 	if (psf->datalength % ppaf24->blocksize)
-	{	psf_sprintf (psf, "*** Warning : file seems to be truncated.\n") ;
+	{	psf_log_printf (psf, "*** Warning : file seems to be truncated.\n") ;
 		ppaf24->blocks = psf->datalength / ppaf24->blocksize  + 1 ;
 		}
 	else
@@ -549,8 +544,8 @@
 } /* paf24_writer_init */
 
 
-static 
-int	paf24_write_block (SF_PRIVATE  *psf, PAF24_PRIVATE *ppaf24)
+static int	
+paf24_write_block (SF_PRIVATE  *psf, PAF24_PRIVATE *ppaf24)
 {	int				k, *iptr, nextsample, channel ;
 	unsigned char	*cptr ;
 	
@@ -577,7 +572,7 @@
 	/* Write block to disk. */
 	
 	if ((k = fwrite (ppaf24->block, 1, ppaf24->blocksize, psf->file)) != ppaf24->blocksize)
-		psf_sprintf (psf, "*** Warning : short write (%d != %d).\n", k, ppaf24->blocksize) ;
+		psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, ppaf24->blocksize) ;
 
 	ppaf24->blockcount ++ ;
 	ppaf24->samplecount = 0 ;
@@ -585,8 +580,8 @@
 	return 1 ;
 } /* paf24_write_block */
 
-static
-int paf24_write (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24, int *ptr, int len)
+static int 
+paf24_write (SF_PRIVATE *psf, PAF24_PRIVATE *ppaf24, int *ptr, int len)
 {	int		count, total = 0, index = 0 ;
 	
 	while (index < len)
@@ -607,8 +602,8 @@
 	return total ;		
 } /* paf24_write */
 
-static 
-int paf24_write_s (SF_PRIVATE *psf, short *ptr, int len)
+static int 
+paf24_write_s (SF_PRIVATE *psf, short *ptr, int len)
 {	PAF24_PRIVATE 	*ppaf24 ; 
 	int				*iptr ;
 	int				k, bufferlen, writecount = 0, count ;
@@ -632,8 +627,8 @@
 	return total ;
 } /* paf24_write_s */
 
-static 
-int paf24_write_i (SF_PRIVATE *psf, int *ptr, int len)
+static int 
+paf24_write_i (SF_PRIVATE *psf, int *ptr, int len)
 {	PAF24_PRIVATE 	*ppaf24 ; 
 	int				total = 0 ;
 
@@ -646,8 +641,8 @@
 	return total ;
 } /* paf24_write_i */
 
-static 
-int paf24_write_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) 
+static int 
+paf24_write_f (SF_PRIVATE *psf, float *ptr, int len) 
 {	PAF24_PRIVATE 	*ppaf24 ; 
 	int				*iptr ;
 	int				k, bufferlen, writecount = 0, count ;
@@ -662,7 +657,7 @@
 	while (len > 0)
 	{	writecount = (len >= bufferlen) ? bufferlen : len ;
 		for (k = 0 ; k < writecount ; k++)
-			iptr [k] = (int) ptr [index+k] ;
+			iptr [k] = FLOAT_TO_INT (ptr [index+k]) ;
 		count = paf24_write (psf, ppaf24, iptr, writecount) ;
 		index += writecount ;
 		total += count ;
@@ -669,23 +664,49 @@
 		len -= writecount ;
 		} ;
 	return total ;
+} /* paf24_write_f */
+
+static int 
+paf24_write_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) 
+{	PAF24_PRIVATE 	*ppaf24 ; 
+	int				*iptr ;
+	int				k, bufferlen, writecount = 0, count ;
+	int				index = 0, total = 0 ;
+
+	if (! psf->fdata)
+		return 0 ;
+	ppaf24 = (PAF24_PRIVATE*) psf->fdata ;
+	
+	iptr = (int*) psf->buffer ;
+	bufferlen = psf->sf.channels * ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (int) ;
+	while (len > 0)
+	{	writecount = (len >= bufferlen) ? bufferlen : len ;
+		for (k = 0 ; k < writecount ; k++)
+			iptr [k] = DOUBLE_TO_INT (ptr [index+k]) ;
+		count = paf24_write (psf, ppaf24, iptr, writecount) ;
+		index += writecount ;
+		total += count ;
+		len -= writecount ;
+		} ;
+	return total ;
 } /* paf24_write_d */
 
 /*---------------------------------------------------------------------------
 */
 
-static 
-off_t paf24_seek (SF_PRIVATE *psf, off_t offset, int whence)
+static long 
+paf24_seek (SF_PRIVATE *psf, long offset, int whence)
 {	PAF24_PRIVATE	*ppaf24 ; 
 	int				newblock, newsample ;
 	
 	if (! psf->fdata)
 		return 0 ;
+
 	ppaf24 = (PAF24_PRIVATE*) psf->fdata ;
 
 	if (! (psf->blockwidth && psf->datalength && psf->dataoffset))
 	{	psf->error = SFE_BAD_SEEK ;
-		return	((off_t) -1) ;
+		return	((long) -1) ;
 		} ;
 		
 	switch (whence)
@@ -692,7 +713,7 @@
 	{	case SEEK_SET :
 				if (offset < 0 || offset > ppaf24->blocks * ppaf24->samplesperblock)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				newblock  = offset / ppaf24->samplesperblock ;
 				newsample = offset % ppaf24->samplesperblock ;
@@ -701,7 +722,7 @@
 		case SEEK_CUR :
 				if (psf->current + offset < 0 || psf->current + offset > ppaf24->blocks * ppaf24->samplesperblock)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				newblock  = (psf->current + offset) / ppaf24->samplesperblock ;
 				newsample = (psf->current + offset) % ppaf24->samplesperblock ;
@@ -710,7 +731,7 @@
 		case SEEK_END :
 				if (offset > 0 || ppaf24->samplesperblock * ppaf24->blocks + offset < 0)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				newblock  = (ppaf24->samplesperblock * ppaf24->blocks + offset) / ppaf24->samplesperblock ;
 				newsample = (ppaf24->samplesperblock * ppaf24->blocks + offset) % ppaf24->samplesperblock ;
@@ -718,7 +739,7 @@
 				
 		default : 
 				psf->error = SFE_BAD_SEEK ;
-				return	((off_t) -1) ;
+				return	((long) -1) ;
 		} ;
 		
 	if (psf->mode == SF_MODE_READ)
@@ -730,10 +751,11 @@
 	else
 	{	/* What to do about write??? */ 
 		psf->error = SFE_BAD_SEEK ;
-		return	((off_t) -1) ;
+		return	((long) -1) ;
 		} ;
 
 	psf->current = newblock * ppaf24->samplesperblock + newsample ;
+
 	return psf->current ;
 } /* paf24_seek */
 
@@ -740,8 +762,8 @@
 /*---------------------------------------------------------------------------
 */
 
-static 
-int paf24_close (SF_PRIVATE  *psf)
+static int 
+paf24_close (SF_PRIVATE  *psf)
 {	PAF24_PRIVATE *ppaf24 ; 
 	
 	if (! psf->fdata)
@@ -763,8 +785,9 @@
 /*---------------------------------------------------------------------------
 */
 
-static
-void	endswap_paf_fmt (PAF_FMT *ppaf_fmt)
+/*-
+static void
+endswap_paf_fmt (PAF_FMT *ppaf_fmt)
 {	ppaf_fmt->version    = ENDSWAP_INT (ppaf_fmt->version) ;
 	ppaf_fmt->endianness = ENDSWAP_INT (ppaf_fmt->endianness) ;
 	ppaf_fmt->samplerate = ENDSWAP_INT (ppaf_fmt->samplerate) ;
@@ -771,4 +794,5 @@
 	ppaf_fmt->format     = ENDSWAP_INT (ppaf_fmt->format) ;
 	ppaf_fmt->channels   = ENDSWAP_INT (ppaf_fmt->channels) ;
 	ppaf_fmt->source     = ENDSWAP_INT (ppaf_fmt->source) ;
-} /* endswap_paf_fmt */
+} /+* endswap_paf_fmt *+/
+-*/
--- a/common/libsndfile/src/pcm.c
+++ b/common/libsndfile/src/pcm.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -21,9 +21,9 @@
 
 #include	"config.h"
 #include	"sndfile.h"
-#include	"common.h"
 #include	"sfendian.h"
-#include	"pcm.h"
+#include	"floatcast.h"
+#include	"common.h"
 
 /* Important!!! Do not assume that sizeof (tribyte) == 3. Some compilers 
 ** (Metrowerks CodeWarrior for Mac is one) pad the struct with an extra byte.
@@ -33,6 +33,79 @@
 {	char	bytes [3] ;
 } tribyte ;
 
+static int	pcm_read_sc2s  (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_read_uc2s  (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_read_bes2s (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_read_les2s (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_read_bet2s (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_read_let2s (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_read_bei2s (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_read_lei2s (SF_PRIVATE *psf, short *ptr, int len) ;
+
+static int	pcm_read_sc2i  (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_read_uc2i  (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_read_bes2i (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_read_les2i (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_read_bet2i (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_read_let2i (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_read_bei2i (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_read_lei2i (SF_PRIVATE *psf, int *ptr, int len) ;
+
+static int	pcm_read_sc2f  (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_read_uc2f  (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_read_bes2f (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_read_les2f (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_read_bet2f (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_read_let2f (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_read_bei2f (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_read_lei2f (SF_PRIVATE *psf, float *ptr, int len) ;
+
+static int	pcm_read_sc2d  (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_read_uc2d  (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_read_bes2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_read_les2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_read_bet2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_read_let2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_read_bei2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_read_lei2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+
+
+static int	pcm_write_s2sc  (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_write_s2uc  (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_write_s2bes (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_write_s2les (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_write_s2bet (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_write_s2let (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_write_s2bei (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	pcm_write_s2lei (SF_PRIVATE *psf, short *ptr, int len) ;
+
+static int	pcm_write_i2sc  (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_write_i2uc  (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_write_i2bes (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_write_i2les (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_write_i2bet (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_write_i2let (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_write_i2bei (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	pcm_write_i2lei (SF_PRIVATE *psf, int *ptr, int len) ;
+
+static int	pcm_write_f2sc  (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_write_f2uc  (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_write_f2bes (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_write_f2les (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_write_f2bet (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_write_f2let (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_write_f2bei (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	pcm_write_f2lei (SF_PRIVATE *psf, float *ptr, int len) ;
+
+static int	pcm_write_d2sc  (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_write_d2uc  (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_write_d2bes (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_write_d2les (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_write_d2bet (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_write_d2let (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_write_d2bei (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+static int	pcm_write_d2lei (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+
 static	void	sc2s_array	(signed char *buffer, unsigned int count, short *ptr, int index) ;
 static	void	uc2s_array	(unsigned char *buffer, unsigned int count, short *ptr, int index) ;
 static	void	bet2s_array (tribyte *buffer, unsigned int count, short *ptr, int index) ;
@@ -39,7 +112,6 @@
 static	void	let2s_array (tribyte *buffer, unsigned int count, short *ptr, int index) ;
 static	void	bei2s_array (int *buffer, unsigned int count, short *ptr, int index) ;
 static	void	lei2s_array (int *buffer, unsigned int count, short *ptr, int index) ;
-static	void	f2s_array 	(float *buffer, unsigned int count, short *ptr, int index) ;
 
 static	void	sc2i_array	(signed char *buffer, unsigned int count, int *ptr, int index) ;
 static	void	uc2i_array	(unsigned char *buffer, unsigned int count, int *ptr, int index) ;
@@ -47,8 +119,16 @@
 static	void	les2i_array (short *buffer, unsigned int count, int *ptr, int index) ;
 static	void	bet2i_array (tribyte *buffer, unsigned int count, int *ptr, int index) ;
 static	void	let2i_array (tribyte *buffer, unsigned int count, int *ptr, int index) ;
-static	void	f2i_array 	(float *buffer, unsigned int count, int *ptr, int index) ;
 
+static	void	sc2f_array	(signed char *buffer, unsigned int count, float *ptr, int index, float normfact) ;
+static	void	uc2f_array	(unsigned char *buffer, unsigned int count, float *ptr, int index, float normfact) ;
+static	void	bes2f_array (short *buffer, unsigned int count, float *ptr, int index, float normfact) ;
+static	void	les2f_array (short *buffer, unsigned int count, float *ptr, int index, float normfact) ;
+static	void	bet2f_array (tribyte *buffer, unsigned int count, float *ptr, int index, float normfact) ;
+static	void	let2f_array (tribyte *buffer, unsigned int count, float *ptr, int index, float normfact) ;
+static	void	bei2f_array (int *buffer, unsigned int count, float *ptr, int index, float normfact) ;
+static	void	lei2f_array (int *buffer, unsigned int count, float *ptr, int index, float normfact) ;
+
 static	void	sc2d_array	(signed char *buffer, unsigned int count, double *ptr, int index, double normfact) ;
 static	void	uc2d_array	(unsigned char *buffer, unsigned int count, double *ptr, int index, double normfact) ;
 static	void	bes2d_array (short *buffer, unsigned int count, double *ptr, int index, double normfact) ;
@@ -57,8 +137,8 @@
 static	void	let2d_array (tribyte *buffer, unsigned int count, double *ptr, int index, double normfact) ;
 static	void	bei2d_array (int *buffer, unsigned int count, double *ptr, int index, double normfact) ;
 static	void	lei2d_array (int *buffer, unsigned int count, double *ptr, int index, double normfact) ;
-static	void	f2d_array 	(float *buffer, unsigned int count, double *ptr, int index, double normfact) ;
 
+
 static	void	s2sc_array	(short *ptr, int index, signed char *buffer, unsigned int count) ;
 static	void	s2uc_array	(short *ptr, int index, unsigned char *buffer, unsigned int count) ;
 static	void	s2bet_array (short *ptr, int index, tribyte *buffer, unsigned int count) ;
@@ -65,7 +145,6 @@
 static	void	s2let_array (short *ptr, int index, tribyte *buffer, unsigned int count) ;
 static	void	s2bei_array (short *ptr, int index, int *buffer, unsigned int count) ;
 static	void	s2lei_array (short *ptr, int index, int *buffer, unsigned int count) ;
-static 	void	s2f_array 	(short *ptr, int index, float *buffer, unsigned int count) ;
 
 static	void	i2sc_array	(int *ptr, int index, signed char *buffer, unsigned int count) ;
 static	void	i2uc_array	(int *ptr, int index, unsigned char *buffer, unsigned int count) ;
@@ -73,8 +152,16 @@
 static	void	i2les_array (int *ptr, int index, short *buffer, unsigned int count) ;
 static	void	i2bet_array (int *ptr, int index, tribyte *buffer, unsigned int count) ;
 static	void	i2let_array (int *ptr, int index, tribyte *buffer, unsigned int count) ;
-static 	void	i2f_array 	(int *ptr, int index, float *buffer, unsigned int count) ;
 
+static	void	f2sc_array	(float *ptr, int index, signed char *buffer, unsigned int count, float normfact) ;
+static	void	f2uc_array	(float *ptr, int index, unsigned char *buffer, unsigned int count, float normfact) ;
+static	void	f2bes_array (float *ptr, int index, short *buffer, unsigned int count, float normfact) ;
+static	void	f2les_array (float *ptr, int index, short *buffer, unsigned int count, float normfact) ;
+static	void	f2bet_array (float *ptr, int index, tribyte *buffer, unsigned int count, float normfact) ;
+static	void	f2let_array (float *ptr, int index, tribyte *buffer, unsigned int count, float normfact) ;
+static 	void	f2bei_array (float *ptr, int index, int *buffer, unsigned int count, float normfact) ;
+static 	void	f2lei_array (float *ptr, int index, int *buffer, unsigned int count, float normfact) ;
+
 static	void	d2sc_array	(double *ptr, int index, signed char *buffer, unsigned int count, double normfact) ;
 static	void	d2uc_array	(double *ptr, int index, unsigned char *buffer, unsigned int count, double normfact) ;
 static	void	d2bes_array (double *ptr, int index, short *buffer, unsigned int count, double normfact) ;
@@ -83,13 +170,145 @@
 static	void	d2let_array (double *ptr, int index, tribyte *buffer, unsigned int count, double normfact) ;
 static 	void	d2bei_array (double *ptr, int index, int *buffer, unsigned int count, double normfact) ;
 static 	void	d2lei_array (double *ptr, int index, int *buffer, unsigned int count, double normfact) ;
-static 	void	d2f_array 	(double *ptr, int index, float *buffer, unsigned int count, double normfact) ;
 
+/*-----------------------------------------------------------------------------------------------
+*/
 
+int
+pcm_read_init (SF_PRIVATE *psf)
+{
+	if (psf->bytewidth == 1 && psf->chars == SF_CHARS_SIGNED)
+	{	psf->read_short  = (func_short)  pcm_read_sc2s ;
+		psf->read_int    = (func_int)    pcm_read_sc2i ;
+		psf->read_float  = (func_float)  pcm_read_sc2f ;
+		psf->read_double = (func_double) pcm_read_sc2d ;
+		return 0 ;
+		} 
+	else if (psf->bytewidth == 1 && psf->chars == SF_CHARS_UNSIGNED)
+	{	psf->read_short  = (func_short)  pcm_read_uc2s ;
+		psf->read_int    = (func_int)    pcm_read_uc2i ;
+		psf->read_float  = (func_float)  pcm_read_uc2f ;
+		psf->read_double = (func_double) pcm_read_uc2d ;
+		return 0 ;
+		} ;
+		
+	switch (psf->bytewidth * 0x10000 + psf->endian)
+	{	case  (2 * 0x10000 + SF_ENDIAN_BIG) :
+				psf->read_short  = (func_short)  pcm_read_bes2s ;
+				psf->read_int    = (func_int)    pcm_read_bes2i ;
+				psf->read_float  = (func_float)  pcm_read_bes2f ;
+				psf->read_double = (func_double) pcm_read_bes2d ;
+				break ;
+		case  (3 * 0x10000 + SF_ENDIAN_BIG) :
+				psf->read_short  = (func_short)  pcm_read_bet2s ;
+				psf->read_int    = (func_int)    pcm_read_bet2i ;
+				psf->read_float  = (func_float)  pcm_read_bet2f ;
+				psf->read_double = (func_double) pcm_read_bet2d ;
+				break ;
+		case  (4 * 0x10000 + SF_ENDIAN_BIG) :
+				psf->read_short  = (func_short)  pcm_read_bei2s ;
+				psf->read_int    = (func_int)    pcm_read_bei2i ;
+				psf->read_float  = (func_float)  pcm_read_bei2f ;
+				psf->read_double = (func_double) pcm_read_bei2d ;
+				break ;
+				
+		case  (2 * 0x10000 + SF_ENDIAN_LITTLE) :
+				psf->read_short  = (func_short)  pcm_read_les2s ;
+				psf->read_int    = (func_int)    pcm_read_les2i ;
+				psf->read_float  = (func_float)  pcm_read_les2f ;
+				psf->read_double = (func_double) pcm_read_les2d ;
+				break ;
+		case  (3 * 0x10000 + SF_ENDIAN_LITTLE) :
+				psf->read_short  = (func_short)  pcm_read_let2s ;
+				psf->read_int    = (func_int)    pcm_read_let2i ;
+				psf->read_float  = (func_float)  pcm_read_let2f ;
+				psf->read_double = (func_double) pcm_read_let2d ;
+				break ;
+		case  (4 * 0x10000 + SF_ENDIAN_LITTLE) :
+				psf->read_short  = (func_short)  pcm_read_lei2s ;
+				psf->read_int    = (func_int)    pcm_read_lei2i ;
+				psf->read_float  = (func_float)  pcm_read_lei2f ;
+				psf->read_double = (func_double) pcm_read_lei2d ;
+				break ;
+		default : return SFE_UNIMPLEMENTED ;
+		} ;
+
+	return 0 ;
+} /* pcm_read_init */
+
+int
+pcm_write_init (SF_PRIVATE *psf)
+{
+	if (psf->bytewidth == 1 && psf->chars == SF_CHARS_SIGNED)
+	{	psf->write_short  = (func_short)  pcm_write_s2sc ;
+		psf->write_int    = (func_int)    pcm_write_i2sc ;
+		psf->write_float  = (func_float)  pcm_write_f2sc ;
+		psf->write_double = (func_double) pcm_write_d2sc ;
+		return 0 ;
+		} 
+	else if (psf->bytewidth == 1 && psf->chars == SF_CHARS_UNSIGNED)
+	{	psf->write_short  = (func_short)  pcm_write_s2uc ;
+		psf->write_int    = (func_int)    pcm_write_i2uc ;
+		psf->write_float  = (func_float)  pcm_write_f2uc ;
+		psf->write_double = (func_double) pcm_write_d2uc ;
+		return 0 ;
+		} ;
+		
+	switch (psf->bytewidth * 0x10000 + psf->endian)
+	{	case  (2 * 0x10000 + SF_ENDIAN_BIG) :
+				psf->write_short  = (func_short)  pcm_write_s2bes ;
+				psf->write_int    = (func_int)    pcm_write_i2bes ;
+				psf->write_float  = (func_float)  pcm_write_f2bes ;
+				psf->write_double = (func_double) pcm_write_d2bes ;
+				break ;
+				
+		case  (3 * 0x10000 + SF_ENDIAN_BIG) :
+				psf->write_short  = (func_short)  pcm_write_s2bet ;
+				psf->write_int    = (func_int)    pcm_write_i2bet ;
+				psf->write_float  = (func_float)  pcm_write_f2bet ;
+				psf->write_double = (func_double) pcm_write_d2bet ;
+				break ;
+				
+		case  (4 * 0x10000 + SF_ENDIAN_BIG) :
+				psf->write_short  = (func_short)  pcm_write_s2bei ;
+				psf->write_int    = (func_int)    pcm_write_i2bei ;
+				psf->write_float  = (func_float)  pcm_write_f2bei ;
+				psf->write_double = (func_double) pcm_write_d2bei ;
+				break ;
+				
+		case  (2 * 0x10000 + SF_ENDIAN_LITTLE) :
+				psf->write_short  = (func_short)  pcm_write_s2les ;
+				psf->write_int    = (func_int)    pcm_write_i2les ;
+				psf->write_float  = (func_float)  pcm_write_f2les ;
+				psf->write_double = (func_double) pcm_write_d2les ;
+				break ;
+				
+		case  (3 * 0x10000 + SF_ENDIAN_LITTLE) :
+				psf->write_short  = (func_short)  pcm_write_s2let ;
+				psf->write_int    = (func_int)    pcm_write_i2let ;
+				psf->write_float  = (func_float)  pcm_write_f2let ;
+				psf->write_double = (func_double) pcm_write_d2let ;
+				break ;
+				
+		case  (4 * 0x10000 + SF_ENDIAN_LITTLE) :
+				psf->write_short  = (func_short)  pcm_write_s2lei ;
+				psf->write_int    = (func_int)    pcm_write_i2lei ;
+				psf->write_float  = (func_float)  pcm_write_f2lei ;
+				psf->write_double = (func_double) pcm_write_d2lei ;
+				break ;
+				
+		default : return SFE_UNIMPLEMENTED ;
+		} ;
+
+	return 0 ;
+} /* pcm_read_init */
+
+
 /*-----------------------------------------------------------------------------------------------
- */
+*/
 
-int		pcm_read_sc2s (SF_PRIVATE *psf, short *ptr, int len)
+static int		
+pcm_read_sc2s (SF_PRIVATE *psf, short *ptr, int len)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -114,7 +333,8 @@
 	return total ;
 } /* pcm_read_sc2s */
 
-int		pcm_read_uc2s (SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_read_uc2s (SF_PRIVATE *psf, short *ptr, int len)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -139,7 +359,8 @@
 	return total ;
 } /* pcm_read_uc2s */
 
-int		pcm_read_bes2s (SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_read_bes2s (SF_PRIVATE *psf, short *ptr, int len)
 {	int		total ;
 
 	total = fread (ptr, 1, len * sizeof (short), psf->file) ;
@@ -153,7 +374,8 @@
 	return total ;
 } /* pcm_read_bes2s */
 
-int		pcm_read_les2s (SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_read_les2s (SF_PRIVATE *psf, short *ptr, int len)
 {	int		total ;
 
 	total = fread (ptr, 1, len * sizeof (short), psf->file) ;
@@ -167,7 +389,8 @@
 	return total ;
 } /* pcm_read_les2s */
 
-int		pcm_read_bet2s (SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_read_bet2s (SF_PRIVATE *psf, short *ptr, int len)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -192,7 +415,8 @@
 	return total ;
 } /* pcm_read_bet2s */
 
-int		pcm_read_let2s (SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_read_let2s (SF_PRIVATE *psf, short *ptr, int len)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -217,7 +441,8 @@
 	return total ;
 } /* pcm_read_let2s */
 
-int		pcm_read_bei2s (SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_read_bei2s (SF_PRIVATE *psf, short *ptr, int len)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -242,7 +467,8 @@
 	return total ;
 } /* pcm_read_bei2s */
 
-int		pcm_read_lei2s (SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_read_lei2s (SF_PRIVATE *psf, short *ptr, int len)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -267,35 +493,11 @@
 	return total ;
 } /* pcm_read_lei2s */
 
-int		pcm_read_f2s (SF_PRIVATE *psf, short *ptr, int len)
-{	unsigned int readcount, thisread ;
-	int		bytecount, bufferlen ;
-	int		index = 0, total = 0 ;
-
-	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
-	bytecount = len * psf->bytewidth ;
-	while (bytecount > 0)
-	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
-		f2s_array ((float*) (psf->buffer), thisread / psf->bytewidth, ptr, index) ;
-		total += thisread ;
-		if (thisread < readcount)
-			break ;
-		index += thisread / psf->bytewidth ;
-		bytecount -= thisread ;
-		} ;
-
-	total /= psf->bytewidth ;
-	if (total < len)
-		psf->error = SFE_SHORT_READ ;
-	
-	return total ;
-} /* pcm_read_f2s */
-
 /*-----------------------------------------------------------------------------------------------
- */
+*/
 
-int		pcm_read_sc2i (SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_read_sc2i (SF_PRIVATE *psf, int *ptr, int len)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -320,7 +522,8 @@
 	return total ;
 } /* pcm_read_sc2i */
 
-int		pcm_read_uc2i (SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_read_uc2i (SF_PRIVATE *psf, int *ptr, int len)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -345,7 +548,8 @@
 	return total ;
 } /* pcm_read_uc2i */
 
-int		pcm_read_bes2i (SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_read_bes2i (SF_PRIVATE *psf, int *ptr, int len)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -370,7 +574,8 @@
 	return total ;
 } /* pcm_read_bes2i */
 
-int		pcm_read_les2i (SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_read_les2i (SF_PRIVATE *psf, int *ptr, int len)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -395,7 +600,8 @@
 	return total ;
 } /* pcm_read_les2i */
 
-int		pcm_read_bet2i (SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_read_bet2i (SF_PRIVATE *psf, int *ptr, int len)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -420,7 +626,8 @@
 	return total ;
 } /* pcm_read_bet2i */
 
-int		pcm_read_let2i (SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_read_let2i (SF_PRIVATE *psf, int *ptr, int len)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -445,7 +652,8 @@
 	return total ;
 } /* pcm_read_let2i */
 
-int		pcm_read_bei2i (SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_read_bei2i (SF_PRIVATE *psf, int *ptr, int len)
 {	int		total ;
 
 	total = fread (ptr, 1, len * sizeof (int), psf->file) ;
@@ -459,7 +667,8 @@
 	return total ;
 } /* pcm_read_bei2i */
 
-int		pcm_read_lei2i (SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_read_lei2i (SF_PRIVATE *psf, int *ptr, int len)
 {	int		total ;
 
 	total = fread (ptr, 1, len * sizeof (int), psf->file) ;
@@ -473,17 +682,24 @@
 	return total ;
 } /* pcm_read_lei2i */
 
-int		pcm_read_f2i (SF_PRIVATE *psf, int *ptr, int len)
+/*-----------------------------------------------------------------------------------------------
+*/
+
+static int
+pcm_read_sc2f (SF_PRIVATE *psf, float *ptr, int len)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
+	float	normfact ;
 
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80) : 1.0 ;
+
 	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
 	bytecount = len * psf->bytewidth ;
 	while (bytecount > 0)
 	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
 		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
-		f2i_array ((float*) (psf->buffer), thisread / psf->bytewidth, ptr, index) ;
+		sc2f_array ((signed char*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;
 		total += thisread ;
 		if (thisread < readcount)
 			break ;
@@ -496,12 +712,216 @@
 		psf->error = SFE_SHORT_READ ;
 	
 	return total ;
-} /* pcm_read_f2i */
+} /* pcm_read_sc2f */
 
+static int
+pcm_read_uc2f (SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int readcount, thisread ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+	float	normfact ;
+
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80) : 1.0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+		uc2f_array ((unsigned char*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* pcm_read_uc2f */
+
+static int
+pcm_read_bes2f (SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int readcount, thisread ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+	float	normfact ;
+
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+		bes2f_array ((short*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* pcm_read_bes2f */
+
+static int
+pcm_read_les2f (SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int readcount, thisread ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+	float	normfact ;
+
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+		les2f_array ((short*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* pcm_read_les2f */
+
+static int
+pcm_read_bet2f (SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int readcount, thisread ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+	float	normfact ;
+
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x800000) : 1.0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+		bet2f_array ((tribyte*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* pcm_read_bet2f */
+
+static int
+pcm_read_let2f (SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int readcount, thisread ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+	float	normfact ;
+
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x800000) : 1.0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+		let2f_array ((tribyte*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* pcm_read_let2f */
+
+static int
+pcm_read_bei2f (SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int readcount, thisread ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+	float	normfact ;
+
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+		bei2f_array ((int*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* pcm_read_bei2f */
+
+static int
+pcm_read_lei2f (SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int readcount, thisread ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+	float	normfact ;
+
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x80000000) : 1.0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+		lei2f_array ((int*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* pcm_read_lei2f */
+
 /*-----------------------------------------------------------------------------------------------
- */
+*/
 
-int		pcm_read_sc2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_read_sc2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -529,7 +949,8 @@
 	return total ;
 } /* pcm_read_sc2d */
 
-int		pcm_read_uc2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_read_uc2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -557,7 +978,8 @@
 	return total ;
 } /* pcm_read_uc2d */
 
-int		pcm_read_bes2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_read_bes2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -585,7 +1007,8 @@
 	return total ;
 } /* pcm_read_bes2d */
 
-int		pcm_read_les2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_read_les2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -613,7 +1036,8 @@
 	return total ;
 } /* pcm_read_les2d */
 
-int		pcm_read_bet2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_read_bet2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -641,7 +1065,8 @@
 	return total ;
 } /* pcm_read_bet2d */
 
-int		pcm_read_let2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_read_let2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -669,7 +1094,8 @@
 	return total ;
 } /* pcm_read_let2d */
 
-int		pcm_read_bei2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_read_bei2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -697,7 +1123,8 @@
 	return total ;
 } /* pcm_read_bei2d */
 
-int		pcm_read_lei2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_read_lei2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int readcount, thisread ;
 	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -725,40 +1152,13 @@
 	return total ;
 } /* pcm_read_lei2d */
 
-int		pcm_read_f2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
-{	unsigned int readcount, thisread ;
-	int		bytecount, bufferlen ;
-	int	index = 0, total = 0 ;
-	double	normfact ;
-
-	normfact = normalize ? 1.0 : 1.0 ;
-
-	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
-	bytecount = len * psf->bytewidth ;
-	while (bytecount > 0)
-	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
-		f2d_array ((float*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;
-		total += thisread ;
-		if (thisread < readcount)
-			break ;
-		index += thisread / psf->bytewidth ;
-		bytecount -= thisread ;
-		} ;
-
-	total /= psf->bytewidth ;
-	if (total < len)
-		psf->error = SFE_SHORT_READ ;
-	
-	return total ;
-} /* pcm_read_f2d */
-
 /*===============================================================================================
- *-----------------------------------------------------------------------------------------------
- *===============================================================================================
- */
+**-----------------------------------------------------------------------------------------------
+**===============================================================================================
+*/
 
-int	pcm_write_s2sc	(SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_write_s2sc	(SF_PRIVATE *psf, short *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -783,7 +1183,8 @@
 	return total ;
 } /* pcm_write_s2sc */
 
-int	pcm_write_s2uc	(SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_write_s2uc	(SF_PRIVATE *psf, short *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -808,7 +1209,8 @@
 	return total ;
 } /* pcm_write_s2uc */
 
-int		pcm_write_s2bes	(SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_write_s2bes	(SF_PRIVATE *psf, short *ptr, int len)
 {	int		total ;
 
 	if (CPU_IS_LITTLE_ENDIAN)
@@ -824,7 +1226,8 @@
 	return total ;
 } /* pcm_write_s2bes */
 
-int		pcm_write_s2les	(SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_write_s2les	(SF_PRIVATE *psf, short *ptr, int len)
 {	int		total ;
 
 	if (CPU_IS_BIG_ENDIAN)
@@ -840,7 +1243,8 @@
 	return total ;
 } /* pcm_write_s2les */
 
-int		pcm_write_s2bet	(SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_write_s2bet	(SF_PRIVATE *psf, short *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -865,7 +1269,8 @@
 	return total ;
 } /* pcm_write_s2bet */
 
-int		pcm_write_s2let	(SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_write_s2let	(SF_PRIVATE *psf, short *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -890,7 +1295,8 @@
 	return total ;
 } /* pcm_write_s2let */
 
-int 	pcm_write_s2bei	(SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_write_s2bei	(SF_PRIVATE *psf, short *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -915,7 +1321,8 @@
 	return total ;
 } /* pcm_write_s2bei */
 
-int 	pcm_write_s2lei	(SF_PRIVATE *psf, short *ptr, int len)
+static int
+pcm_write_s2lei	(SF_PRIVATE *psf, short *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -940,35 +1347,11 @@
 	return total ;
 } /* pcm_write_s2lei */
 
-int		pcm_write_s2f	(SF_PRIVATE *psf, short *ptr, int len)
-{	unsigned int	writecount, thiswrite ;
-	int	bytecount, bufferlen ;
-	int		index = 0, total = 0 ;
-
-	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
-	bytecount = len * psf->bytewidth ;
-	while (bytecount > 0)
-	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		s2f_array (ptr, index, (float*) (psf->buffer), writecount / psf->bytewidth) ;
-		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
-		total += thiswrite ;
-		if (thiswrite < writecount)
-			break ;
-		index += thiswrite / psf->bytewidth ;
-		bytecount -= thiswrite ;
-		} ;
-
-	total /= psf->bytewidth ;
-	if (total < len)
-		psf->error = SFE_SHORT_WRITE ;
-	
-	return total ;
-} /* pcm_write_s2f */
-
 /*-----------------------------------------------------------------------------------------------
- */
+*/
 
-int	pcm_write_i2sc	(SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_write_i2sc	(SF_PRIVATE *psf, int *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -993,7 +1376,8 @@
 	return total ;
 } /* pcm_write_i2sc */
 
-int	pcm_write_i2uc	(SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_write_i2uc	(SF_PRIVATE *psf, int *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -1018,7 +1402,8 @@
 	return total ;
 } /* pcm_write_i2uc */
 
-int		pcm_write_i2bes	(SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_write_i2bes	(SF_PRIVATE *psf, int *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -1043,7 +1428,8 @@
 	return total ;
 } /* pcm_write_i2bes */
 
-int		pcm_write_i2les	(SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_write_i2les	(SF_PRIVATE *psf, int *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -1068,7 +1454,8 @@
 	return total ;
 } /* pcm_write_i2les */
 
-int		pcm_write_i2bet	(SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_write_i2bet	(SF_PRIVATE *psf, int *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -1093,7 +1480,8 @@
 	return total ;
 } /* pcm_write_i2bet */
 
-int		pcm_write_i2let	(SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_write_i2let	(SF_PRIVATE *psf, int *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
@@ -1118,7 +1506,8 @@
 	return total ;
 } /* pcm_write_i2les */
 
-int 	pcm_write_i2bei	(SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_write_i2bei	(SF_PRIVATE *psf, int *ptr, int len)
 {	int		total ;
 
 	if (CPU_IS_LITTLE_ENDIAN)
@@ -1134,7 +1523,8 @@
 	return total ;
 } /* pcm_write_i2bei */
 
-int 	pcm_write_i2lei	(SF_PRIVATE *psf, int *ptr, int len)
+static int
+pcm_write_i2lei	(SF_PRIVATE *psf, int *ptr, int len)
 {	int		total ;
 
 	if (CPU_IS_BIG_ENDIAN)
@@ -1150,16 +1540,81 @@
 	return total ;
 } /* pcm_write_i2lei */
 
-int		pcm_write_i2f	(SF_PRIVATE *psf, int *ptr, int len)
+/*-----------------------------------------------------------------------------------------------
+*/
+
+static int
+pcm_write_f2sc	(SF_PRIVATE *psf, float *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+	float	normfact ;
+	
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x80) : 1.0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		f2sc_array (ptr, index, (signed char*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* pcm_write_f2sc */
+
+static int
+pcm_write_f2uc	(SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int	writecount, thiswrite ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+	float	normfact ;
+	
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x80) : 1.0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		f2uc_array (ptr, index, (unsigned char*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* pcm_write_f2uc */
+
+static int
+pcm_write_f2bes	(SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
+	float	normfact ;
+	
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x8000) : 1.0 ;
 
 	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
 	bytecount = len * psf->bytewidth ;
 	while (bytecount > 0)
 	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		i2f_array (ptr, index, (float*) (psf->buffer), writecount / psf->bytewidth) ;
+		f2bes_array (ptr, index, (short*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
 		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
 		total += thiswrite ;
 		if (thiswrite < writecount)
@@ -1173,24 +1628,51 @@
 		psf->error = SFE_SHORT_WRITE ;
 	
 	return total ;
-} /* pcm_write_i2f */
+} /* pcm_write_f2bes */
 
-/*-----------------------------------------------------------------------------------------------
- */
+static int
+pcm_write_f2les	(SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int	writecount, thiswrite ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+	float	normfact ;
+	
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x8000) : 1.0 ;
 
-int	pcm_write_d2sc	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		f2les_array (ptr, index, (short*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* pcm_write_f2les */
+
+static int
+pcm_write_f2let	(SF_PRIVATE *psf, float *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
-	double		normfact ;
+	float	normfact ;
 	
-	normfact = (normalize ? ((double) 0x80) : 1.0) ;
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x800000) : 1.0 ;
 
 	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
 	bytecount = len * psf->bytewidth ;
 	while (bytecount > 0)
 	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		d2sc_array (ptr, index, (signed char*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		f2let_array (ptr, index, (tribyte*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
 		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
 		total += thiswrite ;
 		if (thiswrite < writecount)
@@ -1204,14 +1686,107 @@
 		psf->error = SFE_SHORT_WRITE ;
 	
 	return total ;
-} /* pcm_write_d2sc */
+} /* pcm_write_f2les */
 
-int	pcm_write_d2uc	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_write_f2bet	(SF_PRIVATE *psf, float *ptr, int len)
 {	unsigned int	writecount, thiswrite ;
 	int	bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
-	double		normfact ;
+	float	normfact ;
 	
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x800000) : 1.0 ;
+
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		f2bet_array (ptr, index, (tribyte*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* pcm_write_f2bes */
+
+static int
+pcm_write_f2bei	(SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int	writecount, thiswrite ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+	float	normfact ;
+	
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x80000000) : 1.0 ;
+
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		f2bei_array (ptr, index, (int*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* pcm_write_f2bei */
+
+static int
+pcm_write_f2lei	(SF_PRIVATE *psf, float *ptr, int len)
+{	unsigned int	writecount, thiswrite ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+	float	normfact ;
+	
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x80000000) : 1.0 ;
+
+	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		f2lei_array (ptr, index, (int*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_WRITE ;
+	
+	return total ;
+} /* pcm_write_f2lei */
+
+/*-----------------------------------------------------------------------------------------------
+*/
+
+static int
+pcm_write_d2sc	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	unsigned int	writecount, thiswrite ;
+	int		bytecount, bufferlen ;
+	int		index = 0, total = 0 ;
+	double	normfact ;
+	
 	normfact = (normalize ? ((double) 0x80) : 1.0) ;
 
 	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
@@ -1218,7 +1793,7 @@
 	bytecount = len * psf->bytewidth ;
 	while (bytecount > 0)
 	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		d2uc_array (ptr, index, (unsigned char*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		d2sc_array (ptr, index, (signed char*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
 		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
 		total += thiswrite ;
 		if (thiswrite < writecount)
@@ -1232,21 +1807,22 @@
 		psf->error = SFE_SHORT_WRITE ;
 	
 	return total ;
-} /* pcm_write_d2uc */
+} /* pcm_write_d2sc */
 
-int		pcm_write_d2bes	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_write_d2uc	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int	writecount, thiswrite ;
-	int	bytecount, bufferlen ;
+	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
-	double		normfact ;
+	double	normfact ;
 	
-	normfact = (normalize ? ((double) 0x8000) : 1.0) ;
+	normfact = (normalize ? ((double) 0x80) : 1.0) ;
 
 	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
 	bytecount = len * psf->bytewidth ;
 	while (bytecount > 0)
 	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		d2bes_array (ptr, index, (short*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		d2uc_array (ptr, index, (unsigned char*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
 		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
 		total += thiswrite ;
 		if (thiswrite < writecount)
@@ -1260,13 +1836,14 @@
 		psf->error = SFE_SHORT_WRITE ;
 	
 	return total ;
-} /* pcm_write_d2bes */
+} /* pcm_write_d2uc */
 
-int		pcm_write_d2les	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_write_d2bes	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int	writecount, thiswrite ;
-	int	bytecount, bufferlen ;
+	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
-	double		normfact ;
+	double	normfact ;
 	
 	normfact = (normalize ? ((double) 0x8000) : 1.0) ;
 
@@ -1274,7 +1851,7 @@
 	bytecount = len * psf->bytewidth ;
 	while (bytecount > 0)
 	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		d2les_array (ptr, index, (short*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		d2bes_array (ptr, index, (short*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
 		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
 		total += thiswrite ;
 		if (thiswrite < writecount)
@@ -1288,21 +1865,22 @@
 		psf->error = SFE_SHORT_WRITE ;
 	
 	return total ;
-} /* pcm_write_d2les */
+} /* pcm_write_d2bes */
 
-int		pcm_write_d2let	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_write_d2les	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int	writecount, thiswrite ;
-	int	bytecount, bufferlen ;
+	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
-	double		normfact ;
+	double	normfact ;
 	
-	normfact = (normalize ? ((double) 0x800000) : 1.0) ;
+	normfact = (normalize ? ((double) 0x8000) : 1.0) ;
 
 	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
 	bytecount = len * psf->bytewidth ;
 	while (bytecount > 0)
 	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		d2let_array (ptr, index, (tribyte*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		d2les_array (ptr, index, (short*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
 		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
 		total += thiswrite ;
 		if (thiswrite < writecount)
@@ -1318,11 +1896,12 @@
 	return total ;
 } /* pcm_write_d2les */
 
-int		pcm_write_d2bet	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_write_d2let	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int	writecount, thiswrite ;
-	int	bytecount, bufferlen ;
+	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
-	double		normfact ;
+	double	normfact ;
 	
 	normfact = (normalize ? ((double) 0x800000) : 1.0) ;
 
@@ -1330,7 +1909,7 @@
 	bytecount = len * psf->bytewidth ;
 	while (bytecount > 0)
 	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		d2bet_array (ptr, index, (tribyte*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		d2let_array (ptr, index, (tribyte*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
 		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
 		total += thiswrite ;
 		if (thiswrite < writecount)
@@ -1344,21 +1923,22 @@
 		psf->error = SFE_SHORT_WRITE ;
 	
 	return total ;
-} /* pcm_write_d2bes */
+} /* pcm_write_d2les */
 
-int 	pcm_write_d2bei	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_write_d2bet	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int	writecount, thiswrite ;
-	int	bytecount, bufferlen ;
+	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
-	double		normfact ;
+	double	normfact ;
 	
-	normfact = (normalize ? ((double) 0x80000000) : 1.0) ;
+	normfact = (normalize ? ((double) 0x800000) : 1.0) ;
 
 	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
 	bytecount = len * psf->bytewidth ;
 	while (bytecount > 0)
 	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		d2bei_array (ptr, index, (int*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		d2bet_array (ptr, index, (tribyte*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
 		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
 		total += thiswrite ;
 		if (thiswrite < writecount)
@@ -1372,13 +1952,14 @@
 		psf->error = SFE_SHORT_WRITE ;
 	
 	return total ;
-} /* pcm_write_d2bei */
+} /* pcm_write_d2bes */
 
-int 	pcm_write_d2lei	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_write_d2bei	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int	writecount, thiswrite ;
-	int	bytecount, bufferlen ;
+	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
-	double		normfact ;
+	double	normfact ;
 	
 	normfact = (normalize ? ((double) 0x80000000) : 1.0) ;
 
@@ -1386,7 +1967,7 @@
 	bytecount = len * psf->bytewidth ;
 	while (bytecount > 0)
 	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		d2lei_array (ptr, index, (int*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		d2bei_array (ptr, index, (int*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
 		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
 		total += thiswrite ;
 		if (thiswrite < writecount)
@@ -1400,21 +1981,22 @@
 		psf->error = SFE_SHORT_WRITE ;
 	
 	return total ;
-} /* pcm_write_d2lei */
+} /* pcm_write_d2bei */
 
-int		pcm_write_d2f	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+pcm_write_d2lei	(SF_PRIVATE *psf, double *ptr, int len, int normalize)
 {	unsigned int	writecount, thiswrite ;
-	int	bytecount, bufferlen ;
+	int		bytecount, bufferlen ;
 	int		index = 0, total = 0 ;
-	double		normfact ;
+	double	normfact ;
 	
-	normfact = (normalize) ? 1.0 : 1.0 ;
+	normfact = (normalize ? ((double) 0x80000000) : 1.0) ;
 
 	bufferlen = SF_BUFFER_LEN - (SF_BUFFER_LEN % psf->blockwidth) ;
 	bytecount = len * psf->bytewidth ;
 	while (bytecount > 0)
 	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		d2f_array (ptr, index, (float*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		d2lei_array (ptr, index, (int*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
 		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
 		total += thiswrite ;
 		if (thiswrite < writecount)
@@ -1428,13 +2010,13 @@
 		psf->error = SFE_SHORT_WRITE ;
 	
 	return total ;
-} /* pcm_write_d2f */
+} /* pcm_write_d2lei */
 
 /*-----------------------------------------------------------------------------------------------
- */
+*/
 
-static	
-void	sc2s_array	(signed char *buffer, unsigned int count, short *ptr, int index)
+static	void	
+sc2s_array	(signed char *buffer, unsigned int count, short *ptr, int index)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	ptr [index] = ((short) buffer [k]) ;
@@ -1442,8 +2024,8 @@
 		} ;
 } /* sc2s_array */
 
-static	
-void	uc2s_array	(unsigned char *buffer, unsigned int count, short *ptr, int index)
+static	void	
+uc2s_array	(unsigned char *buffer, unsigned int count, short *ptr, int index)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	ptr [index] = ((((short) buffer [k]) - 128) % 256) ;
@@ -1451,14 +2033,14 @@
 		} ;
 } /* uc2s_array */
 
-static
-void	bet2s_array (tribyte *buffer, unsigned int count, short *ptr, int index)
+static void	
+bet2s_array (tribyte *buffer, unsigned int count, short *ptr, int index)
 {	unsigned char	*cptr ;
 	int		k ;
 	int 	value;
 	cptr = (unsigned char*) buffer ;
 	for (k = 0 ; k < count ; k++)
-	{	value = (cptr [0] << 24) | (cptr [1] << 16) | (cptr [2] << 8) ;
+	{	value = (cptr [0] << 24) + (cptr [1] << 16) + (cptr [2] << 8) ;
 		value = BE2H_INT (value) ;
 		ptr [index] = (short) (value >> 16) ;
 		index ++ ;
@@ -1466,14 +2048,14 @@
 		} ;
 } /* bet2s_array */
 
-static
-void	let2s_array (tribyte *buffer, unsigned int count, short *ptr, int index)
+static void	
+let2s_array (tribyte *buffer, unsigned int count, short *ptr, int index)
 {	unsigned char	*cptr ;
 	int		k ;
 	int 	value;
 	cptr = (unsigned char*) buffer ;
 	for (k = 0 ; k < count ; k++)
-	{	value = (cptr [0] << 8) | (cptr [1] << 16) | (cptr [2] << 24) ;
+	{	value = (cptr [0] << 8) + (cptr [1] << 16) + (cptr [2] << 24) ;
 		value = LE2H_INT (value) ;
 		ptr [index] = (short) (value >> 16) ;
 		index ++ ;
@@ -1481,8 +2063,8 @@
 		} ;
 } /* let2s_array */
 
-static
-void	bei2s_array (int *buffer, unsigned int count, short *ptr, int index)
+static void	
+bei2s_array (int *buffer, unsigned int count, short *ptr, int index)
 {	int	k ;
 	int		value ;
 	for (k = 0 ; k < count ; k++)
@@ -1492,8 +2074,8 @@
 		} ;
 } /* bei2s_array */
 
-static
-void	lei2s_array (int *buffer, unsigned int count, short *ptr, int index)
+static void	
+lei2s_array (int *buffer, unsigned int count, short *ptr, int index)
 {	int	k ;
 	int		value ;
 	for (k = 0 ; k < count ; k++)
@@ -1503,21 +2085,12 @@
 		} ;
 } /* lei2s_array */
 
-static
-void	f2s_array (float *buffer, unsigned int count, short *ptr, int index)
-{	int	k ;
-	for (k = 0 ; k < count ; k++)
-	{	ptr [index] = ((double) buffer [k]) ;
-		index ++ ;
-		} ;
-} /* f2s_array */
 
-
 /*-----------------------------------------------------------------------------------------------
- */
+*/
 
-static	
-void	sc2i_array	(signed char *buffer, unsigned int count, int *ptr, int index)
+static	void	
+sc2i_array	(signed char *buffer, unsigned int count, int *ptr, int index)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	ptr [index] = ((int) buffer [k]) ;
@@ -1525,8 +2098,8 @@
 		} ;
 } /* sc2i_array */
 
-static	
-void	uc2i_array	(unsigned char *buffer, unsigned int count, int *ptr, int index)
+static	void	
+uc2i_array	(unsigned char *buffer, unsigned int count, int *ptr, int index)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	ptr [index] = ((((int) buffer [k]) - 128) % 256) ;
@@ -1534,8 +2107,8 @@
 		} ;
 } /* uc2i_array */
 
-static
-void	bes2i_array (short *buffer, unsigned int count, int *ptr, int index)
+static void	
+bes2i_array (short *buffer, unsigned int count, int *ptr, int index)
 {	int	k ;
 	short	value ;
 	for (k = 0 ; k < count ; k++)
@@ -1545,8 +2118,8 @@
 		} ;
 } /* bes2i_array */
 
-static
-void	les2i_array (short *buffer, unsigned int count, int *ptr, int index)
+static void	
+les2i_array (short *buffer, unsigned int count, int *ptr, int index)
 {	int	k ;
 	short	value ;
 	for (k = 0 ; k < count ; k++)
@@ -1556,14 +2129,14 @@
 		} ;
 } /* les2i_array */
 
-static
-void	bet2i_array (tribyte *buffer, unsigned int count, int *ptr, int index)
+static void	
+bet2i_array (tribyte *buffer, unsigned int count, int *ptr, int index)
 {	unsigned char	*cptr ;
 	int		k ;
 	int 	value;
 	cptr = (unsigned char*) buffer ;
 	for (k = 0 ; k < count ; k++)
-	{	value = (cptr [0] << 24) | (cptr [1] << 16) | (cptr [2] << 8) ;
+	{	value = (cptr [0] << 24) + (cptr [1] << 16) + (cptr [2] << 8) ;
 		ptr [index] = value / 256 ;
 		index ++ ;
 		cptr += 3 ;
@@ -1570,14 +2143,14 @@
 		} ;
 } /* bet2i_array */
 
-static
-void	let2i_array (tribyte *buffer, unsigned int count, int *ptr, int index)
+static void	
+let2i_array (tribyte *buffer, unsigned int count, int *ptr, int index)
 {	unsigned char	*cptr ;
 	int	k ;
 	int 	value;
 	cptr = (unsigned char*) buffer ;
 	for (k = 0 ; k < count ; k++)
-	{	value = (cptr [0] << 8) | (cptr [1] << 16) | (cptr [2] << 24) ;
+	{	value = (cptr [0] << 8) + (cptr [1] << 16) + (cptr [2] << 24) ;
 		ptr [index] = value / 256 ;
 		index ++ ;
 		cptr += 3 ;
@@ -1584,21 +2157,106 @@
 		} ;
 } /* let2i_array */
 
-static
-void	f2i_array (float *buffer, unsigned int count, int *ptr, int index)
+/*-----------------------------------------------------------------------------------------------
+*/
+
+
+static	void	
+sc2f_array	(signed char *buffer, unsigned int count, float *ptr, int index, float normfact)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
-	{	ptr [index] = (int) ((double) buffer [k]) ;
+	{	ptr [index] = ((float) buffer [k]) * normfact ;
 		index ++ ;
 		} ;
-} /* f2i_array */
+} /* sc2f_array */
 
+static	void	
+uc2f_array	(unsigned char *buffer, unsigned int count, float *ptr, int index, float normfact)
+{	int	k ;
+	for (k = 0 ; k < count ; k++)
+	{	ptr [index] = ((((int) buffer [k]) - 128) % 256) * normfact ;
+		index ++ ;
+		} ;
+} /* uc2f_array */
 
+static void	
+bes2f_array (short *buffer, unsigned int count, float *ptr, int index, float normfact)
+{	int	k ;
+	short	value ;
+	for (k = 0 ; k < count ; k++)
+	{	value = BE2H_SHORT (buffer [k]) ;
+		ptr [index] = ((float) value) * normfact ;
+		index ++ ;
+		} ;
+} /* bes2f_array */
+
+static void	
+les2f_array (short *buffer, unsigned int count, float *ptr, int index, float normfact)
+{	int	k ;
+	short	value ;
+	for (k = 0 ; k < count ; k++)
+	{	value = LE2H_SHORT (buffer [k]) ;
+		ptr [index] = ((float) value) * normfact ;
+		index ++ ;
+		} ;
+} /* les2f_array */
+
+static void	
+bet2f_array (tribyte *buffer, unsigned int count, float *ptr, int index, float normfact)
+{	unsigned char	*cptr ;
+	int		k ;
+	int 	value;
+	cptr = (unsigned char*) buffer ;
+	for (k = 0 ; k < count ; k++)
+	{	value = (cptr [0] << 24) + (cptr [1] << 16) + (cptr [2] << 8) ;
+		ptr [index] = ((float) (value / 256)) * normfact ;
+		index ++ ;
+		cptr += 3 ;
+		} ;
+} /* bet2f_array */
+
+static void	
+let2f_array (tribyte *buffer, unsigned int count, float *ptr, int index, float normfact)
+{	unsigned char	*cptr ;
+	int		k ;
+	int 	value;
+	cptr = (unsigned char*) buffer ;
+	for (k = 0 ; k < count ; k++)
+	{	value = (cptr [0] << 8) + (cptr [1] << 16) + (cptr [2] << 24) ;
+		ptr [index] = ((float) (value / 256)) * normfact ;
+		index ++ ;
+		cptr += 3 ; 
+		} ;
+} /* let2f_array */
+
+static void	
+lei2f_array (int *buffer, unsigned int count, float *ptr, int index, float normfact)
+{	int	k ;
+	int		value ;
+	for (k = 0 ; k < count ; k++)
+	{	value = LE2H_INT (buffer [k]) ;
+		ptr [index] = ((float) value) * normfact ;
+		index ++ ;
+		} ;
+} /* lei2f_array */
+
+static void	
+bei2f_array (int *buffer, unsigned int count, float *ptr, int index, float normfact)
+{	int	k ;
+	int		value ;
+	for (k = 0 ; k < count ; k++)
+	{	value = BE2H_INT (buffer [k]) ;
+		ptr [index] = ((float) value) * normfact ;
+		index ++ ;
+		} ;
+} /* bei2f_array */
+
+
 /*-----------------------------------------------------------------------------------------------
- */
+*/
 
-static	
-void	sc2d_array	(signed char *buffer, unsigned int count, double *ptr, int index, double normfact)
+static	void	
+sc2d_array	(signed char *buffer, unsigned int count, double *ptr, int index, double normfact)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	ptr [index] = ((double) buffer [k]) * normfact ;
@@ -1606,8 +2264,8 @@
 		} ;
 } /* sc2d_array */
 
-static	
-void	uc2d_array	(unsigned char *buffer, unsigned int count, double *ptr, int index, double normfact)
+static	void	
+uc2d_array	(unsigned char *buffer, unsigned int count, double *ptr, int index, double normfact)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	ptr [index] = ((((int) buffer [k]) - 128) % 256) * normfact ;
@@ -1615,8 +2273,8 @@
 		} ;
 } /* uc2d_array */
 
-static
-void	bes2d_array (short *buffer, unsigned int count, double *ptr, int index, double normfact)
+static void	
+bes2d_array (short *buffer, unsigned int count, double *ptr, int index, double normfact)
 {	int	k ;
 	short	value ;
 	for (k = 0 ; k < count ; k++)
@@ -1626,8 +2284,8 @@
 		} ;
 } /* bes2d_array */
 
-static
-void	les2d_array (short *buffer, unsigned int count, double *ptr, int index, double normfact)
+static void	
+les2d_array (short *buffer, unsigned int count, double *ptr, int index, double normfact)
 {	int	k ;
 	short	value ;
 	for (k = 0 ; k < count ; k++)
@@ -1637,14 +2295,14 @@
 		} ;
 } /* les2d_array */
 
-static
-void	bet2d_array (tribyte *buffer, unsigned int count, double *ptr, int index, double normfact)
+static void	
+bet2d_array (tribyte *buffer, unsigned int count, double *ptr, int index, double normfact)
 {	unsigned char	*cptr ;
 	int		k ;
 	int 	value;
 	cptr = (unsigned char*) buffer ;
 	for (k = 0 ; k < count ; k++)
-	{	value = (cptr [0] << 24) | (cptr [1] << 16) | (cptr [2] << 8) ;
+	{	value = (cptr [0] << 24) + (cptr [1] << 16) + (cptr [2] << 8) ;
 		ptr [index] = ((double) (value / 256)) * normfact ;
 		index ++ ;
 		cptr += 3 ;
@@ -1651,14 +2309,14 @@
 		} ;
 } /* bet2d_array */
 
-static
-void	let2d_array (tribyte *buffer, unsigned int count, double *ptr, int index, double normfact)
+static void	
+let2d_array (tribyte *buffer, unsigned int count, double *ptr, int index, double normfact)
 {	unsigned char	*cptr ;
 	int		k ;
 	int 	value;
 	cptr = (unsigned char*) buffer ;
 	for (k = 0 ; k < count ; k++)
-	{	value = (cptr [0] << 8) | (cptr [1] << 16) | (cptr [2] << 24) ;
+	{	value = (cptr [0] << 8) + (cptr [1] << 16) + (cptr [2] << 24) ;
 		ptr [index] = ((double) (value / 256)) * normfact ;
 		index ++ ;
 		cptr += 3 ; 
@@ -1665,8 +2323,8 @@
 		} ;
 } /* let2d_array */
 
-static
-void	bei2d_array (int *buffer, unsigned int count, double *ptr, int index, double normfact)
+static void	
+bei2d_array (int *buffer, unsigned int count, double *ptr, int index, double normfact)
 {	int	k ;
 	int		value ;
 	for (k = 0 ; k < count ; k++)
@@ -1676,8 +2334,8 @@
 		} ;
 } /* bei2d_array */
 
-static
-void	lei2d_array (int *buffer, unsigned int count, double *ptr, int index, double normfact)
+static void	
+lei2d_array (int *buffer, unsigned int count, double *ptr, int index, double normfact)
 {	int	k ;
 	int		value ;
 	for (k = 0 ; k < count ; k++)
@@ -1687,21 +2345,11 @@
 		} ;
 } /* lei2d_array */
 
-static
-void	f2d_array (float *buffer, unsigned int count, double *ptr, int index, double normfact)
-{	int	k ;
-	for (k = 0 ; k < count ; k++)
-	{	ptr [index] = ((double) buffer [k]) * normfact ;
-		index ++ ;
-		} ;
-} /* f2d_array */
-
-
 /*-----------------------------------------------------------------------------------------------
- */
+*/
 
-static	
-void	s2sc_array	(short *ptr, int index, signed char *buffer, unsigned int count)
+static	void	
+s2sc_array	(short *ptr, int index, signed char *buffer, unsigned int count)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	buffer [k] = (signed char) (ptr [index]) ;
@@ -1709,8 +2357,8 @@
 		} ;
 } /* s2sc_array */
 
-static	
-void	s2uc_array	(short *ptr, int index, unsigned char *buffer, unsigned int count)
+static	void	
+s2uc_array	(short *ptr, int index, unsigned char *buffer, unsigned int count)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	buffer [k] = (unsigned char) (ptr [index] + 128) ;
@@ -1718,8 +2366,8 @@
 		} ;
 } /* s2uc_array */
 
-static 
-void	s2bet_array (short *ptr, int index, tribyte *buffer, unsigned int count)
+static void	
+s2bet_array (short *ptr, int index, tribyte *buffer, unsigned int count)
 {	unsigned char	*cptr ;
 	int		k, value ;
 	cptr = (unsigned char*) buffer ;
@@ -1733,8 +2381,8 @@
 		} ;
 } /* s2bet_array */
 
-static 
-void	s2let_array (short *ptr, int index, tribyte *buffer, unsigned int count)
+static void	
+s2let_array (short *ptr, int index, tribyte *buffer, unsigned int count)
 {	unsigned char	*cptr ;
 	int		k, value ;
 	cptr = (unsigned char*) buffer ;
@@ -1748,8 +2396,8 @@
 		} ;
 } /* s2let_array */
 
-static 
-void	s2bei_array (short *ptr, int index, int *buffer, unsigned int count)
+static void	
+s2bei_array (short *ptr, int index, int *buffer, unsigned int count)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	buffer [k] = H2BE_INT (ptr [index] << 16) ;
@@ -1757,8 +2405,8 @@
 		} ;
 } /* s2lei_array */
 
-static 
-void	s2lei_array (short *ptr, int index, int *buffer, unsigned int count)
+static void	
+s2lei_array (short *ptr, int index, int *buffer, unsigned int count)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	buffer [k] = H2LE_INT (ptr [index] << 16) ;
@@ -1766,21 +2414,11 @@
 		} ;
 } /* s2lei_array */
 
-static 
-void	s2f_array (short *ptr, int index, float *buffer, unsigned int count)
-{	int	k ;
-	for (k = 0 ; k < count ; k++)
-	{	buffer [k] = (float) (ptr [index]) ;
-		index ++ ;
-		} ;
-} /* s2f_array */
-
-
 /*-----------------------------------------------------------------------------------------------
- */
+*/
 
-static	
-void	i2sc_array	(int *ptr, int index, signed char *buffer, unsigned int count)
+static	void	
+i2sc_array	(int *ptr, int index, signed char *buffer, unsigned int count)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	buffer [k] = (signed char) (ptr [index]) ;
@@ -1788,8 +2426,8 @@
 		} ;
 } /* i2sc_array */
 
-static	
-void	i2uc_array	(int *ptr, int index, unsigned char *buffer, unsigned int count)
+static	void	
+i2uc_array	(int *ptr, int index, unsigned char *buffer, unsigned int count)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	buffer [k] = (unsigned char) (ptr [index] + 128) ;
@@ -1797,8 +2435,8 @@
 		} ;
 } /* i2uc_array */
 
-static 
-void	i2bes_array (int *ptr, int index, short *buffer, unsigned int count)
+static void	
+i2bes_array (int *ptr, int index, short *buffer, unsigned int count)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	buffer [k] = H2BE_SHORT (ptr [index]) ;
@@ -1806,8 +2444,8 @@
 		} ;
 } /* i2bes_array */
 
-static 
-void	i2les_array (int *ptr, int index, short *buffer, unsigned int count)
+static void	
+i2les_array (int *ptr, int index, short *buffer, unsigned int count)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
 	{	buffer [k] = H2LE_SHORT (ptr [index]) ;
@@ -1815,8 +2453,8 @@
 		} ;
 } /* i2les_array */
 
-static 
-void	i2bet_array (int *ptr, int index, tribyte *buffer, unsigned int count)
+static void	
+i2bet_array (int *ptr, int index, tribyte *buffer, unsigned int count)
 {	unsigned char	*cptr ;
 	int		k, value ;
 	cptr = (unsigned char*) buffer ;
@@ -1830,8 +2468,8 @@
 		} ;
 } /* i2bet_array */
 
-static 
-void	i2let_array (int *ptr, int index, tribyte *buffer, unsigned int count)
+static void	
+i2let_array (int *ptr, int index, tribyte *buffer, unsigned int count)
 {	unsigned char	*cptr ;
 	int		k, value ;
 	cptr = (unsigned char*) buffer ;
@@ -1845,62 +2483,139 @@
 		} ;
 } /* i2let_array */
 
-static 
-void	i2f_array (int *ptr, int index, float *buffer, unsigned int count)
+/*-----------------------------------------------------------------------------------------------
+*/
+
+static	void	
+f2sc_array	(float *ptr, int index, signed char *buffer, unsigned int count, float normfact)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
-	{	buffer [k] = (float) (ptr [index]) ;
+	{	buffer [k] = FLOAT_TO_SHORT (ptr [index] * normfact) ;
 		index ++ ;
 		} ;
-} /* i2f_array */
+} /* f2sc_array */
 
+static	void	
+f2uc_array	(float *ptr, int index, unsigned char *buffer, unsigned int count, float normfact)
+{	int	k ;
+	for (k = 0 ; k < count ; k++)
+	{	buffer [k] = FLOAT_TO_SHORT (ptr [index] * normfact) + 128 ;
+		index ++ ;
+		} ;
+} /* f2uc_array */
 
+static void	
+f2bes_array (float *ptr, int index, short *buffer, unsigned int count, float normfact)
+{	int	k ;
+	for (k = 0 ; k < count ; k++)
+	{	buffer [k] = H2BE_SHORT (FLOAT_TO_SHORT (ptr [index] * normfact)) ;
+		index ++ ;
+		} ;
+} /* f2bes_array */
+
+static void	
+f2les_array (float *ptr, int index, short *buffer, unsigned int count, float normfact)
+{	int	k ;
+	for (k = 0 ; k < count ; k++)
+	{	buffer [k] = H2LE_SHORT (FLOAT_TO_SHORT (ptr [index] * normfact)) ;
+		index ++ ;
+		} ;
+} /* f2les_array */
+
+static void	
+f2bet_array (float *ptr, int index, tribyte *buffer, unsigned int count, float normfact)
+{	unsigned char	*cptr ;
+	int		k, value ;
+	cptr = (unsigned char*) buffer ;
+	for (k = 0 ; k < count ; k++)
+	{	value = FLOAT_TO_INT (ptr [index] * normfact) ;
+		cptr [2] = (unsigned char) (value & 0xFF) ;
+		cptr [1] = (unsigned char) ((value >> 8) & 0xFF) ;
+		cptr [0] = (unsigned char) ((value >> 16) & 0xFF) ;
+		index ++ ;
+		cptr += 3 ;
+		} ;
+} /* f2bet_array */
+
+static void	
+f2let_array (float *ptr, int index, tribyte *buffer, unsigned int count, float normfact)
+{	unsigned char	*cptr ;
+	int		k, value ;
+	cptr = (unsigned char*) buffer ;	
+	for (k = 0 ; k < count ; k++)
+	{	value = FLOAT_TO_INT (ptr [index] * normfact) ;
+		cptr [0] = (unsigned char) (value & 0xFF) ;
+		cptr [1] = (unsigned char) ((value >> 8) & 0xFF) ;
+		cptr [2] = (unsigned char) ((value >> 16) & 0xFF) ;
+		index ++ ;
+		cptr += 3 ;
+		} ;
+} /* f2let_array */
+
+static void	
+f2bei_array (float *ptr, int index, int *buffer, unsigned int count, float normfact)
+{	int	k ;
+	for (k = 0 ; k < count ; k++)
+	{	buffer [k] = H2BE_INT (FLOAT_TO_INT (ptr [index] * normfact)) ;
+		index ++ ;
+		} ;
+} /* f2bei_array */
+
+static 
+void	f2lei_array (float *ptr, int index, int *buffer, unsigned int count, float normfact)
+{	int	k ;
+	for (k = 0 ; k < count ; k++)
+	{	buffer [k] = H2LE_INT (FLOAT_TO_INT (ptr [index] * normfact)) ;
+		index ++ ;
+		} ;
+} /* f2lei_array */
+
 /*-----------------------------------------------------------------------------------------------
- */
+*/
 
-static	
-void	d2sc_array	(double *ptr, int index, signed char *buffer, unsigned int count, double normfact)
+static	void	
+d2sc_array	(double *ptr, int index, signed char *buffer, unsigned int count, double normfact)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
-	{	buffer [k] = (signed char) (ptr [index] * normfact) ;
+	{	buffer [k] = DOUBLE_TO_SHORT (ptr [index] * normfact) ;
 		index ++ ;
 		} ;
 } /* d2sc_array */
 
-static	
-void	d2uc_array	(double *ptr, int index, unsigned char *buffer, unsigned int count, double normfact)
+static	void	
+d2uc_array	(double *ptr, int index, unsigned char *buffer, unsigned int count, double normfact)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
-	{	buffer [k] = (unsigned char) ((ptr [index] * normfact) + 128) ;
+	{	buffer [k] = DOUBLE_TO_SHORT (ptr [index] * normfact) + 128 ;
 		index ++ ;
 		} ;
 } /* d2uc_array */
 
-static 
-void	d2bes_array (double *ptr, int index, short *buffer, unsigned int count, double normfact)
+static void	
+d2bes_array (double *ptr, int index, short *buffer, unsigned int count, double normfact)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
-	{	buffer [k] = H2BE_SHORT ((int) (ptr [index] * normfact)) ;
+	{	buffer [k] = H2BE_SHORT (DOUBLE_TO_SHORT (ptr [index] * normfact)) ;
 		index ++ ;
 		} ;
 } /* d2bes_array */
 
-static 
-void	d2les_array (double *ptr, int index, short *buffer, unsigned int count, double normfact)
+static void	
+d2les_array (double *ptr, int index, short *buffer, unsigned int count, double normfact)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
-	{	buffer [k] = H2LE_SHORT ((int) (ptr [index] * normfact)) ;
+	{	buffer [k] = H2LE_SHORT (DOUBLE_TO_SHORT (ptr [index] * normfact)) ;
 		index ++ ;
 		} ;
 } /* d2les_array */
 
-static 
-void	d2bet_array (double *ptr, int index, tribyte *buffer, unsigned int count, double normfact)
+static void	
+d2bet_array (double *ptr, int index, tribyte *buffer, unsigned int count, double normfact)
 {	unsigned char	*cptr ;
 	int		k, value ;
 	cptr = (unsigned char*) buffer ;
 	for (k = 0 ; k < count ; k++)
-	{	value = (int) (ptr [index] * normfact) ;
+	{	value = DOUBLE_TO_INT (ptr [index] * normfact) ;
 		cptr [2] = (unsigned char) (value & 0xFF) ;
 		cptr [1] = (unsigned char) ((value >> 8) & 0xFF) ;
 		cptr [0] = (unsigned char) ((value >> 16) & 0xFF) ;
@@ -1909,13 +2624,13 @@
 		} ;
 } /* d2bet_array */
 
-static 
-void	d2let_array (double *ptr, int index, tribyte *buffer, unsigned int count, double normfact)
+static void	
+d2let_array (double *ptr, int index, tribyte *buffer, unsigned int count, double normfact)
 {	unsigned char	*cptr ;
 	int		k, value ;
 	cptr = (unsigned char*) buffer ;	
 	for (k = 0 ; k < count ; k++)
-	{	value = (int) (ptr [index] * normfact) ;
+	{	value = DOUBLE_TO_INT (ptr [index] * normfact) ;
 		cptr [0] = (unsigned char) (value & 0xFF) ;
 		cptr [1] = (unsigned char) ((value >> 8) & 0xFF) ;
 		cptr [2] = (unsigned char) ((value >> 16) & 0xFF) ;
@@ -1924,11 +2639,11 @@
 		} ;
 } /* d2let_array */
 
-static 
-void	d2bei_array (double *ptr, int index, int *buffer, unsigned int count, double normfact)
+static void	
+d2bei_array (double *ptr, int index, int *buffer, unsigned int count, double normfact)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
-	{	buffer [k] = H2BE_INT ((int) (ptr [index] * normfact)) ;
+	{	buffer [k] = H2BE_INT (DOUBLE_TO_INT (ptr [index] * normfact)) ;
 		index ++ ;
 		} ;
 } /* d2bei_array */
@@ -1937,19 +2652,8 @@
 void	d2lei_array (double *ptr, int index, int *buffer, unsigned int count, double normfact)
 {	int	k ;
 	for (k = 0 ; k < count ; k++)
-	{	buffer [k] = H2LE_INT ((int) (ptr [index] * normfact)) ;
+	{	buffer [k] = H2LE_INT (DOUBLE_TO_INT (ptr [index] * normfact)) ;
 		index ++ ;
 		} ;
 } /* d2lei_array */
-
-static 
-void	d2f_array (double *ptr, int index, float *buffer, unsigned int count, double normfact)
-{	int	k ;
-	for (k = 0 ; k < count ; k++)
-	{	buffer [k] = (float) (ptr [index] * normfact) ;
-		index ++ ;
-		} ;
-} /* d2f_array */
-
-
 
--- a/common/libsndfile/src/pcm.h
+++ /dev/null
@@ -1,81 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU Lesser General Public License for more details.
-** 
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-int		pcm_read_sc2s	 (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_read_uc2s	 (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_read_bes2s (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_read_les2s (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_read_bet2s (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_read_let2s (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_read_bei2s (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_read_lei2s (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_read_f2s   (SF_PRIVATE *psf, short *ptr, int len) ;
-
-int		pcm_read_sc2i	 (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_read_uc2i	 (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_read_bes2i (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_read_les2i (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_read_bet2i (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_read_let2i (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_read_bei2i (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_read_lei2i (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_read_f2i   (SF_PRIVATE *psf, int *ptr, int len) ;
-
-int		pcm_read_sc2d	 (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_read_uc2d	 (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_read_bes2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_read_les2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_read_bet2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_read_let2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_read_bei2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_read_lei2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_read_f2d   (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-
-
-
-int		pcm_write_s2sc  (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_write_s2uc  (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_write_s2bes (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_write_s2les (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_write_s2bet (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_write_s2let (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_write_s2bei (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_write_s2lei (SF_PRIVATE *psf, short *ptr, int len) ;
-int		pcm_write_s2f   (SF_PRIVATE *psf, short *ptr, int len) ;
-
-int		pcm_write_i2sc  (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_write_i2uc  (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_write_i2bes (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_write_i2les (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_write_i2bet (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_write_i2let (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_write_i2bei (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_write_i2lei (SF_PRIVATE *psf, int *ptr, int len) ;
-int		pcm_write_i2f   (SF_PRIVATE *psf, int *ptr, int len) ;
-
-int		pcm_write_d2sc  (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_write_d2uc  (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_write_d2bes (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_write_d2les (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_write_d2bet (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_write_d2let (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_write_d2bei (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_write_d2lei (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-int		pcm_write_d2f   (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-
--- a/common/libsndfile/src/raw.c
+++ b/common/libsndfile/src/raw.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -27,11 +27,8 @@
 #include	"config.h"
 #include	"sfendian.h"
 #include	"common.h"
-#include	"pcm.h"
 
-/*------------------------------------------------------------------------------
-** Private static functions.
-*/
+static long	raw_seek   (SF_PRIVATE *psf, long offset, int whence) ;
 
 /*------------------------------------------------------------------------------
 ** Public functions.
@@ -39,82 +36,38 @@
 
 int 	raw_open_read	(SF_PRIVATE *psf)
 {	unsigned int subformat ;
-
+	int			error ;
+	
 	if(! psf->sf.channels || ! psf->sf.pcmbitwidth)
 		return SFE_RAW_READ_BAD_SPEC ;
 		
 	subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
 
+	psf->endian = 0 ;
+
 	if (subformat == SF_FORMAT_PCM_BE)
 		psf->endian = SF_ENDIAN_BIG ;
 	else if (subformat == SF_FORMAT_PCM_LE)
 		psf->endian = SF_ENDIAN_LITTLE ;
-	else if (subformat == SF_FORMAT_PCM_S8 || subformat == SF_FORMAT_PCM_U8)
-		psf->endian = 0 ;
+	else if (subformat == SF_FORMAT_PCM_S8)
+		psf->chars = SF_CHARS_SIGNED ;
+	else if (subformat == SF_FORMAT_PCM_U8)
+		psf->chars = SF_CHARS_UNSIGNED ;
 	else
 		return SFE_RAW_READ_BAD_SPEC ;
 		
+	psf->seek_func = (func_seek) raw_seek ;
+
 	psf->sf.seekable = SF_TRUE ;
- 	
 	psf->sf.sections = 1 ;
 
-	switch (psf->sf.pcmbitwidth)
-	{	case   8 :	if (subformat == SF_FORMAT_PCM_S8)
-					{	psf->read_short  = (func_short)  pcm_read_sc2s ;
-						psf->read_int    = (func_int)    pcm_read_sc2i ;
-						psf->read_double = (func_double) pcm_read_sc2d ;
-	  					}
-					else if (subformat == SF_FORMAT_PCM_U8)
-					{	psf->read_short  = (func_short)  pcm_read_uc2s ;
-						psf->read_int    = (func_int)    pcm_read_uc2i ;
-						psf->read_double = (func_double) pcm_read_uc2d ;
-	  					}
-					break ;					
-	
-		case  16 :	if (subformat == SF_FORMAT_PCM_BE)
-					{	psf->read_short  = (func_short)  pcm_read_bes2s ;
-						psf->read_int    = (func_int)    pcm_read_bes2i ;
-						psf->read_double = (func_double) pcm_read_bes2d ;
-						}
-					else
-					{	psf->read_short  = (func_short)  pcm_read_les2s ;
-						psf->read_int    = (func_int)    pcm_read_les2i ;
-						psf->read_double = (func_double) pcm_read_les2d ;
-						} ;
-					break ;
-
-		case  24 :	if (subformat == SF_FORMAT_PCM_BE)
-					{	psf->read_short  = (func_short)  pcm_read_bet2s ;
-						psf->read_int    = (func_int)    pcm_read_bet2i ;
-						psf->read_double = (func_double) pcm_read_bet2d ;
-						}
-					else
-					{	psf->read_short  = (func_short)  pcm_read_let2s ;
-						psf->read_int    = (func_int)    pcm_read_let2i ;
-						psf->read_double = (func_double) pcm_read_let2d ;
-						} ;
-					break ;
-
-		case  32 :	if (subformat == SF_FORMAT_PCM_BE)
-					{	psf->read_short  = (func_short)  pcm_read_bei2s ;
-						psf->read_int    = (func_int)    pcm_read_bei2i ;
-						psf->read_double = (func_double) pcm_read_bei2d ;
-						}
-					else
-					{	psf->read_short  = (func_short)  pcm_read_lei2s ;
-						psf->read_int    = (func_int)    pcm_read_lei2i ;
-						psf->read_double = (func_double) pcm_read_lei2d ;
-						} ;
-					break ;
-					
-		default :   return SFE_RAW_BAD_BITWIDTH ;
-					break ;
-		} ;
-
 	psf->dataoffset = 0 ;
 	psf->bytewidth  = BITWIDTH2BYTES (psf->sf.pcmbitwidth) ;
 	psf->blockwidth = psf->sf.channels * psf->bytewidth ;
 
+	if ((error = pcm_read_init (psf)))
+		return error ;
+		
 	if (psf->blockwidth)
 		psf->sf.samples = psf->filelength / psf->blockwidth ;
 
@@ -130,7 +83,8 @@
 
 int 	raw_open_write	(SF_PRIVATE *psf)
 {	unsigned int	subformat, big_endian_file ;
-	
+	int error ;
+		
 	subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
 
 	if (subformat == SF_FORMAT_PCM_BE)
@@ -152,57 +106,13 @@
 	psf->filelength  = psf->datalength ;
 	psf->error       = 0 ;
 
-	switch (psf->sf.pcmbitwidth)
-	{	case   8 :	if (subformat == SF_FORMAT_PCM_S8)
-					{	psf->write_short  = (func_short)  pcm_write_s2sc ;
-						psf->write_int    = (func_int)    pcm_write_i2sc ;
-						psf->write_double = (func_double) pcm_write_d2sc ;
-	  					}
-					else if (subformat == SF_FORMAT_PCM_U8)
-					{	psf->write_short  = (func_short)  pcm_write_s2uc ;
-						psf->write_int    = (func_int)    pcm_write_i2uc ;
-						psf->write_double = (func_double) pcm_write_d2uc ;
-	  					}
-					break ;					
+	if (subformat == SF_FORMAT_PCM_S8)
+		psf->chars = SF_CHARS_SIGNED ;
+	else if (subformat == SF_FORMAT_PCM_U8)
+		psf->chars = SF_CHARS_UNSIGNED ;
 	
-		case  16 :	if (big_endian_file)
-					{	psf->write_short  = (func_short)  pcm_write_s2bes ;
-						psf->write_int    = (func_int)    pcm_write_i2bes ;
-						psf->write_double = (func_double) pcm_write_d2bes ;
-						}
-					else
-					{	psf->write_short  = (func_short)  pcm_write_s2les ;
-						psf->write_int    = (func_int)    pcm_write_i2les ;
-						psf->write_double = (func_double) pcm_write_d2les ;
-						} ;
-					break ;
-
-		case  24 :	if (big_endian_file)
-					{	psf->write_short  = (func_short)  pcm_write_s2bet ;
-						psf->write_int    = (func_int)    pcm_write_i2bet ;
-						psf->write_double = (func_double) pcm_write_d2bet ;
-						}
-					else
-					{	psf->write_short  = (func_short)  pcm_write_s2let ;
-						psf->write_int    = (func_int)    pcm_write_i2let ;
-						psf->write_double = (func_double) pcm_write_d2let ;
-						} ;
-					break ;
-
-		case  32 :	if (big_endian_file)
-					{	psf->write_short  = (func_short)  pcm_write_s2bei ;
-						psf->write_int    = (func_int)    pcm_write_i2bei ;
-						psf->write_double = (func_double) pcm_write_d2bei ;
-						}
-					else
-					{	psf->write_short  = (func_short)  pcm_write_s2lei ;
-						psf->write_int    = (func_int)    pcm_write_i2lei ;
-						psf->write_double = (func_double) pcm_write_d2lei ;
-						} ;
-					break ;
-					
-		default :   return	SFE_BAD_OPEN_FORMAT ;
-		} ;
+	if ((error = pcm_write_init (psf)))
+		return error ;
 		
 	return 0 ;
 } /* raw_open_write */
@@ -210,7 +120,57 @@
 /*------------------------------------------------------------------------------
 */
 
+static long
+raw_seek   (SF_PRIVATE *psf, long offset, int whence)
+{	long position ;
 
-/*==============================================================================
-*/
+	if (! (psf->blockwidth && psf->datalength))
+	{	psf->error = SFE_BAD_SEEK ;
+		return	((long) -1) ;
+		} ;
+
+	position = ftell (psf->file) ;
+	offset = offset * psf->blockwidth ;
+		
+	switch (whence)
+	{	case SEEK_SET :
+				if (offset < 0 || offset > psf->datalength)
+				{	psf->error = SFE_BAD_SEEK ;
+					return	((long) -1) ;
+					} ;
+				break ;
+				
+		case SEEK_CUR :
+				if (psf->current + offset < 0 || psf->current + offset > psf->datalength)
+				{	psf->error = SFE_BAD_SEEK ;
+					return	((long) -1) ;
+					} ;
+				offset = position + offset ;
+				break ;
+				
+		case SEEK_END :
+				if (offset > 0 || psf->datalength + offset < 0)
+				{	psf->error = SFE_BAD_SEEK ;
+					return	((long) -1) ;
+					} ;
+				offset = psf->datalength + offset ;
+				break ;
+				
+		default : 
+				psf->error = SFE_BAD_SEEK ;
+				return	((long) -1) ;
+		} ;
+		
+	if (psf->mode == SF_MODE_READ)
+		fseek (psf->file, offset, SEEK_SET) ;
+	else
+	{	/* What to do about write??? */ 
+		psf->error = SFE_BAD_SEEK ;
+		return	((long) -1) ;
+		} ;
+
+	psf->current = offset / psf->blockwidth ;
+
+	return psf->current ;
+} /* raw_seek */
 
--- /dev/null
+++ b/common/libsndfile/src/samplitude.c
@@ -1,0 +1,125 @@
+/*
+** Copyright (C) 2000-2001 Erik de Castro Lopo <erikd@zip.com.au>
+**  
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU Lesser General Public License for more details.
+** 
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software 
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+#include	<stdio.h>
+#include	<unistd.h>
+#include	<string.h>
+#include	<ctype.h>
+#include	<stdarg.h>
+
+#include	"sndfile.h"
+#include	"config.h"
+#include	"sfendian.h"
+#include	"common.h"
+
+
+/*------------------------------------------------------------------------------
+ * Macros to handle big/little endian issues.
+*/
+
+#if (CPU_IS_LITTLE_ENDIAN == 1)
+#	define	MAKE_MARKER(a,b,c,d)		((a)|((b)<<8)|((c)<<16)|((d)<<24))
+#elif (CPU_IS_BIG_ENDIAN == 1)
+#	define	MAKE_MARKER(a,b,c,d)		(((a)<<24)|((b)<<16)|((c)<<8)|(d))
+#else
+#	error "Cannot determine endian-ness of processor."
+#endif
+
+#define SEKD_MARKER	(MAKE_MARKER ('S', 'E', 'K', 'D'))
+#define SAMR_MARKER	(MAKE_MARKER ('S', 'A', 'M', 'R'))
+
+/*------------------------------------------------------------------------------
+ * Typedefs for file chunks.
+*/
+
+typedef struct
+{	unsigned int	sekd, samr ;
+	int				unknown0 ;
+	int				bitspersample ;
+	int				unknown1, unknown2 ;
+	int				poss_len ;
+	int				samplerate ;
+	int				channels ;
+} RAP_CHUNK ;
+
+
+/*------------------------------------------------------------------------------
+ * Private static functions.
+*/
+
+static	int		smpltd_close	(SF_PRIVATE  *psf) ;
+
+
+/*------------------------------------------------------------------------------
+** Public functions.
+*/
+
+int 	smpltd_open_read	(SF_PRIVATE *psf)
+{	RAP_CHUNK rap ;
+	
+	psf_binheader_readf (psf, "mm", &(rap.sekd), &(rap.samr)) ;
+	if (rap.sekd != SEKD_MARKER)
+		return SFE_SMTD_NO_SEKD ;
+	if (rap.samr != SAMR_MARKER)
+		return SFE_SMTD_NO_SAMR ;
+	
+/*-
+	printf ("Here we are!\n") ;	
+
+	printf ("unknown0        : %d\n", rap.unknown0) ;
+	printf ("bits per sample : %d\n", rap.bitspersample) ;
+	printf ("unknown1        : %d\n", rap.unknown1) ;
+	printf ("unknown2        : %d\n", rap.unknown2) ;
+	printf ("poss_len        : %d\n", rap.poss_len) ;
+	printf ("sample rate     : %d\n", rap.samplerate) ;
+	printf ("channels        : %d\n", rap.channels) ;
+		
+-*/
+	psf->close = (func_close) smpltd_close ;
+
+	return 0 ;
+} /* smpltd_open_read */
+
+int 	
+smpltd_open_write	(SF_PRIVATE *psf)
+{	
+
+	return 0 ;
+} /* smpltd_open_write */
+
+/*------------------------------------------------------------------------------
+*/
+
+static int	
+smpltd_close	(SF_PRIVATE  *psf)
+{	
+	if (psf->mode == SF_MODE_WRITE)
+	{	/*  Now we know for certain the length of the file we can re-write 
+		**	correct values for the FORM, 8SVX and BODY chunks.
+		*/
+                
+		} ;
+
+	if (psf->fdata)
+		free (psf->fdata) ;
+	psf->fdata = NULL ;
+	
+	return 0 ;
+} /* smpltd_close */
+
--- a/common/libsndfile/src/sfendian.h
+++ b/common/libsndfile/src/sfendian.h
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -74,5 +74,13 @@
 
 #else
 	#error "Cannot determine endian-ness of processor."
+#endif
+
+#if (CPU_IS_LITTLE_ENDIAN == 1)
+#	define	MAKE_MARKER(a,b,c,d)		((a)|((b)<<8)|((c)<<16)|((d)<<24))
+#elif (CPU_IS_BIG_ENDIAN == 1)
+#	define	MAKE_MARKER(a,b,c,d)		(((a)<<24)|((b)<<16)|((c)<<8)|(d))
+#else
+#	error "Cannot determine endian-ness of processor."
 #endif
 
--- a/common/libsndfile/src/sndfile.c
+++ b/common/libsndfile/src/sndfile.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -21,6 +21,7 @@
 #include	<fcntl.h>
 #include	<string.h>
 #include	<ctype.h>
+#include	<math.h>
 
 /* For the Metrowerks CodeWarrior Pro Compiler (mainly MacOS) */
 
@@ -35,14 +36,6 @@
 #include	"sfendian.h"
 #include	"common.h"
 
-#if (CPU_IS_LITTLE_ENDIAN == 1)
-#	define	MAKE_MARKER(a,b,c,d)		((a)|((b)<<8)|((c)<<16)|((d)<<24))
-#elif (CPU_IS_BIG_ENDIAN == 1)
-#	define	MAKE_MARKER(a,b,c,d)		(((a)<<24)|((b)<<16)|((c)<<8)|(d))
-#else
-#	error "Cannot determine endian-ness of processor."
-#endif
-
 #define		SNDFILE_MAGICK	0x1234C0DE
 
 typedef struct
@@ -76,6 +69,7 @@
 	{	SFE_SHORT_READ			, "Short read error." },
 	{	SFE_SHORT_WRITE			, "Short write error." },
 	{	SFE_INTERNAL			, "Unspecified internal error." },
+	{	SFE_BAD_CONTROL_CMD		, "Bad command passed to function sf_command()." },
 	
 	{	SFE_WAV_NO_RIFF			, "Error in WAV file. No 'RIFF' chunk marker." },
 	{	SFE_WAV_NO_WAVE			, "Error in WAV file. No 'WAVE' chunk marker." },
@@ -83,6 +77,9 @@
 	{	SFE_WAV_FMT_SHORT		, "Error in WAV file. Short 'fmt ' chunk." },
 
 	{	SFE_WAV_FMT_TOO_BIG		, "Error in WAV file. 'fmt ' chunk too large." },
+	{	SFE_WAV_BAD_FACT		, "Error in WAV file. 'fact' chunk out of place." },
+	{	SFE_WAV_BAD_PEAK		, "Error in WAV file. Bad 'PEAK' chunk." },
+	{	SFE_WAV_PEAK_B4_FMT		, "Error in WAV file. 'PEAK' chunk found before 'fmt ' chunk." },
 
 	{	SFE_WAV_BAD_FORMAT		, "Error in WAV file. Errors in 'fmt ' chunk." },
 	{	SFE_WAV_BAD_BLOCKALIGN	, "Error in WAV file. Block alignment in 'fmt ' chunk is incorrect." },
@@ -89,50 +86,78 @@
 	{	SFE_WAV_NO_DATA			, "Error in WAV file. No 'data' chunk marker." },
 	{	SFE_WAV_UNKNOWN_CHUNK	, "Error in WAV file. File contains an unknown chunk marker." },
 	
-	{	SFE_WAV_ADPCM_NOT4BIT	, "Error in ADPCM WAV file. Invalid bit width."},
-	{	SFE_WAV_ADPCM_CHANNELS	, "Error in ADPCM WAV file. Invalid number of channels."},
-	{	SFE_WAV_GSM610_FORMAT	, "Error in GSM610 WAV file. Invalid format chunk."},
+	{	SFE_WAV_ADPCM_NOT4BIT	, "Error in ADPCM WAV file. Invalid bit width." },
+	{	SFE_WAV_ADPCM_CHANNELS	, "Error in ADPCM WAV file. Invalid number of channels." },
+	{	SFE_WAV_GSM610_FORMAT	, "Error in GSM610 WAV file. Invalid format chunk." },
   
-	{	SFE_AIFF_NO_FORM		, "Error in AIFF file, bad 'FORM' marker."},
-	{	SFE_AIFF_UNKNOWN_CHUNK	, "Error in AIFF file, unknown chunk."},
-	{	SFE_COMM_CHUNK_SIZE		, "Error in AIFF file, bad 'COMM' chunk size."},
-	{	SFE_AIFF_NO_SSND		, "Error in AIFF file, bad 'SSND' chunk."},
-	{	SFE_AIFF_NO_DATA		, "Error in AIFF file, no sound data."},
+	{	SFE_AIFF_NO_FORM		, "Error in AIFF file, bad 'FORM' marker." },
+	{	SFE_AIFF_AIFF_NO_FORM	, "Error in AIFF file, 'AIFF' marker without 'FORM'." },
+	{	SFE_AIFF_COMM_NO_FORM	, "Error in AIFF file, 'COMM' marker without 'FORM'." },
+	{	SFE_AIFF_SSND_NO_COMM	, "Error in AIFF file, 'SSND' marker without 'COMM'." },
+	{	SFE_AIFF_UNKNOWN_CHUNK	, "Error in AIFF file, unknown chunk." },
+	{	SFE_AIFF_COMM_CHUNK_SIZE, "Error in AIFF file, bad 'COMM' chunk size." },
+	{	SFE_AIFF_BAD_COMM_CHUNK , "Error in AIFF file, bad 'COMM' chunk." },
+	{	SFE_AIFF_PEAK_B4_COMM	, "Error in AIFF file. 'PEAK' chunk found before 'COMM' chunk." },
+	{	SFE_AIFF_BAD_PEAK		, "Error in AIFF file. Bad 'PEAK' chunk." },
+	{	SFE_AIFF_NO_SSND		, "Error in AIFF file, bad 'SSND' chunk." },
+	{	SFE_AIFF_NO_DATA		, "Error in AIFF file, no sound data." },
 	
-	{	SFE_AU_UNKNOWN_FORMAT	, "Error in AU file, unknown format."},
-	{	SFE_AU_NO_DOTSND		, "Error in AU file, missing '.snd' or 'dns.' marker."},
+	{	SFE_AU_UNKNOWN_FORMAT	, "Error in AU file, unknown format." },
+	{	SFE_AU_NO_DOTSND		, "Error in AU file, missing '.snd' or 'dns.' marker." },
 
-	{	SFE_RAW_READ_BAD_SPEC	, "Error while opening RAW file for read. Must specify format, pcmbitwidth and channels."},
-	{	SFE_RAW_BAD_BITWIDTH	, "Error. RAW file bitwidth must be a multiple of 8."},
+	{	SFE_RAW_READ_BAD_SPEC	, "Error while opening RAW file for read. Must specify format, pcmbitwidth and channels." },
+	{	SFE_RAW_BAD_BITWIDTH	, "Error. RAW file bitwidth must be a multiple of 8." },
 
-	{	SFE_PAF_NO_MARKER		, "Error in PAF file, no marker."},
-	{	SFE_PAF_VERSION			, "Error in PAF file, bad version."}, 
-	{	SFE_PAF_UNKNOWN_FORMAT	, "Error in PAF file, unknown format."}, 
-	{	SFE_PAF_SHORT_HEADER	, "Error in PAF file. File shorter than minimal header."},
+	{	SFE_PAF_NO_MARKER		, "Error in PAF file, no marker." },
+	{	SFE_PAF_VERSION			, "Error in PAF file, bad version." }, 
+	{	SFE_PAF_UNKNOWN_FORMAT	, "Error in PAF file, unknown format." }, 
+	{	SFE_PAF_SHORT_HEADER	, "Error in PAF file. File shorter than minimal header." },
 	
-	{	SFE_SVX_NO_FORM			, "Error in 8SVX / 16SV file, no 'FORM' marker."}, 
-	{	SFE_SVX_NO_BODY			, "Error in 8SVX / 16SV file, no 'BODY' marker."}, 
-	{	SFE_SVX_NO_DATA			, "Error in 8SVX / 16SV file, no sound data."},
-	{	SFE_SVX_BAD_COMP		, "Error in 8SVX / 16SV file, unsupported compression format."},
+	{	SFE_SVX_NO_FORM			, "Error in 8SVX / 16SV file, no 'FORM' marker." }, 
+	{	SFE_SVX_NO_BODY			, "Error in 8SVX / 16SV file, no 'BODY' marker." }, 
+	{	SFE_SVX_NO_DATA			, "Error in 8SVX / 16SV file, no sound data." },
+	{	SFE_SVX_BAD_COMP		, "Error in 8SVX / 16SV file, unsupported compression format." },
 	
-	{	SFE_NIST_BAD_HEADER		, "Error in NIST file, bad header."},
-	{	SFE_NIST_BAD_ENCODING	, "Error in NIST file, unsupported compression format."},
+	{	SFE_NIST_BAD_HEADER		, "Error in NIST file, bad header." },
+	{	SFE_NIST_BAD_ENCODING	, "Error in NIST file, unsupported compression format." },
 
+	{	SFE_SMTD_NO_SEKD		, "Error in Samplitude file, no 'SEKD' marker." },  
+	{	SFE_SMTD_NO_SAMR		, "Error in Samplitude file, no 'SAMR' marker." }, 
+
+	{	SFE_VOC_NO_CREATIVE		, "Error in VOC file, no 'Creative Voice File' marker." }, 
+	{	SFE_VOC_BAD_VERSION		, "Error in VOC file, bad version number." }, 
+	{	SFE_VOC_BAD_MARKER		, "Error in VOC file, bad marker in file." }, 
+
+	{	SFE_IRCAM_NO_MARKER		, "Error in IRCAM file, bad IRCAM marker." }, 
+	{	SFE_IRCAM_BAD_CHANNELS	, "Error in IRCAM file, bad channel count." }, 
+	{	SFE_IRCAM_UNKNOWN_FORMAT, "Error in IRCAM file, unknow encoding format." }, 
+
 	{	SFE_MAX_ERROR			, "Maximum error number." }
 } ;
 
 /*------------------------------------------------------------------------------
+*/
+
+static int 	does_extension_match (const char *ext, const char *test) ;
+static int 	is_au_snd_file (const char *filename) ;
+static int	guess_file_type (SF_PRIVATE *psf, const char *filename) ;
+static int	validate_sfinfo (SF_INFO *sfinfo) ;
+static int	validate_psf (SF_PRIVATE *psf) ;
+static void save_header_info (SF_PRIVATE *psf) ;
+static void	copy_filename (SF_PRIVATE *psf, const char *path) ;
+
+static int	hash_command (const char *cmd) ;
+
+/*------------------------------------------------------------------------------
 ** Private (static) variables.
 */
 
 static	int		sf_errno = 0 ;
-static	char	sf_strbuffer [SF_BUFFER_LEN] = { 0 } ;
+static	char	sf_logbuffer [SF_BUFFER_LEN] = { 0 } ;
 
 /*------------------------------------------------------------------------------
-** Private static functions.
 */
 
-
 #define	VALIDATE_SNDFILE_AND_ASSIGN_PSF(a,b)		\
 		{	if (! (a))								\
 				return SFE_BAD_SNDFILE_PTR ;		\
@@ -139,154 +164,27 @@
 			(b) = (SF_PRIVATE*) (a) ;				\
 			if (!((b)->file))						\
 				return SFE_BAD_INT_FD ;				\
-			if ((b)->Magick != SNDFILE_MAGICK)			\
+			if ((b)->Magick != SNDFILE_MAGICK)		\
 				return	SFE_BAD_SNDFILE_PTR ;		\
 			(b)->error = 0 ;						\
 			} 
 
-static
-int does_extension_match (const char *ext, const char *test)
-{	char c1, c2 ;
-
-	if ((! ext) || (! test))
-		return 0 ;
-
-	if (strlen (ext) != strlen (test))
-		return 0 ;
-
-	while (*ext && *test)
-	{	c1 = tolower (*ext) ;
-		c2 = tolower (*test) ;
-		if (c1 > c2)
-			return 0 ;
-		if (c1 < c2)
-			return 0 ;
-		ext ++ ;
-		test ++ ;
-		} 
-
-	return 1 ;
-} /* does_extension_match */
-
-static
-int is_au_snd_file (const char *filename)
-{	const char *cptr ;
-
-	if (! (cptr = strrchr (filename, '.')))
-		return 0 ;
-	cptr ++ ;
-	
-	if (does_extension_match (cptr, "au"))
-		return 1 ;
-		
-	if (does_extension_match (cptr, "snd"))
-		return 1 ;
-		
-	return 0 ;
-} /* is_au_snd_file */
-
-static
-int guess_file_type (FILE *file, const char *filename)
-{	unsigned int buffer [3] ;
-
-	fread (buffer, sizeof(buffer), 1, file) ;
-	fseek (file, 0, SEEK_SET) ;
-
-	if (buffer [0] == MAKE_MARKER ('R','I','F','F') && buffer [2] == MAKE_MARKER ('W','A','V','E'))
-		return SF_FORMAT_WAV ;
-		
-	if (buffer [0] == MAKE_MARKER ('F','O','R','M'))
-	{	if (buffer [2] == MAKE_MARKER ('A','I','F','F') || buffer [2] == MAKE_MARKER ('A','I','F','C'))
-			return SF_FORMAT_AIFF ;
-		if (buffer [2] == MAKE_MARKER ('8','S','V','X') || buffer [2] == MAKE_MARKER ('1','6','S','V'))
-			return SF_FORMAT_SVX ;
-		return 0 ;
-		} ;
-		
-	if ((buffer [0] == MAKE_MARKER ('.','s','n','d') || buffer [0] == MAKE_MARKER ('d','n','s','.')))
-		return SF_FORMAT_AU ;
-		
-	if ((buffer [0] == MAKE_MARKER ('f','a','p',' ') || buffer [0] == MAKE_MARKER (' ','p','a','f')))
-		return SF_FORMAT_PAF ;
-	
-	if (buffer [0] == MAKE_MARKER ('N','I','S','T'))
-		return SF_FORMAT_NIST ;
-		
-	if (filename && is_au_snd_file (filename))
-		return SF_FORMAT_AU | SF_FORMAT_ULAW ;
-
-	/* Default to header-less RAW PCM file type. */
-	return SF_FORMAT_RAW ;
-} /* guess_file_type */
-
-
-static
-int validate_sfinfo (SF_INFO *sfinfo)
-{	if (! sfinfo->samplerate)
-		return 0 ;	
-	if (! sfinfo->samples)
-		return 0 ;	
-	if (! sfinfo->channels)
-		return 0 ;	
-	if (! sfinfo->pcmbitwidth)
-		return 0 ;	
-	if (! sfinfo->format & SF_FORMAT_TYPEMASK)
-		return 0 ;	
-	if (! sfinfo->format & SF_FORMAT_SUBMASK)
-		return 0 ;	
-	if (! sfinfo->sections)
-		return 0 ;	
-	return 1 ;
-} /* validate_sfinfo */
-
-static
-int validate_psf (SF_PRIVATE *psf)
-{	if (! psf->blockwidth)
-		return 0 ;	
-	if (! psf->bytewidth)
-		return 0 ;	
-	if (! psf->datalength)
-		return 0 ;
-	if (psf->blockwidth != psf->sf.channels * psf->bytewidth)
-		return 0 ;	
-	return 1 ;
-} /* validate_psf */
-
-static
-void save_header_info (SF_PRIVATE *psf)
-{	memset (sf_strbuffer, 0, sizeof (sf_strbuffer)) ;
-	strcpy (sf_strbuffer, psf->strbuffer) ;
-} /* validate_psf */
-
-static	
-void copy_filename (SF_PRIVATE *psf, const char *path)
-{	const char *cptr ;
-
-	if ((cptr = strrchr (path, '/')) || (cptr = strrchr (path, '\\')))
-		cptr ++ ;
-	else
-		cptr = path ;
-		
-	memset (psf->filename, 0, SF_FILENAME_LEN) ;
-	strncpy (psf->filename, cptr, SF_FILENAME_LEN - 1) ;
-	psf->filename [SF_FILENAME_LEN - 1] = 0 ;
-} /* copy_filename */
-
 /*------------------------------------------------------------------------------
 **	Public functions.
 */
 
-SNDFILE* 	sf_open_read	(const char *path, SF_INFO *sfinfo)
+SNDFILE*
+sf_open_read	(const char *path, SF_INFO *sfinfo)
 {	SF_PRIVATE 	*psf ;
-	int			filetype, seekable ;
+	int			filetype ;
 	
 	if (! sfinfo)
 	{	sf_errno = SFE_BAD_SF_INFO_PTR ;
 		return	NULL ;
 		} ;
-
+		
 	sf_errno = 0 ;
-	sf_strbuffer [0] = 0 ;
+	sf_logbuffer [0] = 0 ;
 	
 	psf = malloc (sizeof (SF_PRIVATE)) ; 
 	if (! psf)
@@ -299,12 +197,15 @@
 
 	if (! strcmp (path, "-"))
 	{	psf->file = stdin ;
-		seekable = SF_FALSE ;
+		psf->sf.seekable = SF_FALSE ;
 		}
 	else
 	{	/* fopen with 'b' means binary file mode for Win32 systems. */
-		psf->file = fopen (path, "rb") ;
-		seekable = SF_TRUE ;
+		if (! (psf->file = fopen (path, "rb")))
+		{	sf_errno = SFE_OPEN_FAILED ;
+			return NULL ;
+			} ;
+		psf->sf.seekable = SF_TRUE ;
 		} ;
 		 
 	if (! psf->file) 
@@ -315,20 +216,25 @@
 	
 	psf->mode = SF_MODE_READ ;
 	
-	psf_sprintf (psf, "%s\n", path) ;
-	if (seekable)
+	psf_log_printf (psf, "%s\n", path) ;
+	if (psf->sf.seekable)
 	{	fseek (psf->file, 0, SEEK_END) ;
 		psf->filelength = ftell (psf->file) ;
 		fseek (psf->file, 0, SEEK_SET) ;
-		psf_sprintf (psf, "size : %d\n", psf->filelength) ;
+		psf_log_printf (psf, "size : %d\n", psf->filelength) ;
 		}
 	else
-		psf->filelength = 2048 ;
+		psf->filelength = 0x7FFF0000 ;  /* Stupidly big number. */
 	
 	copy_filename (psf, path) ;
 	
-	filetype = guess_file_type (psf->file, psf->filename) ;
-	fseek (psf->file, 0, SEEK_SET) ;
+	if ((sfinfo->format & SF_FORMAT_TYPEMASK) == SF_FORMAT_RAW && sfinfo->channels && sfinfo->pcmbitwidth)
+		filetype = SF_FORMAT_RAW ;
+	else
+	{	memset (sfinfo, 0, sizeof (SF_INFO)) ;
+		filetype = guess_file_type (psf, psf->filename) ;
+		} ;
+		
 	switch (filetype)
 	{	case	SF_FORMAT_WAV :
 				sf_errno = wav_open_read (psf) ;
@@ -342,11 +248,6 @@
 				sf_errno = au_open_read (psf) ;
 				break ;
 
-		case	SF_FORMAT_AU | SF_FORMAT_ULAW :
-				psf_sprintf (psf, "Headers-less u-law encoded file.\n") ;
-				sf_errno = au_nh_open_read (psf) ;
-				break ;
-
 		case	SF_FORMAT_RAW :
 				/* For RAW files, need the sfinfo struct data to
 				** figure out the bitwidth, endian-ness etc.
@@ -363,12 +264,28 @@
 				sf_errno = svx_open_read (psf) ;
 				break ;
 
+		case	SF_FORMAT_NIST :
+				sf_errno = nist_open_read (psf) ;
+				break ;
+
+		case	SF_FORMAT_SMPLTD :
+				sf_errno = smpltd_open_read (psf) ;
+				break ;
+
+		case	SF_FORMAT_VOC :
+				sf_errno = voc_open_read (psf) ;
+				break ;
+
+		case	SF_FORMAT_IRCAM :
+				sf_errno = ircam_open_read (psf) ;
+				break ;
+
 		default :	
 				sf_errno = SFE_UNKNOWN_FORMAT ;
 		} ;
 	
 	/* Both the file format and the file must be seekable to enable sf_seek(). */
-	psf->sf.seekable = (psf->sf.seekable && seekable) ? SF_TRUE : SF_FALSE ;
+	/*-psf->sf.seekable = (psf->sf.seekable && seekable) ? SF_TRUE : SF_FALSE ;-*/
 		
 	if (sf_errno)
 	{	save_header_info (psf) ;
@@ -377,7 +294,8 @@
 		} ;
 
 	if (! validate_sfinfo (&(psf->sf)))
-	{	save_header_info (psf) ;
+	{	psf_log_SF_INFO (psf) ;
+		save_header_info (psf) ;
 		sf_errno = SFE_BAD_SF_INFO ;
 		sf_close (psf) ;
 		return NULL ;
@@ -384,7 +302,8 @@
 		} ;
 		
 	if (! validate_psf (psf))
-	{	save_header_info (psf) ;
+	{	printf ("validate_psf\n") ;
+		save_header_info (psf) ;
 		sf_errno = SFE_INTERNAL ;
 		sf_close (psf) ;
 		return NULL ;
@@ -398,7 +317,8 @@
 /*------------------------------------------------------------------------------
 */
 
-SNDFILE* 	sf_open_write	(const char *path, const SF_INFO *sfinfo)
+SNDFILE*
+sf_open_write	(const char *path, const SF_INFO *sfinfo)
 {	SF_PRIVATE 	*psf ;
 	
 	if (! sfinfo)
@@ -412,7 +332,7 @@
 		} ;
 
 	sf_errno = 0 ;
-	sf_strbuffer [0] = 0 ;
+	sf_logbuffer [0] = 0 ;
 	
 	psf = malloc (sizeof (SF_PRIVATE)) ; 
 	if (! psf)
@@ -425,12 +345,17 @@
 
 	psf->Magick = SNDFILE_MAGICK ;
 
-	/* fopen with 'b' means binary file mode for Win32 systems. */
-	
-	if (! (psf->file = fopen (path, "wb")))		
-	{	sf_errno = SFE_OPEN_FAILED ;
-		sf_close (psf) ;
-		return NULL ;
+	if (! strcmp (path, "-"))
+	{	psf->file = stdout ;
+		psf->sf.seekable = SF_FALSE ;
+		}
+	else
+	{	/* fopen with 'b' means binary file mode for Win32 systems. */
+		if (! (psf->file = fopen (path, "wb")))		
+		{	sf_errno = SFE_OPEN_FAILED ;
+			sf_close (psf) ;
+			return NULL ;
+			} ;
 		} ;
 		
 	psf->mode = SF_MODE_WRITE ;
@@ -484,6 +409,20 @@
 					} ;
 				break ;
 
+		case	SF_FORMAT_NIST :
+				if ((sf_errno = nist_open_write (psf)))
+				{	sf_close (psf) ;
+					return NULL ;
+					} ;
+				break ;
+
+		case	SF_FORMAT_IRCAM :
+				if ((sf_errno = ircam_open_write (psf)))
+				{	sf_close (psf) ;
+					return NULL ;
+					} ;
+				break ;
+
 		default :	
 				sf_errno = SFE_UNKNOWN_FORMAT ;
 				sf_close (psf) ;
@@ -496,7 +435,8 @@
 /*------------------------------------------------------------------------------
 */
 
-int	sf_perror	(SNDFILE *sndfile)
+int	
+sf_perror	(SNDFILE *sndfile)
 {	SF_PRIVATE 	*psf ;
 	int 		k, errnum ;
 
@@ -508,15 +448,16 @@
 		errnum = psf->error ;
 		} ;
 		
+	errnum = abs (errnum) ;
 	errnum = (errnum >= SFE_MAX_ERROR || errnum < 0) ? 0 : errnum ;
 
 	for (k = 0 ; SndfileErrors[k].str ; k++)
 		if (errnum == SndfileErrors[k].error)
-		{	printf ("%s\n", SndfileErrors[k].str) ;
+		{	fprintf (stderr, "%s\n", SndfileErrors[k].str) ;
 			return SFE_NO_ERROR ;
 			} ;
 	
-	printf ("No error string for error number %d.\n", errnum) ;
+	fprintf (stderr, "No error string for error number %d.\n", errnum) ;
 	return SFE_NO_ERROR ;
 } /* sf_perror */
 
@@ -524,7 +465,8 @@
 /*------------------------------------------------------------------------------
 */
 
-int	sf_error_str	(SNDFILE *sndfile, char *str, size_t maxlen)
+int	
+sf_error_str	(SNDFILE *sndfile, char *str, size_t maxlen)
 {	SF_PRIVATE 	*psf ;
 	int 		errnum, k ;
 
@@ -536,17 +478,22 @@
 		errnum = psf->error ;
 		} ;
 		
+	errnum = abs (errnum) ;
 	errnum = (errnum >= SFE_MAX_ERROR || errnum < 0) ? 0 : errnum ;
 
 	for (k = 0 ; SndfileErrors[k].str ; k++)
 		if (errnum == SndfileErrors[k].error)
-		{	strncpy (str, SndfileErrors [errnum].str, maxlen) ;
-			str [maxlen-1] = 0 ;
+		{	if (str)
+			{	strncpy (str, SndfileErrors [errnum].str, maxlen) ;
+				str [maxlen-1] = 0 ;
+				} ;
 			return SFE_NO_ERROR ;
 			} ;
 			
-	strncpy (str, "No error defined for this error number. This is a bug in libsndfile.", maxlen) ;		
-	str [maxlen-1] = 0 ;
+	if (str)
+	{	strncpy (str, "No error defined for this error number. This is a bug in libsndfile.", maxlen) ;		
+		str [maxlen-1] = 0 ;
+		} ;
 			
 	return SFE_NO_ERROR ;
 } /* sf_error_str */
@@ -554,9 +501,11 @@
 /*------------------------------------------------------------------------------
 */
 
-int	sf_error_number	(int errnum, char *str, size_t maxlen)
+int	
+sf_error_number	(int errnum, char *str, size_t maxlen)
 {	int 		k ;
 
+	errnum = abs (errnum) ;
 	errnum = (errnum >= SFE_MAX_ERROR || errnum < 0) ? 0 : errnum ;
 
 	for (k = 0 ; SndfileErrors[k].str ; k++)
@@ -575,7 +524,8 @@
 /*------------------------------------------------------------------------------
 */
 
-int		sf_format_check	(const SF_INFO *info)
+int
+sf_format_check	(const SF_INFO *info)
 {	int	subformat = info->format & SF_FORMAT_SUBMASK ;
 
 	/* This is the place where each file format can check if the suppiled
@@ -590,8 +540,6 @@
 	{	case SF_FORMAT_WAV :
 				if (subformat == SF_FORMAT_PCM && (info->pcmbitwidth >= 8 && info->pcmbitwidth <= 32))
 					return 1 ;
-				if (subformat == SF_FORMAT_FLOAT && info->pcmbitwidth == 32)
-					return 1 ;
 				if (subformat == SF_FORMAT_IMA_ADPCM && info->pcmbitwidth == 16 && info->channels <= 2)
 					return 1 ;
 				if (subformat == SF_FORMAT_MS_ADPCM && info->pcmbitwidth == 16 && info->channels <= 2)
@@ -600,11 +548,19 @@
 					return 1 ;
 				if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW)
 					return 1 ;
+				if (subformat == SF_FORMAT_FLOAT && info->pcmbitwidth == 32)
+					return 1 ;
 				break ;
 				
 		case SF_FORMAT_AIFF :
 				if (subformat == SF_FORMAT_PCM && (info->pcmbitwidth >= 8 && info->pcmbitwidth <= 32))
 					return 1 ;
+				if (subformat == SF_FORMAT_PCM_LE && (info->pcmbitwidth >= 8 && info->pcmbitwidth <= 32))
+					return 1 ;
+				if (subformat == SF_FORMAT_PCM_BE && (info->pcmbitwidth >= 8 && info->pcmbitwidth <= 32))
+					return 1 ;
+				if (subformat == SF_FORMAT_FLOAT && (info->pcmbitwidth == 32))
+					return 1 ;
 				break ;
 				
 		case SF_FORMAT_AU :
@@ -611,14 +567,14 @@
 		case SF_FORMAT_AULE :
 				if (subformat == SF_FORMAT_PCM && (info->pcmbitwidth >= 8 && info->pcmbitwidth <= 32))
 					return 1 ;
-				if (subformat == SF_FORMAT_ULAW)
+				if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW)
 					return 1 ;
-				if (subformat == SF_FORMAT_ALAW)
-					return 1 ;
 				if (subformat == SF_FORMAT_G721_32 && info->channels == 1)
 					return 1 ;
 				if (subformat == SF_FORMAT_G723_24 && info->channels == 1)
 					return 1 ;
+				if (subformat == SF_FORMAT_FLOAT && (info->pcmbitwidth == 32))
+					return 1 ;
 				break ;
 				
 		case SF_FORMAT_RAW :
@@ -628,26 +584,41 @@
 					return 1 ;
 				if (subformat != SF_FORMAT_PCM_BE && subformat != SF_FORMAT_PCM_LE)
 					break ;
-				if (info->pcmbitwidth % 8 || info->pcmbitwidth > 32)
-					break ;
-				return 1 ;
+				if (! (info->pcmbitwidth % 8) && info->pcmbitwidth <= 32)
+					return 1 ;
 				break ;
-				
+
 		case SF_FORMAT_PAF :
 				if (subformat == SF_FORMAT_PCM_S8 && info->pcmbitwidth == 8)
 					return 1 ;
-				if (subformat != SF_FORMAT_PCM_BE && subformat != SF_FORMAT_PCM_LE)
+				if (subformat != SF_FORMAT_PCM_BE && subformat != SF_FORMAT_PCM_LE && subformat != SF_FORMAT_PCM)
 					break ;
-				if (info->pcmbitwidth % 8 || info->pcmbitwidth > 24)
-					break ;
-				return 1 ;
+				if ((info->pcmbitwidth % 8) == 0 && info->pcmbitwidth <= 24)
+					return 1 ;
 				break ;
-				
+
 		case SF_FORMAT_SVX :
 				if (subformat == SF_FORMAT_PCM && (info->pcmbitwidth == 8 || info->pcmbitwidth == 16))
 					return 1 ;
 				break ;
+
+		case SF_FORMAT_NIST :
+				if ((subformat == SF_FORMAT_PCM_BE || subformat == SF_FORMAT_PCM_LE || subformat == SF_FORMAT_PCM)
+						&& info->pcmbitwidth >= 16 && info->pcmbitwidth <= 32)
+					return 1 ;
+				break ;
 				
+		case SF_FORMAT_IRCAM :
+				if ((subformat == SF_FORMAT_PCM_BE || subformat == SF_FORMAT_PCM_LE || subformat == SF_FORMAT_PCM)
+						&& info->pcmbitwidth >= 16 && info->pcmbitwidth <= 32)
+					return 1 ;
+				if ((subformat == SF_FORMAT_FLOAT_BE || subformat == SF_FORMAT_FLOAT_LE || subformat == SF_FORMAT_FLOAT)
+						&& info->pcmbitwidth == 32)
+					return 1 ;
+				if (subformat == SF_FORMAT_ULAW || subformat == SF_FORMAT_ALAW)
+					return 1 ;
+				break ;
+				
 		default : break ;
 		} ;
 
@@ -657,39 +628,39 @@
 /*------------------------------------------------------------------------------
 */
 
-size_t	sf_get_header_info	(SNDFILE *sndfile, char *buffer, size_t bufferlen, size_t offset)
+size_t
+sf_get_header_info	(SNDFILE *sndfile, char *buffer, size_t bufferlen, size_t offset)
 {	SF_PRIVATE	*psf ;
 	int			len ;
 	
 	if (! sndfile)
-	{	strncpy (buffer, sf_strbuffer, bufferlen - 1) ;
+	{	strncpy (buffer, sf_logbuffer, bufferlen - 1) ;
 		buffer [bufferlen - 1] = 0 ;
-		return strlen (sf_strbuffer) ;
+		return strlen (sf_logbuffer) ;
 		} ;
 
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 	
-	len = strlen (psf->strbuffer) ;
+	len = strlen (psf->logbuffer) ;
 	if (offset < 0 || offset >= len)
 		return 0 ;
 	
-	strncpy (buffer, psf->strbuffer, bufferlen - 1) ;
+	strncpy (buffer, psf->logbuffer, bufferlen - 1) ;
 	buffer [bufferlen - 1] = 0 ;
 	
-	return strlen (psf->strbuffer) ;
+	return strlen (psf->logbuffer) ;
 } /* sf_get_header_info */
 
 /*------------------------------------------------------------------------------
 */
 
-size_t	sf_get_lib_version	(char *buffer, size_t bufferlen)
+size_t	
+sf_get_lib_version	(char *buffer, size_t bufferlen)
 {	if (! buffer || ! bufferlen)
 		return 0 ;
 
-	strncpy (buffer, PACKAGE, bufferlen - 1) ;
+	strncpy (buffer, PACKAGE "-" VERSION, bufferlen - 1) ;
 	buffer [bufferlen - 1] = 0 ;
-	strncat (buffer, "-", bufferlen - strlen (buffer) - 1) ;
-	strncat (buffer, VERSION, bufferlen - strlen (buffer) - 1) ;
 	
 	return strlen (buffer) ;
 } /* sf_get_lib_version */
@@ -697,25 +668,91 @@
 /*------------------------------------------------------------------------------
 */
 
-double  sf_signal_max   (SNDFILE *sndfile)
+int	
+sf_command	(SNDFILE *sndfile, const char *cmd, void *data, int datasize)
 {	SF_PRIVATE 		*psf ;
-	off_t			position ;
+	int command ;
+	
+	command = hash_command (cmd) ;
+	
+	if (command == SFC_LIB_VERSION) 
+	{	strncpy (data, PACKAGE "-" VERSION, datasize - 1) ;
+		((char*) data) [datasize - 1] = 0 ;
+		return strlen ((char*) data) ;
+		} ;
+
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
+	
+	switch (command)
+	{	case 0 :
+			return (psf->error = SFE_BAD_CONTROL_CMD) ;
+			
+		case SFC_NORM_FLOAT :
+			if (! data)
+				return (psf->error = SFE_BAD_CONTROL_CMD) ;
+			if (! strcmp ("on", data))
+				psf->norm_float = SF_TRUE ;
+			else if (! strcmp ("off", data))
+				psf->norm_float = SF_FALSE ;
+			else
+				return (psf->error = SFE_BAD_CONTROL_CMD) ;
+			break ;		
+			
+		case SFC_NORM_DOUBLE :
+			if (! data)
+				return (psf->error = SFE_BAD_CONTROL_CMD) ;
+			if (! strcmp ("on", data))
+				psf->norm_double = SF_TRUE ;
+			else if (! strcmp ("off", data))
+				psf->norm_double = SF_FALSE ;
+			else
+				return (psf->error = SFE_BAD_CONTROL_CMD) ;
+			break ;		
+			
+		default :
+			/* Must be a file specific command. Pass it on. */
+			if (psf->command)
+				return psf->command (psf, command, data, datasize) ;
+
+			psf_log_printf (psf, "*** sf_command : cmd = %08X\n", command) ;
+			break ;
+		} ;
+
+	return 0 ;
+} /* sf_command */
+
+/*------------------------------------------------------------------------------
+*/
+
+double  
+sf_signal_max   (SNDFILE *sndfile)
+{	SF_PRIVATE 		*psf ;
+	long			position ;
 	unsigned int	k, len, readcount ;
 	double 			max = 0.0, *data, temp ;
 	
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 	
+	/* If the file has a PEAK chunk use that information. */
+	if (psf->has_peak)
+	{	for (k = 0 ; k < psf->sf.channels ; k++)
+			if (max < fabs (psf->peak.peak [k].value))
+				max = fabs (psf->peak.peak [k].value);
+		return max ;
+		} ;
+	
+	/* If the file is not seekable, there is nothing we can do. */
 	if (! psf->sf.seekable)
 	{	psf->error = SFE_NOT_SEEKABLE ;
 		return	0.0 ;
 		} ;
 		
-	
 	if (! psf->read_double)
 	{	psf->error = SFE_UNIMPLEMENTED ;
-		return	-1 ;
+		return	0.0 ;
 		} ;
 		
+	/* Brute force. Read the whole file and find the biggest sample. */
 	position = sf_seek (sndfile, 0, SEEK_CUR) ; /* Get current position in file */
 	sf_seek (sndfile, 0, SEEK_SET) ;			/* Go to start of file. */
 	
@@ -724,7 +761,7 @@
 	data = malloc (len * sizeof (double)) ;
 	readcount = len ;
 	while (readcount == len)
-	{	readcount = psf->read_double (psf, data, len, 0) ;
+	{	readcount = sf_read_double (sndfile, data, len, 0) ;
 		for (k = 0 ; k < len ; k++)
 		{	temp = data [k] ;
 			temp = temp < 0.0 ? -temp : temp ;
@@ -741,51 +778,54 @@
 /*------------------------------------------------------------------------------
 */
 
-off_t	sf_seek	(SNDFILE *sndfile, off_t offset, int whence)
+long	
+sf_seek	(SNDFILE *sndfile, long offset, int whence)
 {	SF_PRIVATE 	*psf ;
-	off_t		realseek, position ;
+	long		realseek, position ;
 
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 	
 	if (! psf->sf.seekable)
 	{	psf->error = SFE_NOT_SEEKABLE ;
-		return	((off_t) -1) ;
+		return	((long) -1) ;
 		} ;
 	
 	if (psf->seek_func)
-		return	psf->seek_func (psf, offset, whence) ;
+	{	psf->seek_func (psf, offset, whence) ;
+		return psf->current ;
+		} ;
 		
 	if (! (psf->blockwidth && psf->datalength && psf->dataoffset))
 	{	psf->error = SFE_BAD_SEEK ;
-		return	((off_t) -1) ;
+		return	((long) -1) ;
 		} ;
-	
+
 	switch (whence)
 	{	case SEEK_SET :
 				if (offset < 0 || offset * psf->blockwidth > psf->datalength)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				realseek = psf->dataoffset + offset * psf->blockwidth ;
 				fseek (psf->file, realseek, SEEK_SET) ;
 				position = ftell (psf->file) ;
 				break ;
-				
+
 		case SEEK_CUR :
-				realseek = offset * psf->blockwidth ;
-				position = ftell (psf->file) - psf->dataoffset ;
-				if (position + realseek > psf->datalength || position + realseek < 0)
+				position = (ftell (psf->file) - psf->dataoffset) / psf->blockwidth ;
+				if (psf->current + offset > psf->sf.samples)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
-				fseek (psf->file, realseek, SEEK_CUR) ;
+				realseek = psf->dataoffset + (position + offset) * psf->blockwidth ;
+				fseek (psf->file, realseek, SEEK_SET) ;
 				position = ftell (psf->file) ;
 				break ;
-				
+
 		case SEEK_END :
 				if (offset > 0 || psf->sf.samples + offset < 0)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				realseek = (psf->sf.samples + offset) * psf->blockwidth + psf->dataoffset ;
 
@@ -795,7 +835,7 @@
 				
 		default : 
 				psf->error = SFE_BAD_SEEK ;
-				return	((off_t) -1) ;
+				return	((long) -1) ;
 		} ;
 
 	psf->current = (position - psf->dataoffset) / psf->blockwidth ;
@@ -805,15 +845,16 @@
 /*------------------------------------------------------------------------------
 */
 
-size_t		sf_read_raw		(SNDFILE *sndfile, void *ptr, size_t bytes)
+size_t
+sf_read_raw		(SNDFILE *sndfile, void *ptr, size_t bytes)
 {	SF_PRIVATE 	*psf ;
 	size_t		count ;
 
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 	
 	if (psf->mode != SF_MODE_READ)
 	{	psf->error = SFE_NOT_READMODE ;
-		return	((size_t) -1) ;
+		return	0 ;
 		} ;
 	
 	if (psf->current >= psf->datalength)
@@ -823,7 +864,7 @@
 	
 	if (bytes % (psf->sf.channels * psf->bytewidth))
 	{	psf->error = SFE_BAD_READ_ALIGN ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	count = fread (ptr, 1, bytes, psf->file) ;
@@ -839,20 +880,21 @@
 /*------------------------------------------------------------------------------
 */
 
-size_t	sf_read_short		(SNDFILE *sndfile, short *ptr, size_t len)
+size_t
+sf_read_short		(SNDFILE *sndfile, short *ptr, size_t len)
 {	SF_PRIVATE 	*psf ;
 	size_t		count, extra ;
 
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 	
 	if (psf->mode != SF_MODE_READ)
 	{	psf->error = SFE_NOT_READMODE ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	if (len % psf->sf.channels)
 	{	psf->error = SFE_BAD_READ_ALIGN ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	if (psf->current >= psf->sf.samples)
@@ -862,7 +904,7 @@
 
 	if (! psf->read_short)
 	{	psf->error = SFE_UNIMPLEMENTED ;
-		return	(size_t) -1 ;
+		return	0 ;
 		} ;
 		
 	count = psf->read_short (psf, ptr, len) ;
@@ -879,15 +921,16 @@
 	return count ;
 } /* sf_read_short */
 
-size_t	sf_readf_short		(SNDFILE *sndfile, short *ptr, size_t frames)
+size_t
+sf_readf_short		(SNDFILE *sndfile, short *ptr, size_t frames)
 {	SF_PRIVATE 	*psf ;
 	size_t		count, extra ;
 
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 	
 	if (psf->mode != SF_MODE_READ)
 	{	psf->error = SFE_NOT_READMODE ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	if (psf->current >= psf->sf.samples)
@@ -897,7 +940,7 @@
 
 	if (! psf->read_short)
 	{	psf->error = SFE_UNIMPLEMENTED ;
-		return	(size_t) -1 ;
+		return 0 ;
 		} ;
 		
 	count = psf->read_short (psf, ptr, frames * psf->sf.channels) ;
@@ -917,7 +960,8 @@
 /*------------------------------------------------------------------------------
 */
 
-size_t	sf_read_int		(SNDFILE *sndfile, int *ptr, size_t len)
+size_t	
+sf_read_int		(SNDFILE *sndfile, int *ptr, size_t len)
 {	SF_PRIVATE 	*psf ;
 	size_t		count, extra ;
 
@@ -924,10 +968,14 @@
 	VALIDATE_SNDFILE_AND_ASSIGN_PSF   (sndfile,psf) ;
 
 	if (psf->mode != SF_MODE_READ)
-		return SFE_NOT_READMODE ;
+	{	psf->error = SFE_NOT_READMODE ;
+		return 0 ;
+		} ;
 	
 	if (len % psf->sf.channels)
-		return	(psf->error = SFE_BAD_READ_ALIGN) ;
+	{	psf->error = SFE_BAD_READ_ALIGN ;
+		return 0 ;
+		} ;
 	
 	if (psf->current >= psf->sf.samples)
 	{	memset (ptr, 0, len * sizeof (int)) ;
@@ -936,7 +984,7 @@
 
 	if (! psf->read_int)
 	{	psf->error = SFE_UNIMPLEMENTED ;
-		return	(size_t) -1 ;
+		return 0 ;
 		} ;
 		
 	count = psf->read_int (psf, ptr, len) ;
@@ -953,7 +1001,8 @@
 	return count ;
 } /* sf_read_int */
 
-size_t	sf_readf_int		(SNDFILE *sndfile, int *ptr, size_t frames)
+size_t	
+sf_readf_int		(SNDFILE *sndfile, int *ptr, size_t frames)
 {	SF_PRIVATE 	*psf ;
 	size_t		count, extra ;
 
@@ -960,7 +1009,9 @@
 	VALIDATE_SNDFILE_AND_ASSIGN_PSF   (sndfile,psf) ;
 
 	if (psf->mode != SF_MODE_READ)
-		return SFE_NOT_READMODE ;
+	{	psf->error = SFE_NOT_READMODE ;
+		return 0 ;
+		} ;
 	
 	if (psf->current >= psf->sf.samples)
 	{	memset (ptr, 0, frames * psf->sf.channels * sizeof (int)) ;
@@ -969,7 +1020,7 @@
 
 	if (! psf->read_int)
 	{	psf->error = SFE_UNIMPLEMENTED ;
-		return	(size_t) -1 ;
+		return	0 ;
 		} ;
 		
 	count = psf->read_int (psf, ptr, frames * psf->sf.channels) ;
@@ -989,17 +1040,102 @@
 /*------------------------------------------------------------------------------
 */
 
-size_t	sf_read_double	(SNDFILE *sndfile, double *ptr, size_t len, int normalize)
+size_t	
+sf_read_float		(SNDFILE *sndfile, float *ptr, size_t len)
 {	SF_PRIVATE 	*psf ;
 	size_t		count, extra ;
 
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF   (sndfile,psf) ;
+
+	if (psf->mode != SF_MODE_READ)
+	{	psf->error = SFE_NOT_READMODE ;
+		return 0 ;
+		} ;
+	
+	if (len % psf->sf.channels)
+	{	psf->error = SFE_BAD_READ_ALIGN ;
+		return 0 ;
+		} ;
+	
+	if (psf->current >= psf->sf.samples)
+	{	memset (ptr, 0, len * sizeof (float)) ;
+		return 0 ;
+		} ;
+
+	if (! psf->read_float)
+	{	psf->error = SFE_UNIMPLEMENTED ;
+		return	0 ;
+		} ;
+		
+	count = psf->read_float (psf, ptr, len) ;
+	
+	if (psf->current + count / psf->sf.channels > psf->sf.samples)
+	{	count = (psf->sf.samples - psf->current) * psf->sf.channels ;
+		extra = len - count ;
+		memset (ptr + count, 0, extra * sizeof (float)) ;
+		psf->current = psf->sf.samples ;
+		} ;
+	
+	psf->current += count / psf->sf.channels ;
+	
+	return count ;
+} /* sf_read_float */
+
+size_t	
+sf_readf_float		(SNDFILE *sndfile, float *ptr, size_t frames)
+{	SF_PRIVATE 	*psf ;
+	size_t		count, extra ;
+
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF   (sndfile,psf) ;
+
+	if (psf->mode != SF_MODE_READ)
+	{	psf->error = SFE_NOT_READMODE ;
+		return 0 ;
+		} ;
+	
+	if (psf->current >= psf->sf.samples)
+	{	memset (ptr, 0, frames * psf->sf.channels * sizeof (float)) ;
+		return 0 ;
+		} ;
+
+	if (! psf->read_float)
+	{	psf->error = SFE_UNIMPLEMENTED ;
+		return	0 ;
+		} ;
+		
+	count = psf->read_float (psf, ptr, frames * psf->sf.channels) ;
+	
+	if (psf->current + count / psf->sf.channels > psf->sf.samples)
+	{	count = (psf->sf.samples - psf->current) * psf->sf.channels ;
+		extra = frames * psf->sf.channels - count ;
+		memset (ptr + count, 0, extra * sizeof (float)) ;
+		psf->current = psf->sf.samples ;
+		} ;
+	
+	psf->current += count / psf->sf.channels ;
+	
+	return count / psf->sf.channels ;
+} /* sf_readf_float */
+
+/*------------------------------------------------------------------------------
+*/
+
+size_t	
+sf_read_double	(SNDFILE *sndfile, double *ptr, size_t len, int normalize)
+{	SF_PRIVATE 	*psf ;
+	size_t		count, extra ;
+
 	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 	
 	if (psf->mode != SF_MODE_READ)
-		return SFE_NOT_READMODE ;
+	{	psf->error = SFE_NOT_READMODE ;
+		return 0 ;
+		} ;
 	
 	if (len % psf->sf.channels)
-		return	(psf->error = SFE_BAD_READ_ALIGN) ;
+	{	psf->error = SFE_BAD_READ_ALIGN ;
+		return 0 ;
+		} ;
 	
 	if (psf->current >= psf->sf.samples)
 	{	memset (ptr, 0, len * sizeof (double)) ;
@@ -1008,7 +1144,7 @@
 		
 	if (! psf->read_double)
 	{	psf->error = SFE_UNIMPLEMENTED ;
-		return	(size_t) -1 ;
+		return	0 ;
 		} ;
 		
 	count = psf->read_double (psf, ptr, len, normalize) ;
@@ -1025,7 +1161,8 @@
 	return count ;
 } /* sf_read_double */
 
-size_t	sf_readf_double	(SNDFILE *sndfile, double *ptr, size_t frames, int normalize)
+size_t	
+sf_readf_double	(SNDFILE *sndfile, double *ptr, size_t frames, int normalize)
 {	SF_PRIVATE 	*psf ;
 	size_t		count, extra ;
 
@@ -1032,7 +1169,9 @@
 	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 	
 	if (psf->mode != SF_MODE_READ)
-		return SFE_NOT_READMODE ;
+	{	psf->error = SFE_NOT_READMODE ;
+		return 0 ;
+		} ;
 	
 	if (psf->current >= psf->sf.samples)
 	{	memset (ptr, 0, frames * psf->sf.channels * sizeof (double)) ;
@@ -1041,7 +1180,7 @@
 		
 	if (! psf->read_double)
 	{	psf->error = SFE_UNIMPLEMENTED ;
-		return	(size_t) -1 ;
+		return	0 ;
 		} ;
 		
 	count = psf->read_double (psf, ptr, frames * psf->sf.channels, normalize) ;
@@ -1061,20 +1200,21 @@
 /*------------------------------------------------------------------------------
 */
 
-size_t	sf_write_raw	(SNDFILE *sndfile, void *ptr, size_t len)
+size_t	
+sf_write_raw	(SNDFILE *sndfile, void *ptr, size_t len)
 {	SF_PRIVATE 	*psf ;
 	size_t		count ;
 
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 
 	if (psf->mode != SF_MODE_WRITE)
 	{	psf->error = SFE_NOT_WRITEMODE ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	if (len % (psf->sf.channels * psf->bytewidth))
 	{	psf->error = SFE_BAD_WRITE_ALIGN ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	count = fwrite (ptr, 1, len, psf->file) ;
@@ -1087,25 +1227,26 @@
 /*------------------------------------------------------------------------------
 */
 
-size_t	sf_write_short		(SNDFILE *sndfile, short *ptr, size_t len)
+size_t	
+sf_write_short		(SNDFILE *sndfile, short *ptr, size_t len)
 {	SF_PRIVATE 	*psf ;
 	size_t		count ;
 
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 
 	if (psf->mode != SF_MODE_WRITE)
 	{	psf->error = SFE_NOT_WRITEMODE ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	if (len % psf->sf.channels)
 	{	psf->error = SFE_BAD_WRITE_ALIGN ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	if (! psf->write_short)
 	{	psf->error = SFE_UNIMPLEMENTED ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 		
 	count = psf->write_short (sndfile, ptr, len) ;
@@ -1115,20 +1256,21 @@
 	return count ;
 } /* sf_write_short */
 
-size_t	sf_writef_short		(SNDFILE *sndfile, short *ptr, size_t frames)
+size_t	
+sf_writef_short		(SNDFILE *sndfile, short *ptr, size_t frames)
 {	SF_PRIVATE 	*psf ;
 	size_t		count ;
 
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 
 	if (psf->mode != SF_MODE_WRITE)
 	{	psf->error = SFE_NOT_WRITEMODE ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	if (! psf->write_short)
 	{	psf->error = SFE_UNIMPLEMENTED ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 		
 	count = psf->write_short (sndfile, ptr, frames * psf->sf.channels) ;
@@ -1141,52 +1283,54 @@
 /*------------------------------------------------------------------------------
 */
 
-size_t	sf_write_int		(SNDFILE *sndfile, int *ptr, size_t len)
+size_t	
+sf_write_int		(SNDFILE *sndfile, int *ptr, size_t len)
 {	SF_PRIVATE 	*psf ;
 	size_t		count ;
 
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 
 	if (psf->mode != SF_MODE_WRITE)
 	{	psf->error = SFE_NOT_WRITEMODE ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	if (len % psf->sf.channels)
 	{	psf->error = SFE_BAD_WRITE_ALIGN ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	if (! psf->write_int)
 	{	psf->error = SFE_UNIMPLEMENTED ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 		
 	count = psf->write_int (sndfile, ptr, len) ;
-	
+
 	psf->current += count / psf->sf.channels ;
 	
 	return count ;
 } /* sf_write_int */
 
-size_t	sf_writef_int		(SNDFILE *sndfile, int *ptr, size_t frames)
+size_t	
+sf_writef_int		(SNDFILE *sndfile, int *ptr, size_t frames)
 {	SF_PRIVATE 	*psf ;
 	size_t		count ;
 
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 
 	if (psf->mode != SF_MODE_WRITE)
 	{	psf->error = SFE_NOT_WRITEMODE ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	if (! psf->write_int)
 	{	psf->error = SFE_UNIMPLEMENTED ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 		
 	count = psf->write_int (sndfile, ptr, frames * psf->sf.channels) ;
-	
+
 	psf->current += count / psf->sf.channels ;
 	
 	return count / psf->sf.channels ;
@@ -1195,25 +1339,82 @@
 /*------------------------------------------------------------------------------
 */
 
-size_t	sf_write_double		(SNDFILE *sndfile, double *ptr, size_t len, int normalize)
+size_t	
+sf_write_float		(SNDFILE *sndfile, float *ptr, size_t len)
 {	SF_PRIVATE 	*psf ;
 	size_t		count ;
 
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 
 	if (psf->mode != SF_MODE_WRITE)
 	{	psf->error = SFE_NOT_WRITEMODE ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	if (len % psf->sf.channels)
 	{	psf->error = SFE_BAD_WRITE_ALIGN ;
-		return	(size_t) -1 ;
+		return 0 ;
 		} ;
+	
+	if (! psf->write_float)
+	{	psf->error = SFE_UNIMPLEMENTED ;
+		return 0 ;
+		} ;
 		
+	count = psf->write_float (sndfile, ptr, len) ;
+
+	psf->current += count / psf->sf.channels ;
+	
+	return count ;
+} /* sf_write_float */
+
+size_t	
+sf_writef_float		(SNDFILE *sndfile, float *ptr, size_t frames)
+{	SF_PRIVATE 	*psf ;
+	size_t		count ;
+
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
+
+	if (psf->mode != SF_MODE_WRITE)
+	{	psf->error = SFE_NOT_WRITEMODE ;
+		return 0 ;
+		} ;
+	
+	if (! psf->write_float)
+	{	psf->error = SFE_UNIMPLEMENTED ;
+		return 0 ;
+		} ;
+		
+	count = psf->write_float (sndfile, ptr, frames * psf->sf.channels) ;
+
+	psf->current += count / psf->sf.channels ;
+	
+	return count / psf->sf.channels ;
+} /* sf_writef_float */
+
+/*------------------------------------------------------------------------------
+*/
+
+size_t	
+sf_write_double		(SNDFILE *sndfile, double *ptr, size_t len, int normalize)
+{	SF_PRIVATE 	*psf ;
+	size_t		count ;
+
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
+
+	if (psf->mode != SF_MODE_WRITE)
+	{	psf->error = SFE_NOT_WRITEMODE ;
+		return 0 ;
+		} ;
+	
+	if (len % psf->sf.channels)
+	{	psf->error = SFE_BAD_WRITE_ALIGN ;
+		return	0 ;
+		} ;
+		
 	if (! psf->write_double)
 	{	psf->error = SFE_UNIMPLEMENTED ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 		
 	count = psf->write_double (sndfile, ptr, len, normalize) ;
@@ -1223,20 +1424,21 @@
 	return count ;
 } /* sf_write_double */
 
-size_t	sf_writef_double		(SNDFILE *sndfile, double *ptr, size_t frames, int normalize)
+size_t	
+sf_writef_double		(SNDFILE *sndfile, double *ptr, size_t frames, int normalize)
 {	SF_PRIVATE 	*psf ;
 	size_t		count ;
 
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 
 	if (psf->mode != SF_MODE_WRITE)
 	{	psf->error = SFE_NOT_WRITEMODE ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 	
 	if (! psf->write_double)
 	{	psf->error = SFE_UNIMPLEMENTED ;
-		return (size_t) -1 ;
+		return 0 ;
 		} ;
 		
 	count = psf->write_double (sndfile, ptr, frames * psf->sf.channels, normalize) ;
@@ -1249,11 +1451,12 @@
 /*------------------------------------------------------------------------------
 */
 
-int	sf_close	(SNDFILE *sndfile)
+int	
+sf_close	(SNDFILE *sndfile)
 {	SF_PRIVATE  *psf ;
 	int			error ;
 
-	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile,psf) ;
+	VALIDATE_SNDFILE_AND_ASSIGN_PSF (sndfile, psf) ;
 
 	if (psf->close)
 		error = psf->close (psf) ;
@@ -1271,4 +1474,162 @@
 ** Private functions.
 */
 
+static int 
+does_extension_match (const char *ext, const char *test)
+{	char c1, c2 ;
+
+	if ((! ext) || (! test))
+		return 0 ;
+
+	if (strlen (ext) != strlen (test))
+		return 0 ;
+
+	while (*ext && *test)
+	{	c1 = tolower (*ext) ;
+		c2 = tolower (*test) ;
+		if (c1 > c2)
+			return 0 ;
+		if (c1 < c2)
+			return 0 ;
+		ext ++ ;
+		test ++ ;
+		} 
+
+	return 1 ;
+} /* does_extension_match */
+
+static int 
+is_au_snd_file (const char *filename)
+{	const char *cptr ;
+
+	if (! (cptr = strrchr (filename, '.')))
+		return 0 ;
+	cptr ++ ;
+	
+	if (does_extension_match (cptr, "au"))
+		return 1 ;
+		
+	if (does_extension_match (cptr, "snd"))
+		return 1 ;
+		
+	return 0 ;
+} /* is_au_snd_file */
+
+static int 
+guess_file_type (SF_PRIVATE *psf, const char *filename)
+{	unsigned int buffer [3] ;
+
+	psf_binheader_readf (psf, "B", &buffer, sizeof (buffer)) ;
+
+	if (buffer [0] == MAKE_MARKER ('R','I','F','F') && buffer [2] == MAKE_MARKER ('W','A','V','E'))
+		return SF_FORMAT_WAV ;
+		
+	if (buffer [0] == MAKE_MARKER ('F','O','R','M'))
+	{	if (buffer [2] == MAKE_MARKER ('A','I','F','F') || buffer [2] == MAKE_MARKER ('A','I','F','C'))
+			return SF_FORMAT_AIFF ;
+		if (buffer [2] == MAKE_MARKER ('8','S','V','X') || buffer [2] == MAKE_MARKER ('1','6','S','V'))
+			return SF_FORMAT_SVX ;
+		return 0 ;
+		} ;
+		
+	if ((buffer [0] == MAKE_MARKER ('.','s','n','d') || buffer [0] == MAKE_MARKER ('d','n','s','.')))
+		return SF_FORMAT_AU ;
+		
+	if ((buffer [0] == MAKE_MARKER ('f','a','p',' ') || buffer [0] == MAKE_MARKER (' ','p','a','f')))
+		return SF_FORMAT_PAF ;
+	
+	if (buffer [0] == MAKE_MARKER ('N','I','S','T'))
+		return SF_FORMAT_NIST ;
+		
+	if (buffer [0] == MAKE_MARKER ('S','E','K','D') && buffer [1] == MAKE_MARKER ('S','A','M','R'))
+		return SF_FORMAT_SMPLTD ;
+		
+	if (buffer [0] == MAKE_MARKER ('C','r','e','a') && buffer [1] == MAKE_MARKER ('t','i','v','e'))
+		return SF_FORMAT_VOC ;
+		
+	if ((buffer [0] & MAKE_MARKER (0xFF, 0xFF, 0xF8, 0xFF)) == MAKE_MARKER (0x64, 0xA3, 0x00, 0x00) || 
+		(buffer [0] & MAKE_MARKER (0xFF, 0xF8, 0xFF, 0xFF)) == MAKE_MARKER (0x00, 0x00, 0xA3, 0x64))
+		return SF_FORMAT_IRCAM ;
+		
+	if (buffer [0] == MAKE_MARKER ('C', 'A', 'T', ' ') && buffer [2] == MAKE_MARKER ('R', 'E', 'X', '2'))
+		return SF_FORMAT_REX2 ;
+
+	if (buffer [0] == MAKE_MARKER (0x30, 0x26, 0xB2, 0x75) && buffer [1] == MAKE_MARKER (0x8E, 0x66, 0xCF, 0x11))
+		return SF_FORMAT_WMA ;
+
+	/* This must be the last one. */		
+	if (filename && is_au_snd_file (filename))
+		return SF_FORMAT_AU | SF_FORMAT_ULAW ;
+
+	/* Default to header-less RAW PCM file type. */
+	return SF_FORMAT_RAW ;
+} /* guess_file_type */
+
+
+static int 
+validate_sfinfo (SF_INFO *sfinfo)
+{	if (! sfinfo->samplerate)
+		return 0 ;	
+	if (! sfinfo->samples)
+		return 0 ;	
+	if (! sfinfo->channels)
+		return 0 ;	
+	if (! sfinfo->pcmbitwidth)
+		return 0 ;	
+	if (! sfinfo->format & SF_FORMAT_TYPEMASK)
+		return 0 ;	
+	if (! sfinfo->format & SF_FORMAT_SUBMASK)
+		return 0 ;	
+	if (! sfinfo->sections)
+		return 0 ;	
+	return 1 ;
+} /* validate_sfinfo */
+
+static int
+validate_psf (SF_PRIVATE *psf)
+{	if (! psf->blockwidth)
+		return 0 ;	
+	if (! psf->bytewidth)
+		return 0 ;	
+	if (! psf->datalength)
+		return 0 ;
+	if (psf->blockwidth != psf->sf.channels * psf->bytewidth)
+		return 0 ;	
+	return 1 ;
+} /* validate_psf */
+
+static void 
+save_header_info (SF_PRIVATE *psf)
+{	memset (sf_logbuffer, 0, sizeof (sf_logbuffer)) ;
+	strncpy (sf_logbuffer, psf->logbuffer, sizeof (sf_logbuffer)) ;
+} /* save_header_info */
+
+static void 
+copy_filename (SF_PRIVATE *psf, const char *path)
+{	const char *cptr ;
+
+	if ((cptr = strrchr (path, '/')) || (cptr = strrchr (path, '\\')))
+		cptr ++ ;
+	else
+		cptr = path ;
+		
+	memset (psf->filename, 0, SF_FILENAME_LEN) ;
+	strncpy (psf->filename, cptr, SF_FILENAME_LEN - 1) ;
+	psf->filename [SF_FILENAME_LEN - 1] = 0 ;
+} /* copy_filename */
+
+static int	
+hash_command (const char *cmd)
+{	int	hash = 0 ;
+
+	if (! cmd)
+		return 0 ;
+
+	while (*cmd)
+	{	hash = (hash<<1) ^ *cmd ;
+		cmd ++ ;
+		} ;
+		
+	return hash ;
+} /* hash_command */
 
--- a/common/libsndfile/src/sndfile.h
+++ b/common/libsndfile/src/sndfile.h
@@ -1,18 +1,18 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
+**  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
 ** the Free Software Foundation; either version 2.1 of the License, or
 ** (at your option) any later version.
-**
+** 
 ** This program is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU Lesser General Public License for more details.
-**
+** 
 ** You should have received a copy of the GNU Lesser General Public License
-** along with this program; if not, write to the Free Software
+** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
@@ -32,7 +32,7 @@
 #include	<sys/types.h>
 #endif
 
-#ifdef _WIN32
+#if defined (_WIN32)
 	#pragma pack(push,1)
 #endif
 
@@ -48,8 +48,8 @@
 */
 
 enum
-{	SF_FORMAT_WAV		= 0x10000,		/* Microsoft WAV format (big endian). */
-	SF_FORMAT_AIFF		= 0x20000,		/* Apple/SGI AIFF format (little endian). */
+{	SF_FORMAT_WAV		= 0x10000,		/* Microsoft WAV format (little endian). */
+	SF_FORMAT_AIFF		= 0x20000,		/* Apple/SGI AIFF format (big endian). */
 	SF_FORMAT_AU		= 0x30000,		/* Sun/NeXT AU format (big endian). */
 	SF_FORMAT_AULE		= 0x40000,		/* DEC AU format (little endian). */
 	SF_FORMAT_RAW		= 0x50000,		/* RAW PCM data. */
@@ -56,7 +56,15 @@
 	SF_FORMAT_PAF		= 0x60000,		/* Ensoniq PARIS file format. */
 	SF_FORMAT_SVX		= 0x70000,		/* Amiga IFF / SVX8 / SV16 format. */
 	SF_FORMAT_NIST		= 0x80000,		/* Sphere NIST format. */
-
+	SF_FORMAT_WMA		= 0x90000,		/* Windows Media Audio. */
+	SF_FORMAT_SMPLTD	= 0xA0000,		/* Sekd Samplitude. */
+	SF_FORMAT_VOC		= 0xB0000,		/* VOC files. */
+	SF_FORMAT_SD2		= 0xC0000,		/* Sound Designer 2 */
+	SF_FORMAT_REX2		= 0xD0000,		/* Propellorheads Rex2 */
+	SF_FORMAT_IRCAM		= 0xE0000,		/* Berkeley/IRCAM/CARL */
+	
+	/* Subtypes from here on. */
+	
 	SF_FORMAT_PCM		= 0x0001,		/* PCM data in 8, 16, 24 or 32 bits. */
 	SF_FORMAT_FLOAT		= 0x0002,		/* 32 bit floats. */
 	SF_FORMAT_ULAW		= 0x0003,		/* U-Law encoded. */
@@ -68,7 +76,7 @@
 	SF_FORMAT_PCM_LE  	= 0x0008,		/* Little endian PCM data. */
 	SF_FORMAT_PCM_S8	= 0x0009,		/* Signed 8 bit PCM. */
 	SF_FORMAT_PCM_U8  	= 0x000A,		/* Unsigned 8 bit PCM. */
-
+	
 	SF_FORMAT_SVX_FIB	= 0x000B, 		/* SVX Fibonacci Delta encoding. */
 	SF_FORMAT_SVX_EXP	= 0x000C, 		/* SVX Exponential Delta encoding. */
 
@@ -77,12 +85,15 @@
 	SF_FORMAT_G721_32	= 0x000E, 		/* 32kbs G721 ADPCM encoding. */
 	SF_FORMAT_G723_24	= 0x000F, 		/* 24kbs G723 ADPCM encoding. */
 
-	SF_FORMAT_SUBMASK	= 0xFFFF,
+	SF_FORMAT_FLOAT_BE	= 0x0010,		/* Big endian FLOAT data. */
+	SF_FORMAT_FLOAT_LE  = 0x0011,		/* Little endian FLOAT data. */
+
+	SF_FORMAT_SUBMASK	= 0xFFFF,		
 	SF_FORMAT_TYPEMASK	= 0x7FFF0000
 } ;
 
-/* Th following SF_FORMAT_RAW_* identifiers are deprecated. Use the
-**	SF_FORMAT_PCM_* idetifiers instead.
+/* The following SF_FORMAT_RAW_* identifiers are deprecated. Use the
+** SF_FORMAT_PCM_* identifiers instead.
 */
 #define	SF_FORMAT_RAW_BE	SF_FORMAT_PCM_BE
 #define	SF_FORMAT_RAW_LE	SF_FORMAT_PCM_LE
@@ -93,8 +104,8 @@
 
 typedef	void	SNDFILE ;
 
-/* A pointer to a SF_INFO structure is passed to sf_open_read () and filled in.
-** On write, the SF_INFO structure is filled in by the user and passed into
+/* A pointer to a SF_INFO structure is passed to sf_open_read () and filled in. 
+** On write, the SF_INFO structure is filled in by the user and passed into  
 ** sf_open_write ().
 */
 
@@ -108,18 +119,17 @@
 	unsigned int	seekable ;
 } SF_INFO ;
 
-
-/* Open the specified file for read or write. On error, this will return
+/* Open the specified file for read or write. On error, this will return 
 ** a NULL pointer. To find the error number, pass a NULL SNDFILE to
 ** sf_perror () or sf_error_str ().
 */
 
-SNDFILE* 	sf_open_read	(const char *path, SF_INFO *wfinfo) ;
-SNDFILE* 	sf_open_write	(const char *path, const SF_INFO *wfinfo) ;
+SNDFILE* 	sf_open_read	(const char *path, SF_INFO *sfinfo) ;
+SNDFILE* 	sf_open_write	(const char *path, const SF_INFO *sfinfo) ;
 
 /* sf_perror () prints out the current error state.
-** sf_error_str () returns the current error message to the caller in the
-** string buffer provided.
+** sf_error_str () returns the current error message to the caller in the 
+** string buffer provided. 
 */
 
 int		sf_perror		(SNDFILE *sndfile) ;
@@ -136,6 +146,10 @@
 
 /* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */
 
+int		sf_command	(SNDFILE *sndfile, const char *cmd, void *data, int datasize) ;
+
+/* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */
+
 int		sf_format_check	(const SF_INFO *info) ;
 
 /* Return the maximum absolute sample value in the SNDFILE. */
@@ -142,17 +156,17 @@
 
 double	sf_signal_max	(SNDFILE *sndfile) ;
 
-/* Seek within the waveform data chunk of the SNDFILE. sf_seek () uses
+/* Seek within the waveform data chunk of the SNDFILE. sf_seek () uses 
 ** the same values for whence (SEEK_SET, SEEK_CUR and SEEK_END) as
 ** stdio.h functions lseek () and fseek ().
-** An offset of zero with whence set to SEEK_SET will position the
+** An offset of zero with whence set to SEEK_SET will position the 
 ** read / write pointer to the first data sample.
-** On success sf_seek returns the current position in (multi-channel)
+** On success sf_seek returns the current position in (multi-channel) 
 ** samples from the start of the file.
 ** On error sf_seek returns -1.
 */
 
-off_t	sf_seek 		(SNDFILE *sndfile, off_t frames, int whence) ;
+long	sf_seek 		(SNDFILE *sndfile, long frames, int whence) ;
 
 /* Functions for reading/writing the waveform data of a sound file.
 */
@@ -160,7 +174,7 @@
 size_t	sf_read_raw		(SNDFILE *sndfile, void *ptr, size_t bytes) ;
 size_t	sf_write_raw 	(SNDFILE *sndfile, void *ptr, size_t bytes) ;
 
-/* Functions for reading and writing the data chunk in terms of frames.
+/* Functions for reading and writing the data chunk in terms of frames. 
 ** The number of items actually read/written = frames * number of channels.
 **     sf_xxxx_raw		read/writes the raw data bytes from/to the file
 **     sf_xxxx_uchar	passes data in the unsigned char format
@@ -169,8 +183,8 @@
 **     sf_xxxx_int		passes data in the native int format
 **     sf_xxxx_float	passes data in the native float format
 **     sf_xxxx_double	passes data in the native double format
-** For the double format, if the normalize flag is TRUE, the read/write
-** operations will use floats/doubles in the rangs [-1.0 .. 1.0] to
+** For the double format, if the normalize flag is TRUE, the read/write 
+** operations will use floats/doubles in the rangs [-1.0 .. 1.0] to 
 ** represent the minimum and maximum values of the waveform irrespective
 ** of the bitwidth of the input/output file.
 ** All of these read/write function return number of frames read/written.
@@ -182,10 +196,13 @@
 size_t	sf_readf_int	(SNDFILE *sndfile, int *ptr, size_t frames) ;
 size_t	sf_writef_int 	(SNDFILE *sndfile, int *ptr, size_t frames) ;
 
+size_t	sf_readf_float	(SNDFILE *sndfile, float *ptr, size_t frames) ;
+size_t	sf_writef_float	(SNDFILE *sndfile, float *ptr, size_t frames) ;
+
 size_t	sf_readf_double	(SNDFILE *sndfile, double *ptr, size_t frames, int normalize) ;
 size_t	sf_writef_double(SNDFILE *sndfile, double *ptr, size_t frames, int normalize) ;
 
-/* Functions for reading and writing the data chunk in terms of items.
+/* Functions for reading and writing the data chunk in terms of items. 
 ** Otherwise similar to above.
 ** All of these read/write function return number of items read/written.
 */
@@ -196,6 +213,9 @@
 size_t	sf_read_int		(SNDFILE *sndfile, int *ptr, size_t items) ;
 size_t	sf_write_int 	(SNDFILE *sndfile, int *ptr, size_t items) ;
 
+size_t	sf_read_float	(SNDFILE *sndfile, float *ptr, size_t items) ;
+size_t	sf_write_float	(SNDFILE *sndfile, float *ptr, size_t items) ;
+
 size_t	sf_read_double	(SNDFILE *sndfile, double *ptr, size_t items, int normalize) ;
 size_t	sf_write_double	(SNDFILE *sndfile, double *ptr, size_t items, int normalize) ;
 
@@ -208,7 +228,7 @@
 #endif	/* __cplusplus */
 
 #ifdef _WIN32
-//	#pragma pack(pop,1)
+	#pragma pack(pop,1)
 #endif
 
 #endif	/* SNDFILE_H */
--- a/common/libsndfile/src/svx.c
+++ b/common/libsndfile/src/svx.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -27,7 +27,6 @@
 #include	"config.h"
 #include	"sfendian.h"
 #include	"common.h"
-#include	"pcm.h"
 
 
 /*------------------------------------------------------------------------------
@@ -34,14 +33,6 @@
  * Macros to handle big/little endian issues.
 */
 
-#if (CPU_IS_LITTLE_ENDIAN == 1)
-#	define	MAKE_MARKER(a,b,c,d)		((a)|((b)<<8)|((c)<<16)|((d)<<24))
-#elif (CPU_IS_BIG_ENDIAN == 1)
-#	define	MAKE_MARKER(a,b,c,d)		(((a)<<24)|((b)<<16)|((c)<<8)|(d))
-#else
-#	error "Cannot determine endian-ness of processor."
-#endif
-
 #define FORM_MARKER	(MAKE_MARKER ('F', 'O', 'R', 'M'))
 #define SVX8_MARKER	(MAKE_MARKER ('8', 'S', 'V', 'X'))
 #define SV16_MARKER	(MAKE_MARKER ('1', '6', 'S', 'V'))
@@ -57,7 +48,6 @@
 #define ANNO_MARKER	(MAKE_MARKER ('A', 'N', 'N', 'O')) 
 #define CHAN_MARKER	(MAKE_MARKER ('C', 'H', 'A', 'N')) 
 
-
 /*------------------------------------------------------------------------------
  * Typedefs for file chunks.
 */
@@ -69,91 +59,99 @@
 	unsigned int	volume ;
 } VHDR_CHUNK ;
 
+enum {
+	HAVE_FORM	= 0x01,
+	
+	HAVE_SVX	= 0x02,
+	HAVE_VHDR	= 0x04,
+	HAVE_BODY	= 0x08
+} ;
+
 /*------------------------------------------------------------------------------
  * Private static functions.
 */
 
-static	int		svx_close	(SF_PRIVATE  *psf) ;
+static int		svx_close	(SF_PRIVATE  *psf) ;
+static int		svx_write_header (SF_PRIVATE *psf) ;
 
-static
-void endswap_vhdr_chunk (VHDR_CHUNK *vhdr)
-{	vhdr->oneShotHiSamples  = ENDSWAP_INT (vhdr->oneShotHiSamples) ;
-	vhdr->repeatHiSamples   = ENDSWAP_INT (vhdr->repeatHiSamples) ;
-	vhdr->samplesPerHiCycle = ENDSWAP_INT (vhdr->samplesPerHiCycle) ;
-	vhdr->samplesPerSec     = ENDSWAP_SHORT (vhdr->samplesPerSec) ;
-	vhdr->volume            = ENDSWAP_INT (vhdr->volume) ;
-} /* endswap_vhdr_chunk */
+/*
+static void 	endswap_vhdr_chunk (VHDR_CHUNK *vhdr) ;
+*/
 
 /*------------------------------------------------------------------------------
 ** Public functions.
 */
 
-int 	svx_open_read	(SF_PRIVATE *psf)
+int 	
+svx_open_read	(SF_PRIVATE *psf)
 {	VHDR_CHUNK		vhdr ;
 	unsigned int	FORMsize, vhdrsize, dword, marker ;
-	int				filetype = 0, parsestage = 0, done = 0 ;
+	int				filetype = 0, parsestage = 0, done = 0, error ;
+	int 			bytecount = 0, channels ;
+
+	psf_binheader_readf (psf, "p", 0) ;
 	
 	/* Set default number of channels. */
 	psf->sf.channels = 1 ;
 
 	while (! done)
-	{	fread (&marker, sizeof (marker), 1, psf->file) ;
+	{	psf_binheader_readf (psf, "m", &marker) ;
 		switch (marker)
 		{	case FORM_MARKER :
-					if (parsestage != 0)
+					if (parsestage)
 						return SFE_SVX_NO_FORM ;
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-					FORMsize = BE2H_INT (dword) ;
 
+					psf_binheader_readf (psf, "L", &FORMsize) ;
+
 					if (FORMsize != psf->filelength - 2 * sizeof (dword))
 					{	dword = psf->filelength - 2 * sizeof (dword);
-						psf_sprintf (psf, "FORM : %d (should be %d)\n", FORMsize, dword) ;
+						psf_log_printf (psf, "FORM : %d (should be %d)\n", FORMsize, dword) ;
 						FORMsize = dword ;
 						}
 					else
-						psf_sprintf (psf, "FORM : %d\n", FORMsize) ;
-					parsestage = 1 ;
+						psf_log_printf (psf, "FORM : %d\n", FORMsize) ;
+					parsestage |= HAVE_FORM ;
 					break ;
 
 			case SVX8_MARKER :
 			case SV16_MARKER :
-					if (parsestage != 1)
+					if (! (parsestage & HAVE_FORM))
 						return SFE_SVX_NO_FORM ;
 					filetype = marker ;
-					psf_sprintf (psf, " %D\n", marker) ;
-					parsestage = 2 ;
+					psf_log_printf (psf, " %D\n", marker) ;
+					parsestage |= HAVE_SVX ;
 					break ;
 
 			case VHDR_MARKER :
-					if (parsestage != 2)
+					if (! (parsestage & (HAVE_FORM | HAVE_SVX)))
 						return SFE_SVX_NO_FORM ;
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-					vhdrsize = BE2H_INT (dword) ;
+					
+					psf_binheader_readf (psf, "L", &vhdrsize) ;
 
-					psf_sprintf (psf, " VHDR : %d\n", vhdrsize) ;
+					psf_log_printf (psf, " VHDR : %d\n", vhdrsize) ;
 
-					fread (&vhdr, sizeof (vhdr), 1, psf->file) ;
-					if (CPU_IS_LITTLE_ENDIAN)
-						endswap_vhdr_chunk (&vhdr) ;
+					psf_binheader_readf (psf, "LLLWbbL", &(vhdr.oneShotHiSamples), &(vhdr.repeatHiSamples), 
+						&(vhdr.samplesPerHiCycle), &(vhdr.samplesPerSec), &(vhdr.octave), &(vhdr.compression),
+						&(vhdr.volume)) ;
 
-					psf_sprintf (psf, "  OneShotHiSamples  : %d\n", vhdr.oneShotHiSamples) ;
-					psf_sprintf (psf, "  RepeatHiSamples   : %d\n", vhdr.repeatHiSamples) ;
-					psf_sprintf (psf, "  samplesPerHiCycle : %d\n", vhdr.samplesPerHiCycle) ;
-					psf_sprintf (psf, "  Sample Rate       : %d\n", vhdr.samplesPerSec) ;
-					psf_sprintf (psf, "  Octave            : %d\n", vhdr.octave) ;
+					psf_log_printf (psf, "  OneShotHiSamples  : %d\n", vhdr.oneShotHiSamples) ;
+					psf_log_printf (psf, "  RepeatHiSamples   : %d\n", vhdr.repeatHiSamples) ;
+					psf_log_printf (psf, "  samplesPerHiCycle : %d\n", vhdr.samplesPerHiCycle) ;
+					psf_log_printf (psf, "  Sample Rate       : %d\n", vhdr.samplesPerSec) ;
+					psf_log_printf (psf, "  Octave            : %d\n", vhdr.octave) ;
 
-					psf_sprintf (psf, "  Compression       : %d => ", vhdr.compression) ;
+					psf_log_printf (psf, "  Compression       : %d => ", vhdr.compression) ;
 					
 					switch (vhdr.compression)
-					{	case 0 : psf_sprintf (psf, "None.\n") ;
+					{	case 0 : psf_log_printf (psf, "None.\n") ;
 								break ;
-						case 1 : psf_sprintf (psf, "Fibonacci delta\n") ;
+						case 1 : psf_log_printf (psf, "Fibonacci delta\n") ;
 								break ;
-						case 2 : psf_sprintf (psf, "Exponential delta\n") ;
+						case 2 : psf_log_printf (psf, "Exponential delta\n") ;
 								break ;
 						} ;
 
-					psf_sprintf (psf, "  Volume            : %d\n", vhdr.volume) ;
+					psf_log_printf (psf, "  Volume            : %d\n", vhdr.volume) ;
 
 					psf->sf.samplerate 	= vhdr.samplesPerSec ;
 
@@ -162,73 +160,101 @@
 					else if (filetype == SV16_MARKER)
 						psf->sf.pcmbitwidth = 16 ;
 						
-					parsestage = 3 ;
+					parsestage |= HAVE_VHDR ;
 					break ;
 
 			case BODY_MARKER :
-					if (parsestage != 3)
+					if (! (parsestage & HAVE_VHDR))
 						return SFE_SVX_NO_BODY ;
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-
-					psf->datalength = BE2H_INT (dword) ;
+					
+					psf_binheader_readf (psf, "L", &(psf->datalength)) ;
 					psf->dataoffset = ftell (psf->file) ;
 					
 					if (psf->datalength > psf->filelength - psf->dataoffset)
-					{	psf_sprintf (psf, " BODY : %d (should be %d)\n", psf->datalength, psf->filelength - psf->dataoffset) ;
+					{	psf_log_printf (psf, " BODY : %d (should be %d)\n", psf->datalength, psf->filelength - psf->dataoffset) ;
 						psf->datalength = psf->filelength - psf->dataoffset ;
 						} 
 					else
-						psf_sprintf (psf, " BODY : %d\n", psf->datalength) ;
+						psf_log_printf (psf, " BODY : %d\n", psf->datalength) ;
+						
+					parsestage |= HAVE_BODY ;
 
+					if (! psf->sf.seekable)
+						break ;
+
 					fseek (psf->file, psf->datalength, SEEK_CUR) ;
-					parsestage = 4 ;
 					break ;
 
 			case NAME_MARKER :
 			case ANNO_MARKER :
-					if (parsestage < 2)
+					if (! (parsestage & HAVE_SVX))
 						return SFE_SVX_NO_FORM ;
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-					dword = BE2H_INT (dword) ;
-					psf_sprintf (psf, " %D : %d\n", marker, dword) ;
-					fseek (psf->file, (int) dword, SEEK_CUR) ;					
+
+					psf_binheader_readf (psf, "L", &dword) ;
+					
+					psf_log_printf (psf, " %D : %d\n", marker, dword) ;
+
+					psf_binheader_readf (psf, "j", dword) ;
 					break ;
 
+			case CHAN_MARKER :
+					if (! (parsestage & HAVE_SVX))
+						return SFE_SVX_NO_FORM ;
+
+					psf_binheader_readf (psf, "L", &dword) ;
+					
+					psf_log_printf (psf, " %D : %d\n", marker, dword) ;
+					
+					bytecount += psf_binheader_readf (psf, "L", &channels) ;
+
+					psf_log_printf (psf, "  Channels : %d => %d\n", channels) ;
+					
+					psf_binheader_readf (psf, "j", dword - bytecount) ;
+					break ;
+
+
 			case AUTH_MARKER :
 			case c_MARKER :
-			case CHAN_MARKER :
-					if (parsestage < 2)
+					if (! (parsestage & HAVE_SVX))
 						return SFE_SVX_NO_FORM ;
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-					dword = BE2H_INT (dword) ;
-					psf_sprintf (psf, " %D : %d\n", marker, dword) ;
-					fseek (psf->file, (int) dword, SEEK_CUR) ;					
+
+					psf_binheader_readf (psf, "L", &dword) ;
+					
+					psf_log_printf (psf, " %D : %d\n", marker, dword) ;
+
+					psf_binheader_readf (psf, "j", dword) ;
 					break ;
 
 			default : 
 					if (isprint ((marker >> 24) & 0xFF) && isprint ((marker >> 16) & 0xFF)
 						&& isprint ((marker >> 8) & 0xFF) && isprint (marker & 0xFF))
-					{	fread (&dword, sizeof (dword), 1, psf->file) ;
-						psf_sprintf (psf, "%D : %d (unknown marker)\n", marker, dword) ;
-						fseek (psf->file, (int) dword, SEEK_CUR) ;
+					{	psf_binheader_readf (psf, "L", &dword) ;
+					
+						psf_log_printf (psf, "%D : %d (unknown marker)\n", marker, dword) ;
+
+						psf_binheader_readf (psf, "j", dword) ;
 						break ;
 						} ;
 					if ((dword = ftell (psf->file)) & 0x03)
-					{	psf_sprintf (psf, "  Unknown chunk marker at position %d. Resynching.\n", dword - 4) ;
-						fseek (psf->file, -3, SEEK_CUR) ;
+					{	psf_log_printf (psf, "  Unknown chunk marker at position %d. Resynching.\n", dword - 4) ;
+
+						psf_binheader_readf (psf, "j", -3) ;
 						break ;
 						} ;
-					psf_sprintf (psf, "*** Unknown chunk marker : %X. Exiting parser.\n", marker) ;
+					psf_log_printf (psf, "*** Unknown chunk marker : %X. Exiting parser.\n", marker) ;
 					done = 1 ;
 			} ;	/* switch (marker) */
 
 		if (ferror (psf->file))
-		{	psf_sprintf (psf, "*** Error on file handle. ***\n", marker) ;
+		{	psf_log_printf (psf, "*** Error on file handle. ***\n", marker) ;
 			clearerr (psf->file) ;
 			break ;
 			} ;
+			
+		if (! psf->sf.seekable && (parsestage & HAVE_BODY))
+			break ;
 
-		if (ftell (psf->file) >= (off_t) (psf->filelength - (2 * sizeof (dword))))
+		if (ftell (psf->file) >= (long) (psf->filelength - (2 * sizeof (dword))))
 			break ;
 		} ; /* while (1) */
 		
@@ -238,8 +264,8 @@
 	if (! psf->dataoffset)
 		return SFE_SVX_NO_DATA ;
 
-	psf->sf.format 		= (SF_FORMAT_SVX | SF_FORMAT_PCM);
-	psf->sf.sections 	= 1 ;
+	psf->sf.format   = (SF_FORMAT_SVX | SF_FORMAT_PCM);
+	psf->sf.sections = 1 ;
 					
 	psf->current     = 0 ;
 	psf->endian      = SF_ENDIAN_BIG ;			/* All SVX files are big endian. */
@@ -255,30 +281,17 @@
 
 	psf->close = (func_close) svx_close ;
 
-	switch (psf->bytewidth)
-	{	case  1 :
-				psf->read_short  = (func_short)  pcm_read_sc2s ;
-				psf->read_int    = (func_int)    pcm_read_sc2i ;
-				psf->read_double = (func_double) pcm_read_sc2d ;
-				break ;
-		case  2 :
-				psf->read_short  = (func_short)  pcm_read_bes2s ;
-				psf->read_int    = (func_int)    pcm_read_bes2i ;
-				psf->read_double = (func_double) pcm_read_bes2d ;
-				break ;
-		default : 
-				/* printf ("Weird bytewidth (%d)\n", psf->bytewidth) ; */
-				return SFE_UNIMPLEMENTED ;
-		} ;
+	psf->chars = SF_CHARS_SIGNED ;
+	if ((error = pcm_read_init (psf)))
+		return error ;
 
 	return 0 ;
 } /* svx_open_read */
 
-int 	svx_open_write	(SF_PRIVATE *psf)
-{	static	char 	annotation	[] = "libsndfile by Erik de Castro Lopo\0\0\0" ;
-	VHDR_CHUNK		vhdr ;
-	unsigned int	FORMsize ;
-	
+int 	
+svx_open_write	(SF_PRIVATE *psf)
+{	int error ;
+
 	if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_SVX)
 		return	SFE_BAD_OPEN_FORMAT ;
 	if ((psf->sf.format & SF_FORMAT_SUBMASK) != SF_FORMAT_PCM)
@@ -294,56 +307,17 @@
 	psf->filelength  = psf->datalength + psf->dataoffset ;
 	psf->error       = 0 ;
 
-	FORMsize   = 0x7FFFFFFF ;   /* Correct this when closing file. */
-	
-	vhdr.oneShotHiSamples  = psf->sf.samples ;
-	vhdr.repeatHiSamples   = 0 ;
-	vhdr.samplesPerHiCycle = 0 ;
-	vhdr.samplesPerSec     = psf->sf.samplerate ;
-	vhdr.octave            = 1 ;
-	vhdr.compression       = 0 ;
-	vhdr.volume            = (psf->bytewidth == 1) ? 255 : 0xFFFF ;
+	error = svx_write_header (psf) ;
+	if (error)
+		return error ;
+		
+	psf->close        = (func_close)  svx_close ;
+	psf->write_header = (func_wr_hdr) svx_write_header ;
 
-	if (CPU_IS_LITTLE_ENDIAN)
-		endswap_vhdr_chunk (&vhdr) ;
+	psf->chars = SF_CHARS_SIGNED ;
+	if ((error = pcm_write_init (psf)))
+		return error ;
 
-	psf_hprintf (psf, "mL"  , FORM_MARKER, FORMsize) ;
-	psf_hprintf (psf, "m"   , (psf->bytewidth == 1) ? SVX8_MARKER : SV16_MARKER) ;
-	psf_hprintf (psf, "mLb" , VHDR_MARKER, sizeof (VHDR_CHUNK), &vhdr, sizeof (VHDR_CHUNK)) ;
-	psf_hprintf (psf, "mSmS", NAME_MARKER, psf->filename, ANNO_MARKER, annotation) ;
-	psf_hprintf (psf, "mL"  , BODY_MARKER, psf->datalength) ;
-
-
-	fwrite (psf->header, psf->headindex, 1, psf->file) ;
-
-	psf->dataoffset  = ftell (psf->file) ;
-	
-	psf->close = (func_close) svx_close ;
-
-	switch (psf->bytewidth)
-	{	case  1 :
-				psf->write_short  = (func_short) pcm_write_s2sc ;
-				psf->write_int    = (func_int) pcm_write_i2sc ;
-				psf->write_double = (func_double) pcm_write_d2sc ;
-				break ;
-		case  2 :
-				psf->write_short  = (func_short) pcm_write_s2bes ;
-				psf->write_int    = (func_int) pcm_write_i2bes ;
-				psf->write_double = (func_double) pcm_write_d2bes ;
-				break ;
-		case  3 :
-				psf->write_short  = (func_short) pcm_write_s2bet ;
-				psf->write_int    = (func_int) pcm_write_i2bet ;
-				psf->write_double = (func_double) pcm_write_d2bet ;
-				break ;
-		case  4 :
-				psf->write_short  = (func_short) pcm_write_s2bei ;
-				psf->write_int    = (func_int) pcm_write_i2bei ;
-				psf->write_double = (func_double) pcm_write_d2bei ;
-				break ;
-		default : return SFE_UNIMPLEMENTED ;
-		} ;
-
 	return 0 ;
 } /* svx_open_write */
 
@@ -350,7 +324,8 @@
 /*------------------------------------------------------------------------------
 */
 
-int	svx_close	(SF_PRIVATE  *psf)
+static int	
+svx_close	(SF_PRIVATE  *psf)
 {	
 	if (psf->mode == SF_MODE_WRITE)
 	{	/*  Now we know for certain the length of the file we can re-write 
@@ -359,12 +334,11 @@
                 
 		fseek (psf->file, 0, SEEK_END) ;
 		psf->filelength = ftell (psf->file) ;
-
-		psf_hsetf (psf, FORM_MARKER, "L", psf->filelength - 8) ;
-		psf_hsetf (psf, BODY_MARKER, "L", psf->filelength - psf->dataoffset) ;
-
 		fseek (psf->file, 0, SEEK_SET) ;
-		fwrite (psf->header, psf->headindex, 1, psf->file) ;
+		
+		psf->datalength = psf->filelength - psf->dataoffset ;
+
+		svx_write_header (psf) ;
 		} ;
 
 	if (psf->fdata)
@@ -373,4 +347,49 @@
 	
 	return 0 ;
 } /* svx_close */
+
+static int
+svx_write_header (SF_PRIVATE *psf)
+{	static	char 	annotation	[] = "libsndfile by Erik de Castro Lopo\0\0\0" ;
+	
+	psf->header [0] = 0 ;
+	psf->headindex = 0 ;
+	fseek (psf->file, 0, SEEK_SET) ;
+
+	/* FORM marker and FORM size. */	
+	psf_binheader_writef (psf, "mL", FORM_MARKER, psf->filelength - 8) ;
+	psf_binheader_writef (psf, "m", (psf->bytewidth == 1) ? SVX8_MARKER : SV16_MARKER) ;
+
+	/* VHDR chunk. */
+	psf_binheader_writef (psf, "mL", VHDR_MARKER, sizeof (VHDR_CHUNK)) ;
+	/* VHDR : oneShotHiSamples, repeatHiSamples, samplesPerHiCycle */
+	psf_binheader_writef (psf, "LLL", psf->sf.samples, 0, 0) ;
+	/* VHDR : samplesPerSec, octave, compression */
+	psf_binheader_writef (psf, "Wbb", psf->sf.samplerate, 1, 0) ;
+	/* VHDR : volume */
+	psf_binheader_writef (psf, "L", (psf->bytewidth == 1) ? 255 : 0xFFFF) ;
+
+	/* Filename and annotation strings. */
+	psf_binheader_writef (psf, "mSmS", NAME_MARKER, psf->filename, ANNO_MARKER, annotation) ;
+	
+	/* BODY marker and size. */
+	psf_binheader_writef (psf, "mL", BODY_MARKER, psf->datalength) ;
+
+	fwrite (psf->header, psf->headindex, 1, psf->file) ;
+
+	psf->dataoffset = psf->headindex ;
+	
+	return 0 ;
+} /* svx_write_header */
+
+/*-
+static void 
+endswap_vhdr_chunk (VHDR_CHUNK *vhdr)
+{	vhdr->oneShotHiSamples  = ENDSWAP_INT (vhdr->oneShotHiSamples) ;
+	vhdr->repeatHiSamples   = ENDSWAP_INT (vhdr->repeatHiSamples) ;
+	vhdr->samplesPerHiCycle = ENDSWAP_INT (vhdr->samplesPerHiCycle) ;
+	vhdr->samplesPerSec     = ENDSWAP_SHORT (vhdr->samplesPerSec) ;
+	vhdr->volume            = ENDSWAP_INT (vhdr->volume) ;
+} /+* endswap_vhdr_chunk *+/
+-*/
 
--- a/common/libsndfile/src/ulaw.c
+++ b/common/libsndfile/src/ulaw.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -20,18 +20,54 @@
 #include	<unistd.h>
 
 #include	"sndfile.h"
+#include	"floatcast.h"
 #include	"common.h"
 
+static int		ulaw_read_ulaw2s (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
+static int		ulaw_read_ulaw2i (SF_PRIVATE *psf, int *ptr, unsigned int len) ;
+static int		ulaw_read_ulaw2f (SF_PRIVATE *psf, float *ptr, unsigned int len) ;
+static int		ulaw_read_ulaw2d (SF_PRIVATE *psf, double *ptr, unsigned int len, int normalize) ;
+
+static int		ulaw_write_s2ulaw (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
+static int		ulaw_write_i2ulaw (SF_PRIVATE *psf, int *ptr, unsigned int len) ;
+static int		ulaw_write_f2ulaw (SF_PRIVATE *psf, float *ptr, unsigned int len) ;
+static int		ulaw_write_d2ulaw (SF_PRIVATE *psf, double *ptr, unsigned int len, int normalize) ;
+
 static  void    ulaw2s_array      (unsigned char *buffer, unsigned int count, short *ptr, unsigned int index) ;
 static  void    ulaw2i_array      (unsigned char *buffer, unsigned int count, int *ptr, unsigned int index) ;
+static  void    ulaw2f_array      (unsigned char *buffer, unsigned int count, float *ptr, unsigned int index, float normfact) ;
 static  void    ulaw2d_array      (unsigned char *buffer, unsigned int count, double *ptr, unsigned int index, double normfact) ;
 
 static  void    s2ulaw_array      (short *buffer, unsigned int count, unsigned char *ptr, unsigned int index) ;
 static  void    i2ulaw_array      (int *buffer, unsigned int count, unsigned char *ptr, unsigned int index) ;
+static  void    f2ulaw_array      (float *buffer, unsigned int count, unsigned char *ptr, unsigned int index, float normfact) ;
 static  void    d2ulaw_array      (double *buffer, unsigned int count, unsigned char *ptr, unsigned int index, double normfact) ;
 
 
-int		ulaw_read_ulaw2s (SF_PRIVATE *psf, short *ptr, unsigned int len)
+int 
+ulaw_read_init (SF_PRIVATE *psf)
+{
+	psf->read_short  = (func_short)  ulaw_read_ulaw2s ;
+	psf->read_int    = (func_int)    ulaw_read_ulaw2i ;
+	psf->read_float  = (func_float)  ulaw_read_ulaw2f ;
+	psf->read_double = (func_double) ulaw_read_ulaw2d ;
+
+	return 0 ;
+} /* ulaw_read_int */
+
+int 
+ulaw_write_init (SF_PRIVATE *psf)
+{
+	psf->write_short  = (func_short)  ulaw_write_s2ulaw ;
+	psf->write_int    = (func_int)    ulaw_write_i2ulaw ;
+	psf->write_float  = (func_float)  ulaw_write_f2ulaw ;
+	psf->write_double = (func_double) ulaw_write_d2ulaw ;
+
+	return 0 ;
+} /* ulaw_write_int */
+
+static int
+ulaw_read_ulaw2s (SF_PRIVATE *psf, short *ptr, unsigned int len)
 {	unsigned int readcount, thisread, index = 0 ;
 	int		bytecount, bufferlen ;
 	int		total = 0 ;
@@ -56,7 +92,8 @@
 	return total ;
 } /* ulaw_read_ulaw2s */
 
-int		ulaw_read_ulaw2i (SF_PRIVATE *psf, int *ptr, unsigned int len)
+static int
+ulaw_read_ulaw2i (SF_PRIVATE *psf, int *ptr, unsigned int len)
 {	unsigned int readcount, thisread, index = 0 ;
 	int		bytecount, bufferlen ;
 	int		total = 0 ;
@@ -81,10 +118,40 @@
 	return total ;
 } /* ulaw_read_ulaw2i */
 
-int		ulaw_read_ulaw2d (SF_PRIVATE *psf, double *ptr, unsigned int len, int normalize)
+static int
+ulaw_read_ulaw2f (SF_PRIVATE *psf, float *ptr, unsigned int len)
 {	unsigned int readcount, thisread, index = 0 ;
 	int		bytecount, bufferlen ;
 	int		total = 0 ;
+	float	normfact ;
+
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
+
+	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
+		ulaw2f_array ((unsigned char*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;
+		total += thisread ;
+		if (thisread < readcount)
+			break ;
+		index += thisread / psf->bytewidth ;
+		bytecount -= thisread ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* ulaw_read_ulaw2f */
+
+static int
+ulaw_read_ulaw2d (SF_PRIVATE *psf, double *ptr, unsigned int len, int normalize)
+{	unsigned int readcount, thisread, index = 0 ;
+	int		bytecount, bufferlen ;
+	int		total = 0 ;
 	double	normfact ;
 	
 	normfact = (normalize ? 1.0 / ((double) 0x8000) : 1.0) ;
@@ -111,7 +178,8 @@
 /*=============================================================================================
 */
 
-int	ulaw_write_s2ulaw	(SF_PRIVATE *psf, short *ptr, unsigned int len)
+static int
+ulaw_write_s2ulaw	(SF_PRIVATE *psf, short *ptr, unsigned int len)
 {	unsigned int	writecount, thiswrite, index = 0 ;
 	int		bytecount, bufferlen ;
 	int		total = 0 ;
@@ -136,7 +204,8 @@
 	return total ;
 } /* ulaw_write_s2ulaw */
 
-int	ulaw_write_i2ulaw	(SF_PRIVATE *psf, int *ptr, unsigned int len)
+static int
+ulaw_write_i2ulaw	(SF_PRIVATE *psf, int *ptr, unsigned int len)
 {	unsigned int	writecount, thiswrite, index = 0 ;
 	int		bytecount, bufferlen ;
 	int		total = 0 ;
@@ -161,10 +230,40 @@
 	return total ;
 } /* ulaw_write_i2ulaw */
 
-int	ulaw_write_d2ulaw	(SF_PRIVATE *psf, double *ptr, unsigned int len, int normalize)
+static int
+ulaw_write_f2ulaw	(SF_PRIVATE *psf, float *ptr, unsigned int len)
 {	unsigned int	writecount, thiswrite, index = 0 ;
 	int		bytecount, bufferlen ;
 	int		total = 0 ;
+	float	normfact ;
+
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x8000) : 1.0 ;
+
+	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
+	bytecount = len * psf->bytewidth ;
+	while (bytecount > 0)
+	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
+		f2ulaw_array (ptr, index, (unsigned char*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
+		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
+		total += thiswrite ;
+		if (thiswrite < writecount)
+			break ;
+		index += thiswrite / psf->bytewidth ;
+		bytecount -= thiswrite ;
+		} ;
+
+	total /= psf->bytewidth ;
+	if (total < len)
+		psf->error = SFE_SHORT_READ ;
+	
+	return total ;
+} /* ulaw_write_f2ulaw */
+
+static int
+ulaw_write_d2ulaw	(SF_PRIVATE *psf, double *ptr, unsigned int len, int normalize)
+{	unsigned int	writecount, thiswrite, index = 0 ;
+	int		bytecount, bufferlen ;
+	int		total = 0 ;
 	double	normfact ;
 	
 	normfact = (normalize ? ((double) 0x8000) : 1.0) ;
@@ -189,9 +288,6 @@
 	return total ;
 } /* ulaw_write_d2ulaw */
 
-
-
-
 /*=============================================================================================
  *	Private static functions and data.
  */
@@ -902,44 +998,56 @@
 	0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00
 } ;
 
-static  
-void	ulaw2s_array	(unsigned char *buffer, unsigned int count, short *ptr, unsigned int index)
+static void	
+ulaw2s_array	(unsigned char *buffer, unsigned int count, short *ptr, unsigned int index)
 {	int 	k ;
 	for (k = 0 ; k < count ; k++)
 	{	if (buffer [k] & 0x80)
-			ptr [index] = -1 * ulaw_decode [((int)buffer [k]) & 0x7F] ;
+			ptr [index] = -1 * ulaw_decode [((int) buffer [k]) & 0x7F] ;
 		else
-			ptr [index] = ulaw_decode [((int)buffer [k]) & 0x7F] ;
+			ptr [index] = ulaw_decode [((int) buffer [k]) & 0x7F] ;
 		index ++ ;
 		} ;
 } /* ulaw2s_array */
 
-static  
-void	ulaw2i_array	(unsigned char *buffer, unsigned int count, int *ptr, unsigned int index)
+static void	
+ulaw2i_array	(unsigned char *buffer, unsigned int count, int *ptr, unsigned int index)
 {	int 	k ;
 	for (k = 0 ; k < count ; k++)
 	{	if (buffer [k] & 0x80)
-			ptr [index] = -1 * ulaw_decode [((int)buffer [k]) & 0x7F] ;
+			ptr [index] = -1 * ulaw_decode [((int) buffer [k]) & 0x7F] ;
 		else
-			ptr [index] = ulaw_decode [((int)buffer [k]) & 0x7F] ;
+			ptr [index] = ulaw_decode [((int) buffer [k]) & 0x7F] ;
 		index ++ ;
 		} ;
 } /* ulaw2i_array */
 
-static  
-void	ulaw2d_array	(unsigned char *buffer, unsigned int count, double *ptr, unsigned int index, double normfact)
+static void	
+ulaw2f_array	(unsigned char *buffer, unsigned int count, float *ptr, unsigned int index, float normfact)
 {	int 	k ;
 	for (k = 0 ; k < count ; k++)
 	{	if (buffer [k] & 0x80)
-			ptr [index] = -normfact * ulaw_decode [((int)buffer [k]) & 0x7F] ;
+			ptr [index] = -normfact * ulaw_decode [((int) buffer [k]) & 0x7F] ;
 		else
-			ptr [index] = normfact * ulaw_decode [((int)buffer [k]) & 0x7F] ;
+			ptr [index] = normfact * ulaw_decode [((int) buffer [k]) & 0x7F] ;
 		index ++ ;
 		} ;
+} /* ulaw2f_array */
+
+static void	
+ulaw2d_array	(unsigned char *buffer, unsigned int count, double *ptr, unsigned int index, double normfact)
+{	int 	k ;
+	for (k = 0 ; k < count ; k++)
+	{	if (buffer [k] & 0x80)
+			ptr [index] = -normfact * ulaw_decode [((int) buffer [k]) & 0x7F] ;
+		else
+			ptr [index] = normfact * ulaw_decode [((int) buffer [k]) & 0x7F] ;
+		index ++ ;
+		} ;
 } /* ulaw2d_array */
 
-static  
-void    s2ulaw_array      (short *ptr, unsigned int index, unsigned char *buffer, unsigned int count)
+static void    
+s2ulaw_array      (short *ptr, unsigned int index, unsigned char *buffer, unsigned int count)
 {	unsigned int	k ;
 
 	for (k = 0 ; k < count ; k++)
@@ -951,8 +1059,8 @@
 		} ;
 } /* s2ulaw_array */
 
-static  
-void    i2ulaw_array      (int *ptr, unsigned int index, unsigned char *buffer, unsigned int count)
+static void    
+i2ulaw_array      (int *ptr, unsigned int index, unsigned char *buffer, unsigned int count)
 {	unsigned int	k ;
 
 	for (k = 0 ; k < count ; k++)
@@ -964,15 +1072,28 @@
 		} ;
 } /* i2ulaw_array */
 
-static  
-void    d2ulaw_array      (double *ptr, unsigned int index, unsigned char *buffer, unsigned int count, double normfact)
+static void
+f2ulaw_array      (float *ptr, unsigned int index, unsigned char *buffer, unsigned int count, float normfact)
 {	unsigned int	k ;
 
 	for (k = 0 ; k < count ; k++)
 	{	if (ptr [index] >= 0) 
-			buffer [k] = ulaw_encode [((int) (normfact * ptr [index])) / 4] ;
+			buffer [k] = ulaw_encode [(FLOAT_TO_INT (normfact * ptr [index])) / 4] ;
 		else
-			buffer [k] = 0x7F & ulaw_encode [((int) (normfact * ptr [index])) / -4] ;
+			buffer [k] = 0x7F & ulaw_encode [(FLOAT_TO_INT (normfact * ptr [index])) / -4] ;
+		index ++ ;
+		} ;
+} /* f2ulaw_array */
+
+static void
+d2ulaw_array      (double *ptr, unsigned int index, unsigned char *buffer, unsigned int count, double normfact)
+{	unsigned int	k ;
+
+	for (k = 0 ; k < count ; k++)
+	{	if (ptr [index] >= 0) 
+			buffer [k] = ulaw_encode [(DOUBLE_TO_INT (normfact * ptr [index])) / 4] ;
+		else
+			buffer [k] = 0x7F & ulaw_encode [(DOUBLE_TO_INT (normfact * ptr [index])) / -4] ;
 		index ++ ;
 		} ;
 } /* d2ulaw_array */
--- a/common/libsndfile/src/ulaw.h
+++ /dev/null
@@ -1,27 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU Lesser General Public License for more details.
-** 
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-int		ulaw_read_ulaw2s (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
-int		ulaw_read_ulaw2i (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
-int		ulaw_read_ulaw2d (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
-
-int		ulaw_write_s2ulaw (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
-int		ulaw_write_i2ulaw (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
-int		ulaw_write_d2ulaw (SF_PRIVATE *psf, short *ptr, unsigned int len) ;
-
--- /dev/null
+++ b/common/libsndfile/src/voc.c
@@ -1,0 +1,376 @@
+/*
+** Copyright (C) 2001 Erik de Castro Lopo <erikd@zip.com.au>
+**  
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU Lesser General Public License as published by
+** the Free Software Foundation; either version 2.1 of the License, or
+** (at your option) any later version.
+** 
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+** GNU Lesser General Public License for more details.
+** 
+** You should have received a copy of the GNU Lesser General Public License
+** along with this program; if not, write to the Free Software 
+** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+#include	<stdio.h>
+#include	<unistd.h>
+#include	<string.h>
+#include	<ctype.h>
+#include	<stdarg.h>
+
+#include	"sndfile.h"
+#include	"config.h"
+#include	"sfendian.h"
+#include	"common.h"
+
+
+/*------------------------------------------------------------------------------
+ * Macros to handle big/little endian issues.
+*/
+
+#if (CPU_IS_LITTLE_ENDIAN == 1)
+#	define	MAKE_MARKER(a,b,c,d)		((a)|((b)<<8)|((c)<<16)|((d)<<24))
+#elif (CPU_IS_BIG_ENDIAN == 1)
+#	define	MAKE_MARKER(a,b,c,d)		(((a)<<24)|((b)<<16)|((c)<<8)|(d))
+#else
+#	error "Cannot determine endian-ness of processor."
+#endif
+
+/*------------------------------------------------------------------------------
+ * Typedefs for file chunks.
+*/
+
+enum
+{	VOC_TYPE_TERMINATOR		= 0,
+	VOC_TYPE_SOUND_DATA		= 1,
+	VOC_TYPE_SOUND_CONTINUE = 2,
+	VOC_TYPE_SILENCE		= 3,
+	VOC_TYPE_MARKER			= 4,
+	VOC_TYPE_ASCII			= 5,
+	VOC_TYPE_REPEAT			= 6,
+	VOC_TYPE_END_REPEAT		= 7,
+	VOC_TYPE_EXTENDED		= 8,
+	VOC_TYPE_9				= 9
+} ;
+
+/*------------------------------------------------------------------------------
+ * Private static functions.
+*/
+
+static	int		voc_close	(SF_PRIVATE  *psf) ;
+
+/*------------------------------------------------------------------------------
+** Public functions.
+*/
+
+int
+voc_open_read	(SF_PRIVATE *psf)
+{	char	creative [20], type ;
+	short	version ;
+
+	/* Set position to start of file to begin reading header. */
+	psf_binheader_readf (psf, "pB", 0, creative, sizeof (creative)) ;
+		
+	if (creative [sizeof (creative) - 1] != 0x1A)
+		return SFE_VOC_NO_CREATIVE ;
+		
+	/* Terminate the string. */
+	creative [sizeof (creative) - 1] = 0 ;
+	
+	if (strcmp ("Creative Voice File", creative))
+		return SFE_VOC_NO_CREATIVE ;
+
+	psf_log_printf (psf, "%s\n", creative) ;
+
+	psf_binheader_readf (psf, "ww", &(psf->dataoffset), &version) ;
+
+	psf_log_printf (psf, "dataoffset : %d\n", psf->dataoffset) ;
+	psf_log_printf (psf, "version    : %X\n", version) ;
+
+	if (version != 0x010A && version != 0x0114)
+		return SFE_VOC_BAD_VERSION ;
+
+	psf_binheader_readf (psf, "w", &version) ;
+	psf_log_printf (psf, "version 2  : %X\n", version) ;
+	
+	while (1)
+	{	psf_binheader_readf (psf, "b", &type) ;
+	
+		switch (type)
+		{	case VOC_TYPE_TERMINATOR :
+					psf_log_printf (psf, " Terminator\n") ;
+					break ;
+
+			case VOC_TYPE_SOUND_DATA :
+					{	unsigned char rate_byte, compression ;
+						int		size ;
+
+						psf_binheader_readf (psf, "tbb", &size, &rate_byte, &compression) ;
+
+						psf_log_printf (psf, " Sound Data : %d\n", size) ;
+						psf_log_printf (psf, "  sr   : %d => %dHz\n", (rate_byte & 0xFF), 1000000 / (256 - rate_byte)) ;
+						psf_log_printf (psf, "  comp : %d\n", compression) ;
+	
+						psf_binheader_readf (psf, "j", size) ;
+						} ;
+					break ;
+
+			case VOC_TYPE_SOUND_CONTINUE :
+					{	int		size ;
+
+						psf_binheader_readf (psf, "t", &size) ;
+
+						psf_log_printf (psf, " Sound Continue : %d\n", size) ;
+	
+						psf_binheader_readf (psf, "j", size) ;
+						} ;
+					break ;
+
+			case VOC_TYPE_SILENCE :
+					{	unsigned char rate_byte ;
+						short length ;
+						
+						psf_log_printf (psf, " Silence\n") ;
+						psf_binheader_readf (psf, "wb", &length, &rate_byte) ;
+						psf_log_printf (psf, "  length : %d\n", length) ;
+						psf_log_printf (psf, "  sr     : %d => %dHz\n", (rate_byte & 0xFF), 1000000 / (256 - rate_byte)) ;
+		  				} ;
+					break ;
+
+			case VOC_TYPE_MARKER :
+					{	int		size ;
+						short	value ;
+
+						psf_log_printf (psf, " Marker\n") ;
+
+						psf_binheader_readf (psf, "tw", &size, &value) ;
+						
+						psf_log_printf (psf, "  size  : %d\n", size) ;
+						psf_log_printf (psf, "  value : %d\n", value) ;
+						} ;
+					break ;
+
+			case VOC_TYPE_ASCII :
+					{	int		size ;
+
+						psf_binheader_readf (psf, "t", &size) ;
+
+						psf_log_printf (psf, " ASCII : %d\n", size) ;
+	
+						psf_binheader_readf (psf, "B", psf->header, size) ;
+						psf->header [size] = 0 ;
+						psf_log_printf (psf, "  text : %s\n", psf->header) ;
+						} ;
+					break ;
+
+			case VOC_TYPE_REPEAT :
+					{	int		size ;
+						short	count ;
+
+						psf_binheader_readf (psf, "tw", &size, &count) ;
+
+						psf_log_printf (psf, " Marker : %d\n", size) ;
+						psf_log_printf (psf, "  value : %d\n", count) ;
+						} ;
+					break ;
+
+			case VOC_TYPE_END_REPEAT :
+					psf_log_printf (psf, " End Repeat\n") ;
+					break ;
+						
+			case VOC_TYPE_EXTENDED :
+					{	unsigned char pack, mode ;
+						short 	rate_short ;
+						int		size, sample_rate ;
+
+						psf_binheader_readf (psf, "t", &size) ;
+						psf_log_printf (psf, " Extended : %d\n", size) ;
+						
+						psf_binheader_readf (psf, "wbb", &rate_short, &pack, &mode) ;
+						psf_log_printf (psf, "  size : %d\n", size) ;
+						psf_log_printf (psf, "  pack : %d\n", pack) ;
+						psf_log_printf (psf, "  mode : %d\n", mode) ;
+						
+						if (mode)
+							sample_rate = 128000000 / (65536 - rate_short) ;
+						else
+							sample_rate = 256000000 / (65536 - rate_short) ;
+
+						psf_log_printf (psf, "  sr   : %d => %dHz\n", (rate_short & 0xFFFF), sample_rate) ;
+						psf_binheader_readf (psf, "j", size) ;
+						} ;
+					break ;
+
+			case VOC_TYPE_9 :
+					{	unsigned char bitwidth, channels, byte6 ;
+						int sample_rate, size, bytecount = 0 ;
+						
+						psf_binheader_readf (psf, "t", &size) ;
+						psf_log_printf (psf, " Type 9 : %d\n", size) ;
+
+						bytecount = psf_binheader_readf (psf, "lbbb", &sample_rate, &bitwidth, &channels, &byte6) ;
+
+						psf_log_printf (psf, "  sample rate : %d\n", sample_rate) ;
+						psf_log_printf (psf, "  bit width   : %d\n", bitwidth) ;
+						psf_log_printf (psf, "  channels    : %d\n", channels) ;
+
+						psf_binheader_readf (psf, "j", size - bytecount) ;
+						} ;
+					break ;
+
+			default :
+				psf_log_printf (psf, "Unknown type : %d\n", type & 0xFF) ;
+				return SFE_VOC_BAD_MARKER ;
+			} ;
+
+		if (ftell (psf->file) >= psf->filelength)
+			break ;
+		} ;
+
+
+
+	psf->sf.seekable = SF_TRUE ;
+
+	psf->close = (func_close) voc_close ;
+
+	return 0 ;
+} /* voc_open_read */
+
+int 	
+voc_open_write	(SF_PRIVATE *psf)
+{	
+
+	return 0 ;
+} /* voc_open_write */
+
+/*------------------------------------------------------------------------------
+*/
+
+static int	
+voc_close	(SF_PRIVATE  *psf)
+{	
+	if (psf->mode == SF_MODE_WRITE)
+	{	/*  Now we know for certain the length of the file we can re-write 
+		**	correct values for the FORM, 8SVX and BODY chunks.
+		*/
+                
+		} ;
+
+	if (psf->fdata)
+		free (psf->fdata) ;
+	psf->fdata = NULL ;
+	
+	return 0 ;
+} /* voc_close */
+
+
+/*------------------------------------------------------------------------------------
+
+Creative Voice (VOC) file format
+--------------------------------
+
+~From: galt@dsd.es.com
+
+(byte numbers are hex!)
+
+    HEADER (bytes 00-19)
+    Series of DATA BLOCKS (bytes 1A+) [Must end w/ Terminator Block]
+
+- ---------------------------------------------------------------
+
+HEADER:
+=======
+     byte #     Description
+     ------     ------------------------------------------
+     00-12      "Creative Voice File"
+     13         1A (eof to abort printing of file)
+     14-15      Offset of first datablock in .voc file (std 1A 00
+                in Intel Notation)
+     16-17      Version number (minor,major) (VOC-HDR puts 0A 01)
+     18-19      1's Comp of Ver. # + 1234h (VOC-HDR puts 29 11)
+
+- ---------------------------------------------------------------
+
+DATA BLOCK:
+===========
+
+   Data Block:  TYPE(1-byte), SIZE(3-bytes), INFO(0+ bytes)
+   NOTE: Terminator Block is an exception -- it has only the TYPE byte.
+
+      TYPE   Description     Size (3-byte int)   Info
+      ----   -----------     -----------------   -----------------------
+      00     Terminator      (NONE)              (NONE)
+      01     Sound data      2+length of data    *
+      02     Sound continue  length of data      Voice Data
+      03     Silence         3                   **
+      04     Marker          2                   Marker# (2 bytes)
+      05     ASCII           length of string    null terminated string
+      06     Repeat          2                   Count# (2 bytes)
+      07     End repeat      0                   (NONE)
+      08     Extended        4                   ***
+
+      *Sound Info Format:    
+       --------------------- 
+       00   Sample Rate      
+       01   Compression Type 
+       02+  Voice Data
+
+      **Silence Info Format:
+      ----------------------------
+      00-01  Length of silence - 1
+      02     Sample Rate
+      
+
+    ***Extended Info Format:
+       ---------------------
+       00-01  Time Constant: Mono: 65536 - (256000000/sample_rate)
+                             Stereo: 65536 - (25600000/(2*sample_rate))
+       02     Pack
+       03     Mode: 0 = mono
+                    1 = stereo
+
+
+  Marker#           -- Driver keeps the most recent marker in a status byte
+  Count#            -- Number of repetitions + 1
+                         Count# may be 1 to FFFE for 0 - FFFD repetitions
+                         or FFFF for endless repetitions
+  Sample Rate       -- SR byte = 256-(1000000/sample_rate)
+  Length of silence -- in units of sampling cycle
+  Compression Type  -- of voice data
+                         8-bits    = 0
+                         4-bits    = 1
+                         2.6-bits  = 2
+                         2-bits    = 3
+                         Multi DAC = 3+(# of channels) [interesting--
+                                       this isn't in the developer's manual]
+
+
+---------------------------------------------------------------------------------
+Addendum submitted by Votis Kokavessis:
+
+After some experimenting with .VOC files I found out that there is a Data Block 
+Type 9, which is not covered in the VOC.TXT file. Here is what I was able to discover 
+about this block type:
+  
+  
+TYPE: 09
+SIZE: 12 + length of data
+INFO: 12 (twelve) bytes
+  
+INFO STRUCTURE:
+  
+Bytes 0-1: (Word) Sample Rate (e.g. 44100)
+Bytes 2-3: zero (could be that bytes 0-3 are a DWord for Sample Rate)
+Byte 4: Sample Size in bits (e.g. 16)
+Byte 5: Number of channels (e.g. 1 for mono, 2 for stereo)
+Byte 6: Unknown (equal to 4 in all files I examined)
+Bytes 7-11: zero
+
+
+-------------------------------------------------------------------------------------*/
+
--- a/common/libsndfile/src/wav.c
+++ b/common/libsndfile/src/wav.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -21,14 +21,12 @@
 #include	<unistd.h>
 #include	<string.h>
 #include	<ctype.h>
+#include	<time.h>
 
 #include	"sndfile.h"
 #include	"config.h"
 #include	"sfendian.h"
 #include	"common.h"
-#include	"pcm.h"
-#include	"ulaw.h"
-#include	"alaw.h"
 #include	"wav.h"
 
 /*------------------------------------------------------------------------------
@@ -97,22 +95,19 @@
 	WAVE_FORMAT_EXTENSIBLE			= 0xFFFE
 } ;
 
+#define	FACT_CHUNK_SIZE	sizeof (int)
+
 /*------------------------------------------------------------------------------
  * Macros to handle big/little endian issues.
  */
 
-#if (CPU_IS_LITTLE_ENDIAN == 1)
-#	define	MAKE_MARKER(a,b,c,d)		((a)|((b)<<8)|((c)<<16)|((d)<<24))
-#elif (CPU_IS_BIG_ENDIAN == 1)
-#	define	MAKE_MARKER(a,b,c,d)		(((a)<<24)|((b)<<16)|((c)<<8)|(d))
-#else
-#	error "Cannot determine endian-ness of processor."
-#endif
-
 #define RIFF_MARKER	(MAKE_MARKER ('R', 'I', 'F', 'F')) 
 #define WAVE_MARKER	(MAKE_MARKER ('W', 'A', 'V', 'E')) 
 #define fmt_MARKER	(MAKE_MARKER ('f', 'm', 't', ' ')) 
 #define data_MARKER	(MAKE_MARKER ('d', 'a', 't', 'a')) 
+#define fact_MARKER	(MAKE_MARKER ('f', 'a', 'c', 't')) 
+#define PEAK_MARKER	(MAKE_MARKER ('P', 'E', 'A', 'K')) 
+
 #define cue_MARKER	(MAKE_MARKER ('c', 'u', 'e', ' ')) 
 #define LIST_MARKER	(MAKE_MARKER ('L', 'I', 'S', 'T')) 
 #define slnt_MARKER	(MAKE_MARKER ('s', 'l', 'n', 't')) 
@@ -122,139 +117,242 @@
 #define adtl_MARKER	(MAKE_MARKER ('a', 'd', 't', 'l')) 
 #define labl_MARKER	(MAKE_MARKER ('l', 'a', 'b', 'l')) 
 #define note_MARKER	(MAKE_MARKER ('n', 'o', 't', 'e')) 
-#define fact_MARKER	(MAKE_MARKER ('f', 'a', 'c', 't')) 
 #define smpl_MARKER	(MAKE_MARKER ('s', 'm', 'p', 'l')) 
 #define bext_MARKER	(MAKE_MARKER ('b', 'e', 'x', 't')) 
 #define MEXT_MARKER	(MAKE_MARKER ('M', 'E', 'X', 'T')) 
 #define DISP_MARKER	(MAKE_MARKER ('D', 'I', 'S', 'P')) 
+#define acid_MARKER	(MAKE_MARKER ('a', 'c', 'i', 'd')) 
+#define PAD_MARKER	(MAKE_MARKER ('P', 'A', 'D', ' ')) 
+#define adtl_MARKER	(MAKE_MARKER ('a', 'd', 't', 'l')) 
 
+#define ISFT_MARKER	(MAKE_MARKER ('I', 'S', 'F', 'T')) 
+#define ICRD_MARKER	(MAKE_MARKER ('I', 'C', 'R', 'D')) 
+#define ICOP_MARKER	(MAKE_MARKER ('I', 'C', 'O', 'P')) 
+#define IART_MARKER	(MAKE_MARKER ('I', 'A', 'R', 'T')) 
+#define INAM_MARKER	(MAKE_MARKER ('I', 'N', 'A', 'M')) 
+#define IENG_MARKER	(MAKE_MARKER ('I', 'E', 'N', 'G')) 
+#define IART_MARKER	(MAKE_MARKER ('I', 'A', 'R', 'T')) 
+#define ICOP_MARKER	(MAKE_MARKER ('I', 'C', 'O', 'P')) 
+#define IPRD_MARKER	(MAKE_MARKER ('I', 'P', 'R', 'D')) 
+#define ISRC_MARKER	(MAKE_MARKER ('I', 'S', 'R', 'C')) 
+#define ISBJ_MARKER	(MAKE_MARKER ('I', 'S', 'B', 'J')) 
+#define ICMT_MARKER	(MAKE_MARKER ('I', 'C', 'M', 'T')) 
+
+
+
+enum {
+	HAVE_RIFF	= 0x01,
+	HAVE_WAVE	= 0x02,
+	HAVE_fmt	= 0x04,
+	HAVE_fact	= 0x08,
+	HAVE_PEAK	= 0x10,
+	HAVE_data	= 0x20
+} ;
+
 /*------------------------------------------------------------------------------
  * Private static functions.
  */
 
+static int		wav_close	(SF_PRIVATE  *psf) ;
+
 static int		read_fmt_chunk	(SF_PRIVATE *psf, WAV_FMT *wav_fmt) ;
-static int		write_header (SF_PRIVATE *psf, WAV_FMT *wav_fmt, unsigned int size, int do_fact) ;
+static int		wav_write_header (SF_PRIVATE *psf) ;
+static int		wav_write_tailer (SF_PRIVATE *psf) ;
 
+static int 		wav_subchunk_parse	(SF_PRIVATE *psf, int chunk) ;
+
 static const 	char* wav_format_str (int k) ;
 
-static void		le2h_wav_fmt (WAV_FMT *fmt) ;
-static void		h2le_wav_fmt (WAV_FMT *fmt) ;
-
 /*------------------------------------------------------------------------------
- * Public functions.
- */
+** Public functions.
+*/
 
-int 	wav_open_read	(SF_PRIVATE *psf)
+int
+wav_open_read	(SF_PRIVATE *psf)
 {	WAV_FMT			wav_fmt ;
 	FACT_CHUNK		fact_chunk ;
 	unsigned int	dword, marker, RIFFsize ;
 	int				parsestage = 0, error, format = 0 ;
+	char			*cptr ;	
 	
-	psf->sf.seekable = SF_TRUE ;
-
+	/* Set position to start of file to begin reading header. */
+	psf_binheader_readf (psf, "p", 0) ;	
+		
 	while (1)
-	{	fread (&marker, sizeof (marker), 1, psf->file) ;
+	{	psf_binheader_readf (psf, "m", &marker) ;
 		switch (marker)
 		{	case RIFF_MARKER :
-					if (parsestage != 0)
+					if (parsestage)
 						return SFE_WAV_NO_RIFF ;
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-					RIFFsize = LE2H_INT (dword) ;	
+
+					psf_binheader_readf (psf, "l", &RIFFsize) ;
+					
 					if (psf->filelength  < RIFFsize + 2 * sizeof (dword))
 					{	dword = psf->filelength - 2 * sizeof (dword);
-						psf_sprintf (psf, "RIFF : %d (should be %d)\n", RIFFsize, dword) ;
+						psf_log_printf (psf, "RIFF : %d (should be %d)\n", RIFFsize, dword) ;
 						RIFFsize = dword ;
 						}
 					else
-						psf_sprintf (psf, "RIFF : %d\n", RIFFsize) ;
-					parsestage = 1 ;
+						psf_log_printf (psf, "RIFF : %d\n", RIFFsize) ;
+					parsestage |= HAVE_RIFF ;
 					break ;
 					
 			case WAVE_MARKER :
-					if (parsestage != 1)
+					if ((parsestage & HAVE_RIFF) != HAVE_RIFF)
 						return SFE_WAV_NO_WAVE ;
-					psf_sprintf (psf, "WAVE\n") ;
-					parsestage = 2 ;
+					psf_log_printf (psf, "WAVE\n") ;
+					parsestage |= HAVE_WAVE ;
 					break ;
 			
 			case fmt_MARKER :
-					if (parsestage != 2)
+					if ((parsestage & (HAVE_RIFF | HAVE_WAVE)) != (HAVE_RIFF | HAVE_WAVE))
 						return SFE_WAV_NO_FMT ;
 					if ((error = read_fmt_chunk (psf, &wav_fmt)))
 						return error ;
 						
 					format     = wav_fmt.format ;
-					parsestage = 3 ;
+					parsestage |= HAVE_fmt ;
 					break ;
 					
 			case data_MARKER :
-					if (parsestage < 3)
+					if ((parsestage & (HAVE_RIFF | HAVE_WAVE | HAVE_fmt)) != (HAVE_RIFF | HAVE_WAVE | HAVE_fmt))
 						return SFE_WAV_NO_DATA ;
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-					psf->datalength = LE2H_INT (dword) ;
+					
+					psf_binheader_readf (psf, "l", &(psf->datalength)) ;
+
 					psf->dataoffset = ftell (psf->file) ;
 					
 					if (psf->filelength < psf->dataoffset + psf->datalength)
-					{	psf_sprintf (psf, "data : %d (should be %d)\n", psf->datalength, psf->filelength - psf->dataoffset) ;
+					{	psf_log_printf (psf, "data : %d (should be %d)\n", psf->datalength, psf->filelength - psf->dataoffset) ;
 						psf->datalength = psf->filelength - psf->dataoffset ;
 						}
 					else
-						psf_sprintf (psf, "data : %d\n", psf->datalength) ;
+						psf_log_printf (psf, "data : %d\n", psf->datalength) ;
 
 					if (format == WAVE_FORMAT_MS_ADPCM && psf->datalength % 2)
 					{	psf->datalength ++ ;
-						psf_sprintf (psf, "*** Data length odd. Increasing it by 1.\n") ;
+						psf_log_printf (psf, "*** Data length odd. Increasing it by 1.\n") ;
 						} ;
 		
+					parsestage |= HAVE_data ;
+
+					if (! psf->sf.seekable)
+						break ;
+					
+					/* Seek past data and continue reading header. */
 					fseek (psf->file, psf->datalength, SEEK_CUR) ;
+
 					dword = ftell (psf->file) ;
-					if (dword != (off_t) (psf->dataoffset + psf->datalength))
-						psf_sprintf (psf, "*** fseek past end error ***\n", dword, psf->dataoffset + psf->datalength) ;
+					if (dword != (long) (psf->dataoffset + psf->datalength))
+						psf_log_printf (psf, "*** fseek past end error ***\n", dword, psf->dataoffset + psf->datalength) ;
 					break ;
 
 			case fact_MARKER :
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-					dword = LE2H_INT (dword) ;
-					fread (&fact_chunk, sizeof (fact_chunk), 1, psf->file) ;
+					if ((parsestage & (HAVE_RIFF | HAVE_WAVE | HAVE_fmt)) != (HAVE_RIFF | HAVE_WAVE | HAVE_fmt))
+						return SFE_WAV_BAD_FACT ;
+
+					psf_binheader_readf (psf, "ll", &dword, &(fact_chunk.samples)) ;
+					
 					if (dword > sizeof (fact_chunk))
-						fseek (psf->file, (int) (dword - sizeof (fact_chunk)), SEEK_CUR) ;
-					fact_chunk.samples = LE2H_INT (fact_chunk.samples) ;
-					psf_sprintf (psf, "%D : %d\n", marker, dword) ;
-					psf_sprintf (psf, "  samples : %d\n", fact_chunk.samples) ;
+						psf_binheader_readf (psf, "j", (int) (dword - sizeof (fact_chunk))) ;
+
+					psf_log_printf (psf, "%D : %d\n", marker, dword) ;
+					psf_log_printf (psf, "  samples : %d\n", fact_chunk.samples) ;
+					parsestage |= HAVE_fact ;
 					break ;
 
-			case cue_MARKER :
-			case LIST_MARKER :
+			case PEAK_MARKER :
+					if ((parsestage & (HAVE_RIFF | HAVE_WAVE | HAVE_fmt)) != (HAVE_RIFF | HAVE_WAVE | HAVE_fmt))
+						return SFE_WAV_PEAK_B4_FMT ;
+
+					psf_binheader_readf (psf, "l", &dword) ;
+					
+					psf_log_printf (psf, "%D : %d\n", marker, dword) ;
+					if (dword > sizeof (psf->peak))
+					{	psf_binheader_readf (psf, "j", dword) ;
+						psf_log_printf (psf, "*** File PEAK chunk bigger than sizeof (PEAK_CHUNK).\n") ;
+						return SFE_WAV_BAD_PEAK ;
+						} ;
+					if (dword != sizeof (psf->peak) - sizeof (psf->peak.peak) + psf->sf.channels * sizeof (PEAK_POS))
+					{	psf_binheader_readf (psf, "j", dword) ;
+						psf_log_printf (psf, "*** File PEAK chunk size doesn't fit with number of channels.\n") ;
+						return SFE_WAV_BAD_PEAK ;
+						} ;
+					
+					psf_binheader_readf (psf, "ll", &(psf->peak.version), &(psf->peak.timestamp)) ;
+
+					if (psf->peak.version != 1)
+						psf_log_printf (psf, "  version    : %d *** (should be version 1)\n", psf->peak.version) ;
+					else
+						psf_log_printf (psf, "  version    : %d\n", psf->peak.version) ;
+						
+					psf_log_printf (psf, "  time stamp : %d\n", psf->peak.timestamp) ;
+					psf_log_printf (psf, "    Ch   Position       Value\n") ;
+
+					cptr = (char *) psf->buffer ;
+					for (dword = 0 ; dword < psf->sf.channels ; dword++)
+					{	psf_binheader_readf (psf, "fl", &(psf->peak.peak[dword].value), 
+														&(psf->peak.peak[dword].position)) ;
+					
+						snprintf (cptr, sizeof (psf->buffer), "    %2d   %-12d   %g\n", 
+								dword, psf->peak.peak[dword].position, psf->peak.peak[dword].value) ;
+						cptr [sizeof (psf->buffer) - 1] = 0 ;
+						psf_log_printf (psf, cptr) ;
+						};
+
+					psf->has_peak = SF_TRUE ;
+					break ;
+
 			case INFO_MARKER :
-			case smpl_MARKER :
+			case LIST_MARKER :
+					psf_log_printf (psf, "%D\n", marker) ;
+					if ((error = wav_subchunk_parse (psf, marker)))
+						return error ;
+					break ;
+			
 			case bext_MARKER :
-			case MEXT_MARKER :
+			case cue_MARKER :
 			case DISP_MARKER :
-					fread (&dword, sizeof (dword), 1, psf->file) ;
-					dword = LE2H_INT (dword) ;
-					psf_sprintf (psf, "%D : %d\n", marker, dword) ;
-					fseek (psf->file, (int) dword, SEEK_CUR) ;
+			case MEXT_MARKER :
+					psf_binheader_readf (psf, "l", &dword);
+					psf_log_printf (psf, "%D : %d\n", marker, dword) ;
+					dword += (dword & 1) ;
+					psf_binheader_readf (psf, "j", dword) ;
 					break ;
 
+			case smpl_MARKER :
+			case acid_MARKER :
+			case PAD_MARKER :
+					psf_binheader_readf (psf, "l", &dword);
+					psf_log_printf (psf, " *** %D : %d\n", marker, dword) ;
+					dword += (dword & 1) ;
+					psf_binheader_readf (psf, "j", dword) ;
+					break ;
+
+
 			default : 
 					if (isprint ((marker >> 24) & 0xFF) && isprint ((marker >> 16) & 0xFF)
 						&& isprint ((marker >> 8) & 0xFF) && isprint (marker & 0xFF))
-					{	fread (&dword, sizeof (dword), 1, psf->file) ;
-						psf_sprintf (psf, "%D : %d (unknown marker)\n", marker, dword) ;
-						fseek (psf->file, (int) dword, SEEK_CUR) ;
+					{	psf_binheader_readf (psf, "l", &dword);
+						psf_log_printf (psf, "*** %D : %d (unknown marker)\n", marker, dword) ;
+
+						psf_binheader_readf (psf, "j", dword);
 						break ;
 						} ;
-					if ((dword = ftell (psf->file)) & 0x03)
-					{	psf_sprintf (psf, "  Unknown chunk marker at position %d. Resynching.\n", dword - 4) ;
-						fseek (psf->file, -3, SEEK_CUR) ;
+					if (ftell (psf->file) & 0x03)
+					{	psf_log_printf (psf, "  Unknown chunk marker at position %d. Resynching.\n", dword - 4) ;
+						psf_binheader_readf (psf, "j", -3) ;
 						break ;
 						} ;
-					psf_sprintf (psf, "*** Unknown chunk marker : %X. Exiting parser.\n", marker) ;
+					psf_log_printf (psf, "*** Unknown chunk marker : %X. Exiting parser.\n", marker) ;
 					break ;
 			} ;	/* switch (dword) */
 
+		if (! psf->sf.seekable && (parsestage & HAVE_data))
+			break ;
+
 		if (ferror (psf->file))
-		{	psf_sprintf (psf, "*** Error on file handle. ***\n", marker) ;
+		{	psf_log_printf (psf, "*** Error on file handle. ***\n", marker) ;
 			clearerr (psf->file) ;
 			break ;
 			} ;
@@ -284,94 +382,22 @@
 	switch (format)
 	{	case 	WAVE_FORMAT_PCM :
 		case	WAVE_FORMAT_EXTENSIBLE :
-					break ;
-					
-		case	WAVE_FORMAT_MULAW :
-					psf->sf.format   = (SF_FORMAT_WAV | SF_FORMAT_ULAW) ;
-					psf->read_short  = (func_short)  ulaw_read_ulaw2s ;
-					psf->read_int    = (func_int)    ulaw_read_ulaw2i ;
-					psf->read_double = (func_double) ulaw_read_ulaw2d ;
-					return 0 ;
+					psf->sf.format = (SF_FORMAT_WAV | SF_FORMAT_PCM) ;
+					if (psf->bytewidth == 1)
+						psf->chars = SF_CHARS_UNSIGNED ;
 	
-		case	WAVE_FORMAT_ALAW :
-					psf->sf.format   = (SF_FORMAT_WAV | SF_FORMAT_ALAW) ;
-					psf->read_short  = (func_short)  alaw_read_alaw2s ;
-					psf->read_int    = (func_int)    alaw_read_alaw2i ;
-					psf->read_double = (func_double) alaw_read_alaw2d ;
-					return 0 ;
-		
-		case	WAVE_FORMAT_MS_ADPCM : 
-					psf->sf.format   = (SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM) ;
-					if ((error = msadpcm_reader_init (psf, &wav_fmt)))
+					if ((error = pcm_read_init (psf)))
 						return error ;
-					psf->read_short  = (func_short)  msadpcm_read_s ;
-					psf->read_int    = (func_int)    msadpcm_read_i ;
-					psf->read_double = (func_double) msadpcm_read_d ;
-					psf->seek_func   = (func_seek)   msadpcm_seek ;
 					return 0 ;
-
-		case	WAVE_FORMAT_IMA_ADPCM :
-					psf->sf.format   = (SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM) ;
-					if ((error = wav_ima_reader_init (psf, &wav_fmt)))
-						return error ;
-					psf->read_short  = (func_short)  ima_read_s ;
-					psf->read_int    = (func_int)    ima_read_i ;
-					psf->read_double = (func_double) ima_read_d ;
-					psf->seek_func   = (func_seek)   ima_seek ;
-					return 0 ;
-		
-		case	WAVE_FORMAT_GSM610 :
-					psf->sf.format   = (SF_FORMAT_WAV | SF_FORMAT_GSM610) ;
-					if ((error = wav_gsm610_reader_init (psf, &wav_fmt)))
-						return error ;
-					psf->read_short  = (func_short)  wav_gsm610_read_s ;
-					psf->read_int    = (func_int)    wav_gsm610_read_i ;
-					psf->read_double = (func_double) wav_gsm610_read_d ;
-					psf->seek_func   = NULL ;  /* Not seekable */
-					return 0 ;
-		
+					
 		case	WAVE_FORMAT_IEEE_FLOAT :
 					psf->sf.format   = (SF_FORMAT_WAV | SF_FORMAT_FLOAT) ;
-					if (CAN_READ_WRITE_x86_IEEE)
-					{	psf->read_short  = (func_short)  pcm_read_f2s ;
-						psf->read_int    = (func_int)    pcm_read_f2i ;
-						psf->read_double = (func_double) pcm_read_f2d ;
-						}
-					else 
-					{	psf->read_short  = (func_short)  wav_read_x86f2s ;
-						psf->read_int    = (func_int)    wav_read_x86f2i ;
-						psf->read_double = (func_double) wav_read_x86f2d ;
-						} ;
+					float32_read_init (psf) ;
 					return 0 ;
 		
 		default :	return SFE_UNIMPLEMENTED ;
 		} ;
 
-	psf->sf.format = (SF_FORMAT_WAV | SF_FORMAT_PCM) ;
-	switch (psf->bytewidth)
-	{	case  1 :
-				psf->read_short  = (func_short)  pcm_read_uc2s ;
-				psf->read_int    = (func_int)    pcm_read_uc2i ;
-				psf->read_double = (func_double) pcm_read_uc2d ;
-				break ;
-		case  2 :
-				psf->read_short  = (func_short)  pcm_read_les2s ;
-				psf->read_int    = (func_int)    pcm_read_les2i ;
-				psf->read_double = (func_double) pcm_read_les2d ;
-				break ;
-		case  3 :
-				psf->read_short  = (func_short)  pcm_read_let2s ;
-				psf->read_int    = (func_int)    pcm_read_let2i ;
-				psf->read_double = (func_double) pcm_read_let2d ;
-				break ;
-		case  4 :
-				psf->read_short  = (func_short)  pcm_read_lei2s ;
-				psf->read_int    = (func_int)    pcm_read_lei2i ;
-				psf->read_double = (func_double) pcm_read_lei2d ;
-				break ;
-		default : return SFE_UNIMPLEMENTED ;
-		} ;
-
 	return 0 ;
 } /* wav_open_read */
 
@@ -378,9 +404,9 @@
 /*------------------------------------------------------------------------------
  */
 
-int 	wav_open_write	(SF_PRIVATE *psf)
-{	WAV_FMT			wav_fmt ;
-	unsigned int	dword, subformat ;
+int
+wav_open_write	(SF_PRIVATE *psf)
+{	unsigned int	subformat ;
 	int				error ;
 	
 	if ((psf->sf.format & SF_FORMAT_TYPEMASK) != SF_FORMAT_WAV)
@@ -398,207 +424,18 @@
 
 	psf->blockwidth  = psf->bytewidth * psf->sf.channels ;
 
-	wav_fmt.min.channels    = psf->sf.channels ;
-	wav_fmt.min.samplerate  = psf->sf.samplerate ;
-	wav_fmt.min.bytespersec = psf->sf.samplerate * psf->bytewidth * psf->sf.channels ;
-	wav_fmt.min.blockalign  = psf->bytewidth * psf->sf.channels ;
-	wav_fmt.min.bitwidth    = psf->sf.pcmbitwidth ;
+	/* Set sample count artifically high and fix later. */ 
+	psf->sf.samples = 0x7FFFFFFF / psf->blockwidth ; 
+	psf->datalength = psf->blockwidth * psf->sf.samples ;
+	psf->filelength = 0x7FFFFFFF ;
 
+	/* Set standard wav_close and write_header now, may be overridden in wav_write_header. */
+	psf->close        = (func_close)  wav_close ;
+	psf->write_header = (func_wr_hdr) wav_write_header ;
 
-	switch (psf->sf.format & SF_FORMAT_SUBMASK)
-	{	case	SF_FORMAT_PCM : 
-					wav_fmt.format = WAVE_FORMAT_PCM ;
+	if ((error = wav_write_header (psf)))
+		return error ;
 
-					psf->dataoffset  = 7 * sizeof (dword) + sizeof (MIN_WAV_FMT) ;
-					psf->datalength  = psf->blockwidth * psf->sf.samples ;
-					psf->filelength  = psf->datalength + psf->dataoffset ;
-
-					write_header (psf, &wav_fmt, sizeof (MIN_WAV_FMT), 0) ;
-					break ;
-
-		case	SF_FORMAT_FLOAT : 
-					wav_fmt.format = WAVE_FORMAT_IEEE_FLOAT ;
-
-					psf->dataoffset  = 9 * sizeof (dword) + sizeof (MIN_WAV_FMT) + sizeof (FACT_CHUNK) ;
-					psf->datalength  = psf->blockwidth * psf->sf.samples ;
-					psf->filelength  = psf->datalength + psf->dataoffset ;
-
-					write_header (psf, &wav_fmt, sizeof (MIN_WAV_FMT), 1) ;
-					break ;
-
-		case	SF_FORMAT_ULAW : 
-					wav_fmt.format = WAVE_FORMAT_MULAW ;
-
-					wav_fmt.size20.bitwidth = 8 ;
-					wav_fmt.size20.extrabytes = 2 ;
-					wav_fmt.size20.dummy = 0 ;
-
-					psf->dataoffset  = 9 * sizeof (dword) + sizeof (WAV_FMT_SIZE20) + sizeof (FACT_CHUNK) ;
-					
-					psf->datalength  = psf->blockwidth * psf->sf.samples ;
-					psf->filelength  = psf->datalength + psf->dataoffset ;
-
-					write_header (psf, &wav_fmt, sizeof (WAV_FMT_SIZE20), 1) ;
-					break ;
-					
-		case	SF_FORMAT_ALAW :
-					wav_fmt.format = WAVE_FORMAT_ALAW ;
-
-					wav_fmt.size20.bitwidth = 8 ;
-					wav_fmt.size20.extrabytes = 2 ;
-					wav_fmt.size20.dummy = 0 ;
-
-					psf->dataoffset  = 9 * sizeof (dword) + sizeof (WAV_FMT_SIZE20) + sizeof (FACT_CHUNK) ;
-					
-					psf->datalength  = psf->blockwidth * psf->sf.samples ;
-					psf->filelength  = psf->datalength + psf->dataoffset ;
-
-					write_header (psf, &wav_fmt, sizeof (WAV_FMT_SIZE20), 1) ;
-					break ;
-
-		case	SF_FORMAT_IMA_ADPCM : 
-					wav_fmt.format = WAVE_FORMAT_IMA_ADPCM ;
-					if ((error = wav_ima_writer_init (psf, &wav_fmt)))
-						return error ;
-
-					psf->dataoffset  = 9 * sizeof (dword) + sizeof (IMA_ADPCM_WAV_FMT) + sizeof (FACT_CHUNK) ;
-					if (psf->sf.samples % wav_fmt.ima.samplesperblock)
-						psf->datalength  = ((psf->sf.samples / wav_fmt.ima.samplesperblock) + 1) * wav_fmt.ima.samplesperblock ;
-					else
-						psf->datalength  = psf->sf.samples ;
-					psf->filelength  = psf->datalength + psf->dataoffset ;
-
-					write_header (psf, &wav_fmt, sizeof (IMA_ADPCM_WAV_FMT), 1) ;
-					break ;
-
-		case	SF_FORMAT_MS_ADPCM : 
-					wav_fmt.format = WAVE_FORMAT_MS_ADPCM ;
-					msadpcm_writer_init (psf, &wav_fmt) ;
-
-					psf->dataoffset  = 9 * sizeof (dword) + sizeof (MS_ADPCM_WAV_FMT) + sizeof (FACT_CHUNK) ;
-					if (psf->sf.samples % wav_fmt.msadpcm.samplesperblock)
-						psf->datalength  = ((psf->sf.samples / wav_fmt.msadpcm.samplesperblock) + 1) * wav_fmt.msadpcm.samplesperblock ;
-					else
-						psf->datalength  = psf->sf.samples ;
-					psf->filelength  = psf->datalength + psf->dataoffset ;
-
-					write_header (psf, &wav_fmt, sizeof (MS_ADPCM_WAV_FMT), 1) ;
-					break ;
-
-		case	SF_FORMAT_GSM610 : 
-					wav_fmt.format = WAVE_FORMAT_GSM610 ;
-					wav_gsm610_writer_init (psf, &wav_fmt) ;
-
-					psf->dataoffset  = 9 * sizeof (dword) + sizeof (GSM610_WAV_FMT) + sizeof (FACT_CHUNK) ;
-					if (psf->sf.samples % wav_fmt.gsm610.samplesperblock)
-						psf->datalength  = ((psf->sf.samples / wav_fmt.gsm610.samplesperblock) + 1) * wav_fmt.gsm610.samplesperblock ;
-					else
-						psf->datalength  = psf->sf.samples ;
-					psf->filelength  = psf->datalength + psf->dataoffset ;
-
-					write_header (psf, &wav_fmt, sizeof (GSM610_WAV_FMT), 1) ;
-					break ;
-
-		default : 	return SFE_UNIMPLEMENTED ;
-		} ;
-
-
-	dword = data_MARKER ;
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
-
-	dword = H2LE_INT (psf->datalength) ;
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
-	
-	psf->close = (func_close) wav_close ;
-
-	if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_FLOAT)
-	{	psf->sf.format = (SF_FORMAT_WAV | SF_FORMAT_FLOAT) ;
-		if (CAN_READ_WRITE_x86_IEEE)
-		{	psf->write_short  = (func_short)  pcm_write_s2f ;
-			psf->write_int    = (func_int)    pcm_write_i2f ;
-			psf->write_double = (func_double) pcm_write_d2f ;
-			}
-		else 
-		{	psf->write_short  = (func_short)  wav_write_s2x86f ;
-			psf->write_int    = (func_int)    wav_write_i2x86f ;
-			psf->write_double = (func_double) wav_write_d2x86f ;
-			} ;
-		return	 0 ;
-		} ;
-	
-	if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_IMA_ADPCM)
-	{	psf->sf.format    = (SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM) ;
-		psf->write_short  = (func_short)  ima_write_s ;
-		psf->write_int    = (func_int)    ima_write_i ;
-		psf->write_double = (func_double) ima_write_d ;
-		psf->seek_func    = (func_seek)   ima_seek ;
-		psf->close        = (func_close)  wav_ima_close ;
-		return 0 ;
-		} ;
-
-	if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_MS_ADPCM)
-	{	psf->sf.format    = (SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM) ;
-		psf->write_short  = (func_short)  msadpcm_write_s ;
-		psf->write_int    = (func_int)    msadpcm_write_i ;
-		psf->write_double = (func_double) msadpcm_write_d ;
-		psf->seek_func    = (func_seek)   msadpcm_seek ;
-		psf->close        = (func_close)  msadpcm_close ;
-		return 0 ;
-		} ;
-
-	if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_GSM610)
-	{	psf->sf.format    = (SF_FORMAT_WAV | SF_FORMAT_GSM610) ;
-		psf->write_short  = (func_short)  wav_gsm610_write_s ;
-		psf->write_int    = (func_int)    wav_gsm610_write_i ;
-		psf->write_double = (func_double) wav_gsm610_write_d ;
-		psf->seek_func    = NULL ; /* Not seekable */
-		psf->close        = (func_close)  wav_gsm610_close ;
-		return 0 ;
-		} ;
-
-	if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_ULAW)
-	{	psf->sf.format    = (SF_FORMAT_WAV | SF_FORMAT_ULAW) ;
-		psf->write_short  = (func_short)  ulaw_write_s2ulaw ;
-		psf->write_int    = (func_int)    ulaw_write_i2ulaw ;
-		psf->write_double = (func_double) ulaw_write_d2ulaw ;
-		return 0 ;
-		} ;
-
-	if ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_ALAW)
-	{	psf->sf.format    = (SF_FORMAT_WAV | SF_FORMAT_ALAW) ;
-		psf->write_short  = (func_short)  alaw_write_s2alaw ;
-		psf->write_int    = (func_int)    alaw_write_i2alaw ;
-		psf->write_double = (func_double) alaw_write_d2alaw ;
-		return 0 ;
-		} ;
-
-	if ((psf->sf.format & SF_FORMAT_SUBMASK) != SF_FORMAT_PCM)
-		return SFE_UNIMPLEMENTED ;
-
-	switch (psf->bytewidth)
-	{	case  1 :
-				psf->write_short  = (func_short)  pcm_write_s2uc ;
-				psf->write_int    = (func_int)    pcm_write_i2uc ;
-				psf->write_double = (func_double) pcm_write_d2uc ;
-				break ;
-		case  2 :
-				psf->write_short  = (func_short)  pcm_write_s2les ;
-				psf->write_int    = (func_int)    pcm_write_i2les ;
-				psf->write_double = (func_double) pcm_write_d2les ;
-				break ;
-		case  3 :
-				psf->write_short  = (func_short)  pcm_write_s2let ;
-				psf->write_int    = (func_int)    pcm_write_i2let ;
-				psf->write_double = (func_double) pcm_write_d2let ;
-				break ;
-		case  4 :
-				psf->write_short  = (func_short)  pcm_write_s2lei ;
-				psf->write_int    = (func_int)    pcm_write_i2lei ;
-				psf->write_double = (func_double) pcm_write_d2lei ;
-				break ;
-		default : return SFE_UNIMPLEMENTED ;
-		} ;
-
 	return 0 ;
 } /* wav_open_write */
 
@@ -605,9 +442,9 @@
 /*------------------------------------------------------------------------------
  */
 
-int	wav_close	(SF_PRIVATE  *psf)
-{	unsigned int		dword ;
-
+static int	
+wav_close	(SF_PRIVATE  *psf)
+{	
 	if (psf->mode == SF_MODE_WRITE)
 	{	/*  Now we know for certain the length of the file we can
 		 *  re-write correct values for the RIFF and data chunks.
@@ -614,18 +451,17 @@
 		 */
 
 		fseek (psf->file, 0, SEEK_END) ;
-		psf->filelength = ftell (psf->file) ;
+		psf->tailstart = ftell (psf->file) ;
+		wav_write_tailer (psf) ;
 
-		/* Fix RIFF size. */
-		dword = H2LE_INT (psf->filelength - 2 * sizeof (dword)) ;
-		fseek (psf->file, sizeof (dword), SEEK_SET) ;
-		fwrite (&dword, sizeof (dword), 1, psf->file) ;
+		fseek (psf->file, 0, SEEK_END) ;
+		psf->filelength = ftell (psf->file) ;
+		fseek (psf->file, 0, SEEK_SET) ;
 		
-		psf->datalength = psf->filelength - psf->dataoffset ;
-		psf->sf.samples = psf->datalength / (psf->sf.channels * psf->bytewidth) ;
-		fseek (psf->file, (int) (psf->dataoffset - sizeof (dword)), SEEK_SET) ;
-		dword = H2LE_INT (psf->datalength) ;
-		fwrite (&dword, sizeof (dword), 1, psf->file) ;
+		psf->datalength = psf->filelength - psf->dataoffset - (psf->filelength - psf->tailstart) ;
+ 		psf->sf.samples = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
+
+		wav_write_header (psf) ;
 		} ;
 
 	if (psf->fdata)
@@ -635,40 +471,41 @@
 	return 0 ;
 } /* wav_close */
 
-
 /*=========================================================================
- * Private functions.
- */
+** Private functions.
+*/
 
-static
-int read_fmt_chunk (SF_PRIVATE *psf, WAV_FMT *wav_fmt)
-{	unsigned int	dword, bytesread, k, structsize, bytespersec = 0  ;
+static int
+read_fmt_chunk (SF_PRIVATE *psf, WAV_FMT *wav_fmt)
+{	unsigned int	bytesread, k, structsize, bytespersec = 0  ;
 	
 	memset (wav_fmt, 0, sizeof (WAV_FMT)) ;
-	bytesread = 0 ;
 
-	fread (&dword, sizeof (dword), 1, psf->file) ;
-	structsize = LE2H_INT (dword) ;
+	psf_binheader_readf (psf, "l", &structsize) ;
 	
-	psf_sprintf (psf, "fmt  : %d\n", structsize) ;
+	psf_log_printf (psf, "fmt  : %d\n", structsize) ;
 	
 	if (structsize < 16)
 		return SFE_WAV_FMT_SHORT ;
 	if (structsize > sizeof (WAV_FMT))
 		return SFE_WAV_FMT_TOO_BIG ;
-					
-	fread (wav_fmt, structsize, 1, psf->file) ;
-	bytesread += structsize ;
-	if (CPU_IS_BIG_ENDIAN)
-		le2h_wav_fmt (wav_fmt) ;
 
-	psf_sprintf (psf, "  Format        : 0x%X => %s\n", wav_fmt->format, wav_format_str (wav_fmt->format)) ;
-	psf_sprintf (psf, "  Channels      : %d\n", wav_fmt->min.channels) ;
-	psf_sprintf (psf, "  Sample Rate   : %d\n", wav_fmt->min.samplerate) ;
-	psf_sprintf (psf, "  Block Align   : %d\n", wav_fmt->min.blockalign) ;
-	psf_sprintf (psf, "  Bit Width     : %d\n", wav_fmt->min.bitwidth) ;
-	
+	/* Read the minimal WAV file header here. */	
+	bytesread =
+	psf_binheader_readf (psf, "wwllww", &(wav_fmt->format), &(wav_fmt->min.channels),
+			&(wav_fmt->min.samplerate), &(wav_fmt->min.bytespersec), 
+			&(wav_fmt->min.blockalign), &(wav_fmt->min.bitwidth))  ;
 
+	psf_log_printf (psf, "  Format        : 0x%X => %s\n", wav_fmt->format, wav_format_str (wav_fmt->format)) ;
+	psf_log_printf (psf, "  Channels      : %d\n", wav_fmt->min.channels) ;
+	psf_log_printf (psf, "  Sample Rate   : %d\n", wav_fmt->min.samplerate) ;
+	psf_log_printf (psf, "  Block Align   : %d\n", wav_fmt->min.blockalign) ;
+	
+	if (wav_fmt->format == WAVE_FORMAT_GSM610 && wav_fmt->min.bitwidth != 0)
+		psf_log_printf (psf, "  Bit Width     : %d (should be 0)\n", wav_fmt->min.bitwidth) ;
+	else
+		psf_log_printf (psf, "  Bit Width     : %d\n", wav_fmt->min.bitwidth) ;
+	
 	psf->sf.samplerate		= wav_fmt->min.samplerate ;
 	psf->sf.samples 		= 0 ;					/* Correct this when reading data chunk. */
 	psf->sf.channels		= wav_fmt->min.channels ;
@@ -678,247 +515,220 @@
 		case WAVE_FORMAT_IEEE_FLOAT :
 				bytespersec = wav_fmt->min.samplerate * wav_fmt->min.blockalign ;
 				if (wav_fmt->min.bytespersec != bytespersec)
-					psf_sprintf (psf, "  Bytes/sec     : %d (should be %d)\n", wav_fmt->min.bytespersec, bytespersec) ;
+					psf_log_printf (psf, "  Bytes/sec     : %d (should be %d)\n", wav_fmt->min.bytespersec, bytespersec) ;
 				else
-					psf_sprintf (psf, "  Bytes/sec     : %d\n", wav_fmt->min.bytespersec) ;
+					psf_log_printf (psf, "  Bytes/sec     : %d\n", wav_fmt->min.bytespersec) ;
 		
 				psf->sf.pcmbitwidth	= wav_fmt->min.bitwidth ;
 				psf->bytewidth      = BITWIDTH2BYTES (wav_fmt->min.bitwidth) ;
 				break ;
 
-		case WAVE_FORMAT_ALAW :
-		case WAVE_FORMAT_MULAW :
-				if (wav_fmt->min.bytespersec / wav_fmt->min.blockalign != wav_fmt->min.samplerate)
-					psf_sprintf (psf, "  Bytes/sec     : %d (should be %d)\n", wav_fmt->min.bytespersec, wav_fmt->min.samplerate * wav_fmt->min.blockalign) ;
+		case WAVE_FORMAT_EXTENSIBLE :
+				if (wav_fmt->ext.bytespersec / wav_fmt->ext.blockalign != wav_fmt->ext.samplerate)
+					psf_log_printf (psf, "  Bytes/sec     : %d (should be %d)\n", wav_fmt->ext.bytespersec, wav_fmt->ext.samplerate * wav_fmt->ext.blockalign) ;
 				else
-					psf_sprintf (psf, "  Bytes/sec     : %d\n", wav_fmt->min.bytespersec) ;
+					psf_log_printf (psf, "  Bytes/sec     : %d\n", wav_fmt->ext.bytespersec) ;
 
-				psf->sf.pcmbitwidth	= 16 ;
-				psf->bytewidth      = 1 ;
-				if (structsize >= 18)
-					psf_sprintf (psf, "  Extra Bytes   : %d\n", wav_fmt->size20.extrabytes) ;
-				break ;
+				bytesread += 
+				psf_binheader_readf (psf, "wwl", &(wav_fmt->ext.extrabytes), &(wav_fmt->ext.validbits),
+						&(wav_fmt->ext.channelmask)) ;
 
-		case WAVE_FORMAT_MS_ADPCM :
-				if (wav_fmt->msadpcm.bitwidth != 4)
-					return SFE_WAV_ADPCM_NOT4BIT ;
-				if (wav_fmt->msadpcm.channels < 1 || wav_fmt->msadpcm.channels > 2)
-					return SFE_WAV_ADPCM_CHANNELS ;
+				psf_log_printf (psf, "  Valid Bits    : %d\n", wav_fmt->ext.validbits) ;
+				psf_log_printf (psf, "  Channel Mask  : 0x%X\n", wav_fmt->ext.channelmask) ;
 
-				bytespersec = (wav_fmt->msadpcm.samplerate * wav_fmt->msadpcm.blockalign) / wav_fmt->msadpcm.samplesperblock ;
-				if (wav_fmt->min.bytespersec == bytespersec)
-					psf_sprintf (psf, "  Bytes/sec     : %d\n", wav_fmt->min.bytespersec) ;
-				else if (wav_fmt->min.bytespersec == (wav_fmt->msadpcm.samplerate / wav_fmt->msadpcm.samplesperblock) * wav_fmt->msadpcm.blockalign) 
-					psf_sprintf (psf, "  Bytes/sec     : %d (should be %d (MS BUG!))\n", wav_fmt->min.bytespersec, bytespersec) ;
-				else
-					psf_sprintf (psf, "  Bytes/sec     : %d (should be %d)\n", wav_fmt->min.bytespersec, bytespersec) ;
+				bytesread += 
+				psf_binheader_readf (psf, "lww", &(wav_fmt->ext.esf.esf_field1), &(wav_fmt->ext.esf.esf_field2),
+						&(wav_fmt->ext.esf.esf_field3)) ;
 
-				psf->sf.pcmbitwidth = 16 ;
-				psf->bytewidth      = 2 ;
-				psf_sprintf (psf, "  Extra Bytes   : %d\n", wav_fmt->msadpcm.extrabytes) ;
-				psf_sprintf (psf, "  Samples/Block : %d\n", wav_fmt->msadpcm.samplesperblock) ;
-				if (wav_fmt->msadpcm.numcoeffs > sizeof (MS_ADPCM_WAV_FMT) / sizeof (int))
-				{	psf_sprintf (psf, "  No. of Coeffs : %d ****\n", wav_fmt->msadpcm.numcoeffs) ;
-					wav_fmt->msadpcm.numcoeffs = sizeof (MS_ADPCM_WAV_FMT) / sizeof (int) ;
-					}
-				else
-					psf_sprintf (psf, "  No. of Coeffs : %d\n", wav_fmt->msadpcm.numcoeffs) ;
-				psf_sprintf (psf, "    Coeff 1 : ") ;
-				for (k = 0 ; k < wav_fmt->msadpcm.numcoeffs ; k++)
-					psf_sprintf (psf, "%d ", wav_fmt->msadpcm.coeffs [k].coeff1) ;
-				psf_sprintf (psf, "\n    Coeff 2 : ") ;
-				for (k = 0 ; k < wav_fmt->msadpcm.numcoeffs ; k++)
-					psf_sprintf (psf, "%d ", wav_fmt->msadpcm.coeffs [k].coeff2) ;
-				psf_sprintf (psf, "\n") ;
-				break ;
-				
-		case WAVE_FORMAT_IMA_ADPCM :
-				if (wav_fmt->ima.bitwidth != 4)
-					return SFE_WAV_ADPCM_NOT4BIT ;
-				if (wav_fmt->ima.channels < 1 || wav_fmt->ima.channels > 2)
-					return SFE_WAV_ADPCM_CHANNELS ;
-
-				bytespersec = (wav_fmt->ima.samplerate * wav_fmt->ima.blockalign) / wav_fmt->ima.samplesperblock ;
-				if (wav_fmt->ima.bytespersec != bytespersec)
-					psf_sprintf (psf, "  Bytes/sec     : %d (should be %d)\n", wav_fmt->ima.bytespersec, bytespersec) ;
-				else
-					psf_sprintf (psf, "  Bytes/sec     : %d\n", wav_fmt->ima.bytespersec) ;
-
-				psf->sf.pcmbitwidth = 16 ;
-				psf->bytewidth      = 2 ;
-				psf_sprintf (psf, "  Extra Bytes   : %d\n", wav_fmt->ima.extrabytes) ;
-				psf_sprintf (psf, "  Samples/Block : %d\n", wav_fmt->ima.samplesperblock) ;
-				break ;
-				
-		case WAVE_FORMAT_EXTENSIBLE :
-				if (wav_fmt->ext.bytespersec / wav_fmt->ext.blockalign != wav_fmt->ext.samplerate)
-					psf_sprintf (psf, "  Bytes/sec     : %d (should be %d)\n", wav_fmt->ext.bytespersec, wav_fmt->ext.samplerate * wav_fmt->ext.blockalign) ;
-				else
-					psf_sprintf (psf, "  Bytes/sec     : %d\n", wav_fmt->ext.bytespersec) ;
-
-				psf_sprintf (psf, "  Valid Bits    : %d\n", wav_fmt->ext.validbits) ;
-				psf_sprintf (psf, "  Channel Mask  : 0x%X\n", wav_fmt->ext.channelmask) ;
-				psf_sprintf (psf, "  Subformat\n") ;
-				psf_sprintf (psf, "    esf_field1 : 0x%X\n", wav_fmt->ext.esf.esf_field1) ;
-				psf_sprintf (psf, "    esf_field2 : 0x%X\n", wav_fmt->ext.esf.esf_field2) ;
-				psf_sprintf (psf, "    esf_field3 : 0x%X\n", wav_fmt->ext.esf.esf_field3) ;
-				psf_sprintf (psf, "    esf_field4 : ") ;
+				psf_log_printf (psf, "  Subformat\n") ;
+				psf_log_printf (psf, "    esf_field1 : 0x%X\n", wav_fmt->ext.esf.esf_field1) ;
+				psf_log_printf (psf, "    esf_field2 : 0x%X\n", wav_fmt->ext.esf.esf_field2) ;
+				psf_log_printf (psf, "    esf_field3 : 0x%X\n", wav_fmt->ext.esf.esf_field3) ;
+				psf_log_printf (psf, "    esf_field4 : ") ;
 				for (k = 0 ; k < 8 ; k++)
-					psf_sprintf (psf, "0x%X ", wav_fmt->ext.esf.esf_field4 [k] & 0xFF) ;
-				psf_sprintf (psf, "\n") ;
+				{	bytesread += psf_binheader_readf (psf, "b", &(wav_fmt->ext.esf.esf_field4 [k])) ;
+					psf_log_printf (psf, "0x%X ", wav_fmt->ext.esf.esf_field4 [k] & 0xFF) ;
+					} ;
+				psf_log_printf (psf, "\n") ;
 				psf->sf.pcmbitwidth = wav_fmt->ext.bitwidth ;
 				psf->bytewidth      = BITWIDTH2BYTES (wav_fmt->ext.bitwidth) ;
 				break ;
 
-		case WAVE_FORMAT_GSM610 :
-				if (wav_fmt->gsm610.channels != 1 || wav_fmt->gsm610.blockalign != 65)
-					return SFE_WAV_GSM610_FORMAT ;
-
-				if (wav_fmt->gsm610.samplesperblock != 320)
-					return SFE_WAV_GSM610_FORMAT ;
-
-				bytespersec = (wav_fmt->gsm610.samplerate * wav_fmt->gsm610.blockalign) / wav_fmt->gsm610.samplesperblock ;
-				if (wav_fmt->gsm610.bytespersec != bytespersec)
-					psf_sprintf (psf, "  Bytes/sec     : %d (should be %d)\n", wav_fmt->gsm610.bytespersec, bytespersec) ;
-				else
-					psf_sprintf (psf, "  Bytes/sec     : %d\n", wav_fmt->gsm610.bytespersec) ;
-
-				psf->sf.pcmbitwidth = 16 ;
-				psf->bytewidth      = 2 ;
-				psf_sprintf (psf, "  Extra Bytes   : %d\n", wav_fmt->gsm610.extrabytes) ;
-				psf_sprintf (psf, "  Samples/Block : %d\n", wav_fmt->gsm610.samplesperblock) ;
-				break ;
 		default : break ;
 		} ;
-	
+
+	if (bytesread > structsize)	
+	{	psf_log_printf (psf, "*** read_fmt_chunk (bytesread > structsize)\n") ;
+		return SFE_WAV_FMT_SHORT ;
+		}
+	else
+		fread (psf->buffer, 1, structsize - bytesread, psf->file) ;
+
 	psf->blockwidth = wav_fmt->min.channels * psf->bytewidth ;
 
 	return 0 ;
 } /* read_fmt_chunk */
 
-static
-int write_header (SF_PRIVATE *psf, WAV_FMT *wav_fmt, unsigned int size, int do_fact)
-{	FACT_CHUNK		fact_chunk ;
-	unsigned int dword, RIFFsize ;
+static int 
+wav_write_header (SF_PRIVATE *psf)
+{	unsigned int 	fmt_size ;
+	int 			k, error, subformat ;
+	
+	/* Reset the current header length to zero. */
+	psf->header [0] = 0 ;
+	psf->headindex = 0 ;
+	fseek (psf->file, 0, SEEK_SET) ;
 
-	RIFFsize   = psf->filelength - 2 * sizeof (dword) ;
+	/* RIFF marker, length, WAVE and 'fmt ' markers. */		
+	psf_binheader_writef (psf, "mlmm", RIFF_MARKER, psf->filelength - 8, WAVE_MARKER, fmt_MARKER) ;
 
-	dword = RIFF_MARKER ;
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
-	dword = H2LE_INT (RIFFsize) ;
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
+	subformat = psf->sf.format & SF_FORMAT_SUBMASK ;
+
+	switch (subformat)
+	{	case	SF_FORMAT_PCM : 
+					psf->sf.format = (SF_FORMAT_WAV | SF_FORMAT_PCM) ;
+
+					if (psf->bytewidth == 1)
+						psf->chars = SF_CHARS_UNSIGNED ;
 	
-	dword = WAVE_MARKER ;
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
-	dword = fmt_MARKER ;
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
-	
-	dword = H2LE_INT (size) ;
-	fwrite (&dword, sizeof (dword), 1, psf->file) ;
-	if (CPU_IS_BIG_ENDIAN)
-		h2le_wav_fmt (wav_fmt) ;	
-	fwrite (wav_fmt, size, 1, psf->file) ;
-	
-	if (do_fact)
-	{	dword = fact_MARKER ;
-		fwrite (&dword, sizeof (dword), 1, psf->file) ;
-		dword = H2LE_INT (sizeof (FACT_CHUNK)) ;
-		fwrite (&dword, sizeof (dword), 1, psf->file) ;
-		fact_chunk.samples = H2LE_INT (psf->sf.samples) ;
-		fwrite (&fact_chunk, sizeof (fact_chunk), 1, psf->file) ;
+					if ((error = pcm_write_init (psf)))
+						return error ;
+		
+					fmt_size = 2 + 2 + 4 + 4 + 2 + 2 ;
+
+					/* fmt : format, channels, samplerate */
+					psf_binheader_writef (psf, "lwwl", fmt_size, WAVE_FORMAT_PCM, psf->sf.channels, psf->sf.samplerate) ;
+					/*  fmt : bytespersec */
+					psf_binheader_writef (psf, "l", psf->sf.samplerate * psf->bytewidth * psf->sf.channels) ;
+					/*  fmt : blockalign, bitwidth */
+					psf_binheader_writef (psf, "ww", psf->bytewidth * psf->sf.channels, psf->sf.pcmbitwidth) ;
+					break ;
+
+		case	SF_FORMAT_FLOAT : 
+					psf->sf.format = (SF_FORMAT_WAV | SF_FORMAT_FLOAT) ;
+
+					/* Add the peak chunk to floating point files. */					
+					psf->has_peak = SF_TRUE ;
+					psf->peak_loc = SF_PEAK_START ;
+					float32_write_init (psf) ;
+					
+					fmt_size = 2 + 2 + 4 + 4 + 2 + 2 ;
+
+					/* fmt : format, channels, samplerate */
+					psf_binheader_writef (psf, "lwwl", fmt_size, WAVE_FORMAT_IEEE_FLOAT, psf->sf.channels, psf->sf.samplerate) ;
+					/*  fmt : bytespersec */
+					psf_binheader_writef (psf, "l", psf->sf.samplerate * psf->bytewidth * psf->sf.channels) ;
+					/*  fmt : blockalign, bitwidth */
+					psf_binheader_writef (psf, "ww", psf->bytewidth * psf->sf.channels, psf->sf.pcmbitwidth) ;
+
+					/* Write 'fact' chunk. */
+					psf_binheader_writef (psf, "mll", fact_MARKER, FACT_CHUNK_SIZE, psf->sf.samples) ;
+					break ;
+
+		default : 	return SFE_UNIMPLEMENTED ;
 		} ;
 
+	if (psf->has_peak && psf->peak_loc == SF_PEAK_START)
+	{	psf_binheader_writef (psf, "ml", PEAK_MARKER, 
+			sizeof (psf->peak) - sizeof (psf->peak.peak) + psf->sf.channels * sizeof (PEAK_POS)) ;
+		psf_binheader_writef (psf, "ll", 1, time (NULL)) ;
+		for (k = 0 ; k < psf->sf.channels ; k++)
+			psf_binheader_writef (psf, "fl", psf->peak.peak[k].value, psf->peak.peak[k].position) ;
+		} ;
+
+	psf_binheader_writef (psf, "ml", data_MARKER, psf->datalength) ;
+	fwrite (psf->header, psf->headindex, 1, psf->file) ;
+
+	psf->dataoffset = psf->headindex ;
+
 	return 0 ;
-} /* write_header */
+} /* wav_write_header */
 
-static 
-void	le2h_wav_fmt (WAV_FMT *fmt)
+static int 
+wav_write_tailer (SF_PRIVATE *psf)
 {	int		k ;
 
-	fmt->min.format      = ENDSWAP_SHORT (fmt->min.format) ;
-	fmt->min.channels    = ENDSWAP_SHORT (fmt->min.channels) ;
-	fmt->min.samplerate  = ENDSWAP_INT   (fmt->min.samplerate) ;
-	fmt->min.bytespersec = ENDSWAP_INT   (fmt->min.bytespersec) ;
-	fmt->min.blockalign  = ENDSWAP_SHORT (fmt->min.blockalign) ;
-	fmt->min.bitwidth    = ENDSWAP_SHORT (fmt->min.bitwidth) ;
+	/* Reset the current header buffer length to zero. */
+	psf->header [0] = 0 ;
+	psf->headindex = 0 ;
+	fseek (psf->file, 0, SEEK_END) ;
 
-	switch (fmt->format)
-	{	case WAVE_FORMAT_MS_ADPCM :	
-				fmt->msadpcm.extrabytes      = ENDSWAP_SHORT (fmt->msadpcm.extrabytes) ;
-				fmt->msadpcm.samplesperblock = ENDSWAP_SHORT (fmt->msadpcm.samplesperblock) ;
-				fmt->msadpcm.numcoeffs       = ENDSWAP_SHORT (fmt->msadpcm.numcoeffs) ;
-				for (k = 0 ; k < fmt->msadpcm.numcoeffs  ; k++)
-				{	fmt->msadpcm.coeffs [k].coeff1 = ENDSWAP_SHORT (fmt->msadpcm.coeffs [k].coeff1) ;
-					fmt->msadpcm.coeffs [k].coeff2 = ENDSWAP_SHORT (fmt->msadpcm.coeffs [k].coeff2) ;
-					} ;
-				break ;
-				
-		case WAVE_FORMAT_IMA_ADPCM :	
-				fmt->ima.extrabytes      = ENDSWAP_SHORT (fmt->ima.extrabytes) ;
-				fmt->ima.samplesperblock = ENDSWAP_SHORT (fmt->ima.samplesperblock) ;
-				break ;
-				
-		case WAVE_FORMAT_ALAW :	
-		case WAVE_FORMAT_MULAW :	
-				fmt->size20.extrabytes = ENDSWAP_SHORT (fmt->size20.extrabytes) ;
-				fmt->size20.dummy      = ENDSWAP_SHORT (fmt->size20.dummy) ;
-				break ;
-				
-		case	WAVE_FORMAT_GSM610 :
-				fmt->gsm610.extrabytes      = ENDSWAP_SHORT (fmt->gsm610.extrabytes) ;
-				fmt->gsm610.samplesperblock = ENDSWAP_SHORT (fmt->gsm610.samplesperblock) ;
-				break ;
-				
-		default : break ;
+	if (psf->has_peak && psf->peak_loc == SF_PEAK_END)
+	{	psf_binheader_writef (psf, "ml", PEAK_MARKER, 
+			sizeof (psf->peak) - sizeof (psf->peak.peak) + psf->sf.channels * sizeof (PEAK_POS)) ;
+		psf_binheader_writef (psf, "ll", 1, time (NULL)) ;
+		for (k = 0 ; k < psf->sf.channels ; k++)
+			psf_binheader_writef (psf, "fl", psf->peak.peak[k].value, psf->peak.peak[k].position) ; /* XXXXX */
 		} ;
 
-} /* le2h_wav_fmt */
+	if (psf->headindex > 0)
+		fwrite (psf->header, psf->headindex, 1, psf->file) ;
 
-static 
-void	h2le_wav_fmt (WAV_FMT *fmt)
-{	int		k ;
+	return 0 ;
+} /* wav_write_tailer */
 
-	switch (fmt->format)
-	{	case WAVE_FORMAT_MS_ADPCM :	
-				for (k = 0 ; k < fmt->msadpcm.numcoeffs  ; k++)
-				{	fmt->msadpcm.coeffs [k].coeff1 = ENDSWAP_SHORT (fmt->msadpcm.coeffs [k].coeff1) ;
-					fmt->msadpcm.coeffs [k].coeff2 = ENDSWAP_SHORT (fmt->msadpcm.coeffs [k].coeff2) ;
-					} ;
-				fmt->msadpcm.numcoeffs       = ENDSWAP_SHORT (fmt->msadpcm.numcoeffs) ;
-				fmt->msadpcm.extrabytes      = ENDSWAP_SHORT (fmt->msadpcm.extrabytes) ;
-				fmt->msadpcm.samplesperblock = ENDSWAP_SHORT (fmt->msadpcm.samplesperblock) ;
-				break ;
-				
-		case WAVE_FORMAT_IMA_ADPCM :	
-				fmt->ima.extrabytes      = ENDSWAP_SHORT (fmt->ima.extrabytes) ;
-				fmt->ima.samplesperblock = ENDSWAP_SHORT (fmt->ima.samplesperblock) ;
-				break ;
-				
-		case WAVE_FORMAT_ALAW :	
-		case WAVE_FORMAT_MULAW :	
-				fmt->size20.extrabytes = ENDSWAP_SHORT (fmt->size20.extrabytes) ;
-				fmt->size20.dummy      = ENDSWAP_SHORT (fmt->size20.dummy) ;
-				break ;
-				
-		case	WAVE_FORMAT_GSM610 :
-				fmt->gsm610.extrabytes      = ENDSWAP_SHORT (fmt->gsm610.extrabytes) ;
-				fmt->gsm610.samplesperblock = ENDSWAP_SHORT (fmt->gsm610.samplesperblock) ;
-				break ;
-				
-		default : break ;
-		} ;
+static int
+wav_subchunk_parse (SF_PRIVATE *psf, int chunk)
+{	unsigned int dword, bytesread, length ;
 
-	fmt->min.format      = ENDSWAP_SHORT (fmt->min.format) ;
-	fmt->min.channels    = ENDSWAP_SHORT (fmt->min.channels) ;
-	fmt->min.samplerate  = ENDSWAP_INT   (fmt->min.samplerate) ;
-	fmt->min.bytespersec = ENDSWAP_INT   (fmt->min.bytespersec) ;
-	fmt->min.blockalign  = ENDSWAP_SHORT (fmt->min.blockalign) ;
-	fmt->min.bitwidth    = ENDSWAP_SHORT (fmt->min.bitwidth) ;
+	bytesread = psf_binheader_readf (psf, "l", &length);
 
-} /* h2le_wav_fmt */
+	while (bytesread < length)
+	{	bytesread += psf_binheader_readf (psf, "m", &chunk);
 
-static
-const char* wav_format_str (int k)
+		switch (chunk)
+		{	case adtl_MARKER :
+			case INFO_MARKER :
+					/* These markers don't contain anything. */
+					psf_log_printf (psf, "  %D\n", chunk) ;
+					break ;
+
+
+			case IART_MARKER :
+			case ICMT_MARKER : 
+			case ICOP_MARKER :
+			case ICRD_MARKER :
+			case IENG_MARKER :
+			
+			case INAM_MARKER :
+			case IPRD_MARKER :
+			case ISBJ_MARKER :
+			case ISFT_MARKER :
+			case ISRC_MARKER :
+					bytesread += psf_binheader_readf (psf, "l", &dword);
+					dword += (dword & 1) ;
+					if (dword > sizeof (psf->buffer))
+					{	psf_log_printf (psf, "  *** %D : %d (too big)\n", chunk, dword) ;
+						return SFE_INTERNAL ;
+						} ;
+					bytesread += psf_binheader_readf (psf, "B", psf->buffer, dword) ;
+					psf->buffer [dword - 1] = 0 ;
+					psf_log_printf (psf, "    %D : %s\n", chunk, psf->buffer) ;
+					break ;
+
+			case labl_MARKER :
+			case note_MARKER :
+					bytesread += psf_binheader_readf (psf, "l", &dword);
+					dword += (dword & 1) ;
+					psf_binheader_readf (psf, "j", dword) ;
+					bytesread += dword ;
+					psf_log_printf (psf, "    %D : %d\n", chunk, dword) ;
+					break ;
+
+			default : 
+					bytesread += psf_binheader_readf (psf, "l", &dword);
+					dword += (dword & 1) ;
+					bytesread += psf_binheader_readf (psf, "j", dword) ;
+					psf_log_printf (psf, "    *** %D : %d\n", chunk, dword) ;
+					break ;
+			} ;
+		} ;
+
+	return 0 ;
+} /* wav_subchunk_parse */
+
+static char const* 
+wav_format_str (int k)
 {	switch (k)
 	{	case WAVE_FORMAT_UNKNOWN :
 			return "WAVE_FORMAT_UNKNOWN" ;
--- a/common/libsndfile/src/wav.h
+++ b/common/libsndfile/src/wav.h
@@ -14,7 +14,7 @@
 	unsigned short	bitwidth ;
 } MIN_WAV_FMT ;
 
-typedef	struct
+typedef	struct 
 {	unsigned short	format ;
 	unsigned short	channels ;
 	unsigned int	samplerate ;
@@ -52,6 +52,17 @@
 	unsigned short	samplesperblock ;
 } IMA_ADPCM_WAV_FMT ;
 
+typedef	struct
+{	unsigned short	format ;
+	unsigned short	channels ;
+	unsigned int	samplerate ;
+	unsigned int	bytespersec ;
+	unsigned short	blockalign ;
+	unsigned short	bitwidth ;
+	unsigned short	extrabytes ;
+	unsigned short	samplesperblock ;
+} GSM610_WAV_FMT ;
+
 typedef struct
 {	unsigned int	esf_field1 ;
 	unsigned short	esf_field2 ;
@@ -72,17 +83,6 @@
 	EXT_SUBFORMAT	esf ;
 } EXTENSIBLE_WAV_FMT ;
 
-typedef	struct
-{	unsigned short	format ;
-	unsigned short	channels ;
-	unsigned int	samplerate ;
-	unsigned int	bytespersec ;
-	unsigned short	blockalign ;
-	unsigned short	bitwidth ;
-	unsigned short	extrabytes ;
-	unsigned short	samplesperblock ;
-} GSM610_WAV_FMT ;
-
 typedef union
 {	unsigned short		format ;
 	MIN_WAV_FMT			min ;
@@ -98,81 +98,29 @@
 {	unsigned int samples ;
 } FACT_CHUNK ;
 
-/*------------------------------------------------------------------------------------
-**	Functions defined in wav.c
-*/
-
-int		wav_close	(SF_PRIVATE  *psf) ;
-
-/*------------------------------------------------------------------------------------
-**	Functions defined in wav_float.c
-*/
-
-int		wav_read_x86f2s (SF_PRIVATE *psf, short *ptr, int len) ;
-int		wav_read_x86f2i (SF_PRIVATE *psf, int *ptr, int len) ;
-int		wav_read_x86f2d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-
-int		wav_write_s2x86f (SF_PRIVATE *psf, short *ptr, int len) ;
-int		wav_write_i2x86f (SF_PRIVATE *psf, int *ptr, int len) ;
-int		wav_write_d2x86f (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-
-/*------------------------------------------------------------------------------------
+/*------------------------------------------------------------------------------------ 
 **	Functions defined in wav_ima_adpcm.c
 */
 
-off_t	ima_seek   (SF_PRIVATE *psf, off_t offset, int whence) ;
-int		wav_ima_close	(SF_PRIVATE  *psf) ;
-
 int		wav_ima_reader_init (SF_PRIVATE *psf, WAV_FMT *fmt) ;
-int		ima_read_s (SF_PRIVATE *psf, short *ptr, int len) ;
-int		ima_read_i (SF_PRIVATE *psf, int *ptr, int len) ;
-int		ima_read_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+int		wav_ima_writer_init (SF_PRIVATE *psf) ;
 
-int		wav_ima_writer_init (SF_PRIVATE *psf, WAV_FMT *fmt) ;
-int		ima_write_s (SF_PRIVATE *psf, short *ptr, int len) ;
-int		ima_write_i (SF_PRIVATE *psf, int *ptr, int len) ;
-int		ima_write_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-
-/*------------------------------------------------------------------------------------
+/*------------------------------------------------------------------------------------ 
 **	Functions defined in wav_ms_adpcm.c
 */
 
-off_t	msadpcm_seek   (SF_PRIVATE *psf, off_t offset, int whence) ;
-int		msadpcm_close	(SF_PRIVATE  *psf) ;
+int		wav_msadpcm_reader_init (SF_PRIVATE *psf, WAV_FMT *fmt) ;
+int		wav_msadpcm_writer_init (SF_PRIVATE *psf) ;
 
-int		msadpcm_reader_init (SF_PRIVATE *psf, WAV_FMT *fmt) ;
-int		msadpcm_read_s (SF_PRIVATE *psf, short *ptr, int len) ;
-int		msadpcm_read_i (SF_PRIVATE *psf, int *ptr, int len) ;
-int		msadpcm_read_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-
-int		msadpcm_writer_init (SF_PRIVATE *psf, WAV_FMT *fmt) ;
-int		msadpcm_write_s (SF_PRIVATE *psf, short *ptr, int len) ;
-int		msadpcm_write_i (SF_PRIVATE *psf, int *ptr, int len) ;
-int		msadpcm_write_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-
-
-/*------------------------------------------------------------------------------------
+/*------------------------------------------------------------------------------------ 
 **	Functions defined in wav_gsm610.c
 */
 
-/*
-**	off_t	wav_gsm610_seek   (SF_PRIVATE *psf, off_t offset, int whence) ;
-*/
-int		wav_gsm610_close	(SF_PRIVATE  *psf) ;
-
 int		wav_gsm610_reader_init (SF_PRIVATE *psf, WAV_FMT *fmt) ;
-int		wav_gsm610_read_s (SF_PRIVATE *psf, short *ptr, int len) ;
-int		wav_gsm610_read_i (SF_PRIVATE *psf, int *ptr, int len) ;
-int		wav_gsm610_read_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+int		wav_gsm610_writer_init (SF_PRIVATE *psf) ;
 
-int		wav_gsm610_writer_init (SF_PRIVATE *psf, WAV_FMT *fmt) ;
-int		wav_gsm610_write_s (SF_PRIVATE *psf, short *ptr, int len) ;
-int		wav_gsm610_write_i (SF_PRIVATE *psf, int *ptr, int len) ;
-int		wav_gsm610_write_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
-
-
 #ifdef _WIN32
-//	#pragma pack(pop,1)
+	#pragma pack(pop,1)
 #endif
 
 #endif
--- a/common/libsndfile/src/wav_float.c
+++ /dev/null
@@ -1,326 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU Lesser General Public License as published by
-** the Free Software Foundation; either version 2.1 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU Lesser General Public License for more details.
-** 
-** You should have received a copy of the GNU Lesser General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-#include	<stdio.h>
-#include	<unistd.h>
-#include	<string.h>
-#include	<math.h>
-
-#include	"sndfile.h"
-#include	"config.h"
-#include	"sfendian.h"
-#include	"common.h"
-#include	"wav.h"
-
-/*--------------------------------------------------------------------------------------------
-**	Prototypes for private functions.
-*/
-
-static	void	x86f2s_array (float *buffer, unsigned int count, short *ptr, int index) ;
-static	void	x86f2i_array (float *buffer, unsigned int count, int *ptr, int index) ;
-static	void	x86f2d_array (float *buffer, unsigned int count, double *ptr, int index, double normfact) ;
-
-static	void	s2x86f_array (short *ptr, int index, float *buffer, unsigned int count) ;
-static	void	i2x86f_array (int *ptr, int index, float *buffer, unsigned int count) ;
-static	void	d2x86f_array (double *ptr, int index, float *buffer, unsigned int count, double normfact) ;
-
-/*--------------------------------------------------------------------------------------------
-**	Exported functions.
-*/
-
-int		wav_read_x86f2s (SF_PRIVATE *psf, short *ptr, int len)
-{	unsigned int	bytecount, readcount, bufferlen, thisread ;
-	int				index = 0, total = 0 ;
-
-	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
-	bytecount = len * psf->bytewidth ;
-	while (bytecount > 0)
-	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
-		x86f2s_array ((float*) (psf->buffer), thisread / psf->bytewidth, ptr, index) ;
-		total += thisread ;
-		if (thisread < readcount)
-			break ;
-		index += thisread / psf->bytewidth ;
-		bytecount -= thisread ;
-		} ;
-
-	total /= psf->bytewidth ;
-	if (total < len)
-		psf->error = SFE_SHORT_READ ;
-	
-	return total ;
-} /* wav_read_x86f2s */
-
-int		wav_read_x86f2i (SF_PRIVATE *psf, int *ptr, int len)
-{	unsigned int	bytecount, readcount, bufferlen, thisread ;
-	int				index = 0, total = 0 ;
-
-	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
-	bytecount = len * psf->bytewidth ;
-	while (bytecount > 0)
-	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
-		x86f2i_array ((float*) (psf->buffer), thisread / psf->bytewidth, ptr, index) ;
-		total += thisread ;
-		if (thisread < readcount)
-			break ;
-		index += thisread / psf->bytewidth ;
-		bytecount -= thisread ;
-		} ;
-
-	total /= psf->bytewidth ;
-	if (total < len)
-		psf->error = SFE_SHORT_READ ;
-	
-	return total ;
-} /* wav_read_x86f2i */
-
-
-int		wav_read_x86f2d (SF_PRIVATE *psf, double *ptr, int len, int normalize)
-{	unsigned int	bytecount, readcount, bufferlen, thisread ;
-	int				index = 0, total = 0 ;
-	double			normfact ;
-
-	normfact = normalize ? 1.0 : 1.0 ;
-
-	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
-	bytecount = len * psf->bytewidth ;
-	while (bytecount > 0)
-	{	readcount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		thisread = fread (psf->buffer, 1, readcount, psf->file) ;
-		x86f2d_array ((float*) (psf->buffer), thisread / psf->bytewidth, ptr, index, normfact) ;
-		total += thisread ;
-		if (thisread < readcount)
-			break ;
-		index += thisread / psf->bytewidth ;
-		bytecount -= thisread ;
-		} ;
-
-	total /= psf->bytewidth ;
-	if (total < len)
-		psf->error = SFE_SHORT_READ ;
-	
-	return total ;
-} /* wav_read_x86f2d */
-
-int	wav_write_s2x86f (SF_PRIVATE *psf, short *ptr, int len)
-{	unsigned int	bytecount, writecount, bufferlen, thiswrite ;
-	int				index = 0, total = 0 ;
-
-	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
-	bytecount = len * psf->bytewidth ;
-	while (bytecount > 0)
-	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		s2x86f_array (ptr, index, (float*) (psf->buffer), writecount / psf->bytewidth) ;
-		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
-		total += thiswrite ;
-		if (thiswrite < writecount)
-			break ;
-		index += thiswrite / psf->bytewidth ;
-		bytecount -= thiswrite ;
-		} ;
-
-	total /= psf->bytewidth ;
-	if (total < len)
-		psf->error = SFE_SHORT_WRITE ;
-	
-	return total ;
-} /* wav_write_s2x86f */
-
-int	wav_write_i2x86f (SF_PRIVATE *psf, int *ptr, int len) 
-{	unsigned int	bytecount, writecount, bufferlen, thiswrite ;
-	int				index = 0, total = 0 ;
-
-	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
-	bytecount = len * psf->bytewidth ;
-	while (bytecount > 0)
-	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		i2x86f_array (ptr, index, (float*) (psf->buffer), writecount / psf->bytewidth) ;
-		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
-		total += thiswrite ;
-		if (thiswrite < writecount)
-			break ;
-		index += thiswrite / psf->bytewidth ;
-		bytecount -= thiswrite ;
-		} ;
-
-	total /= psf->bytewidth ;
-	if (total < len)
-		psf->error = SFE_SHORT_WRITE ;
-	
-	return total ;
-} /* wav_write_i2x86f */
-
-int	wav_write_d2x86f (SF_PRIVATE *psf, double *ptr, int len, int normalize)
-{	unsigned int	bytecount, writecount, bufferlen, thiswrite ;
-	int				index = 0, total = 0 ;
-	double			normfact ;
-	
-	normfact = (normalize) ? 1.0 : 1.0 ;
-
-	bufferlen = (SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth ;
-	bytecount = len * psf->bytewidth ;
-	while (bytecount > 0)
-	{	writecount = (bytecount >= bufferlen) ? bufferlen : bytecount ;
-		d2x86f_array (ptr, index, (float*) (psf->buffer), writecount / psf->bytewidth, normfact) ;
-		thiswrite = fwrite (psf->buffer, 1, writecount, psf->file) ;
-		total += thiswrite ;
-		if (thiswrite < writecount)
-			break ;
-		index += thiswrite / psf->bytewidth ;
-		bytecount -= thiswrite ;
-		} ;
-
-	total /= psf->bytewidth ;
-	if (total < len)
-		psf->error = SFE_SHORT_WRITE ;
-	
-	return total ;
-} /* wav_write_d2x86f */
-
-/*==============================================================================================
-**	Private functions.
-*/
-
-static
-float	read_x86float (unsigned char *cptr)
-{	int		exponent, mantissa ;
-	float	fvalue ;
-
-	exponent = ((cptr [3] & 0x7F) << 1) | ((cptr [2] & 0x80) ? 1 : 0);
-	mantissa = ((cptr [2] & 0x7F) << 16) | (cptr [1] << 8) | (cptr [0]) ;
-
-	if (! (exponent || mantissa))
-		return 0.0 ;
-
-	mantissa |= 0x800000 ;
-	exponent = exponent ? exponent - 127 : 0 ;
-                
-	fvalue = mantissa ? ((float) mantissa) / ((float) 0x800000) : 0.0 ;
-                
-	if (cptr [3] & 0x80)
-		fvalue *= -1 ;
-                
-	if (exponent > 0)
-		fvalue *= (1 << exponent) ;
-	else if (exponent < 0)
-		fvalue /= (1 << abs (exponent)) ;
-
-	return fvalue ;
-} /* read_x86float */
-
-static
-void	write_x86float (double in, unsigned char *out)
-{	int		exponent, mantissa ;
-
-	*((int*) out) = 0 ;
-	
-	if (in == 0.0)
-		return ;
-	
-	if (in < 0.0)
-	{	in *= -1.0 ;
-		out [3] |= 0x80 ;
-		} ;
-		
-	in = frexp (in, &exponent) ;
-	
-	exponent += 126 ;
-	
-	if (exponent & 0x01)
-		out [2] |= 0x80 ;
-	out [3] |= (exponent >> 1) & 0x7F ;
-	
-	in *= (float) 0x1000000 ;
-	mantissa = (((int) in) & 0x7FFFFF) ;
-	
-	out [0]  = mantissa & 0xFF ;
-	out [1]  = (mantissa >> 8) & 0xFF ;
-	out [2] |= (mantissa >> 16) & 0x7F ;
-	
-	return ;
-} /* write_x86float */
-
-/*----------------------------------------------------------------------------------------------
-*/
-
-static
-void	x86f2s_array (float *buffer, unsigned int count, short *ptr, int index)
-{	int	k ;
-	
-	for (k = 0 ; k < count ; k++)
-	{	ptr [index] = ((short) read_x86float ((unsigned char *) (buffer +k))) ;
-		index ++ ;
-		} ;
-} /* x86f2s_array */
-
-static
-void	x86f2i_array (float *buffer, unsigned int count, int *ptr, int index)
-{	int	k ;
-	
-	for (k = 0 ; k < count ; k++)
-	{	ptr [index] = ((int) read_x86float ((unsigned char *) (buffer +k))) ;
-		index ++ ;
-		} ;
-} /* x86f2i_array */
-
-static
-void	x86f2d_array (float *buffer, unsigned int count, double *ptr, int index, double normfact)
-{	int	k ;
-	
-	for (k = 0 ; k < count ; k++)
-	{	ptr [index] = ((double) read_x86float ((unsigned char *) (buffer +k))) * normfact  ;
-		index ++ ;
-		} ;
-} /* x86f2d_array */
-
-static 
-void	s2x86f_array (short *ptr, int index, float *buffer, unsigned int count)
-{	int		k ;
-	float	value ;
-	for (k = 0 ; k < count ; k++)
-	{	value = (float) (ptr [index]) ;
-		write_x86float (value, (unsigned char*) (buffer + k)) ;
-		index ++ ;
-		} ;
-} /* s2x86f_array */
-
-static 
-void	i2x86f_array (int *ptr, int index, float *buffer, unsigned int count)
-{	int		k ;
-	float	value ;
-	for (k = 0 ; k < count ; k++)
-	{	value = (float) (ptr [index]) ;
-		write_x86float (value, (unsigned char*) (buffer + k)) ;
-		index ++ ;
-		} ;
-} /* i2x86f_array */
-
-static 
-void	d2x86f_array (double *ptr, int index, float *buffer, unsigned int count, double normfact)
-{	int		k ;
-	float	value ;
-	for (k = 0 ; k < count ; k++)
-	{	value = (float) (ptr [index] * normfact) ;
-		write_x86float (value, (unsigned char*) (buffer + k)) ;
-		index ++ ;
-		} ;
-} /* d2x86f_array */
-
--- a/common/libsndfile/src/wav_gsm610.c
+++ b/common/libsndfile/src/wav_gsm610.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -25,10 +25,27 @@
 #include	"sndfile.h"
 #include	"config.h"
 #include	"sfendian.h"
+#include	"floatcast.h"
 #include	"common.h"
 #include	"wav.h"
 #include	"GSM610/gsm.h"
 
+#if (CPU_IS_LITTLE_ENDIAN == 1)
+#	define	MAKE_MARKER(a,b,c,d)		((a)|((b)<<8)|((c)<<16)|((d)<<24))
+#elif (CPU_IS_BIG_ENDIAN == 1)
+#	define	MAKE_MARKER(a,b,c,d)		(((a)<<24)|((b)<<16)|((c)<<8)|(d))
+#else
+#	error "Cannot determine endian-ness of processor."
+#endif
+
+#define RIFF_MARKER	(MAKE_MARKER ('R', 'I', 'F', 'F')) 
+#define WAVE_MARKER	(MAKE_MARKER ('W', 'A', 'V', 'E')) 
+#define fmt_MARKER	(MAKE_MARKER ('f', 'm', 't', ' ')) 
+#define fact_MARKER	(MAKE_MARKER ('f', 'a', 'c', 't')) 
+#define data_MARKER	(MAKE_MARKER ('d', 'a', 't', 'a')) 
+
+#define 	WAVE_FORMAT_GSM610	0x0031
+
 #define		GSM610_BLOCKSIZE	65
 #define		GSM610_SAMPLES		320
 
@@ -47,18 +64,39 @@
 static	int	wav_gsm610_write_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610) ;
 static	int wav_gsm610_write (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, short *ptr, int len) ;
 
+static long  wav_gsm610_seek   (SF_PRIVATE *psf, long offset, int whence) ;
 
+static int	wav_gsm610_read_s (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	wav_gsm610_read_i (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	wav_gsm610_read_f (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	wav_gsm610_read_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
 
+static int	wav_gsm610_write_s (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	wav_gsm610_write_i (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	wav_gsm610_write_f (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	wav_gsm610_write_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+
+static int	wav_gsm610_close	(SF_PRIVATE  *psf) ;
+static int	wav_gsm610_write_header (SF_PRIVATE  *psf) ;
+
 /*============================================================================================
 ** WAV GSM610 Reader initialisation function.
 */
 
-int	wav_gsm610_reader_init (SF_PRIVATE *psf, WAV_FMT *fmt)
+int	
+wav_gsm610_reader_init (SF_PRIVATE *psf, WAV_FMT *fmt)
 {	GSM610_PRIVATE	*pgsm610 ;
 	int  true = 1 ;
 	
 	psf->sf.seekable = SF_FALSE ;
-	
+	/*-psf->sf.seekable = SF_TRUE ;		-*/
+	psf->seek_func = (func_seek) wav_gsm610_seek ;
+
+	psf->read_short  = (func_short)  wav_gsm610_read_s ;
+	psf->read_int    = (func_int)    wav_gsm610_read_i ;
+	psf->read_float  = (func_float)  wav_gsm610_read_f ;
+	psf->read_double = (func_double) wav_gsm610_read_d ;
+
 	if (psf->mode != SF_MODE_READ)
 		return SFE_BAD_MODE_RW ;
 
@@ -74,7 +112,7 @@
 	gsm_option (pgsm610->gsm_data,  GSM_OPT_WAV49, &true) ;
 
 	if (psf->datalength % GSM610_BLOCKSIZE)
-	{	psf_sprintf (psf, "*** Warning : data chunk seems to be truncated.\n") ;
+	{	psf_log_printf (psf, "*** Warning : data chunk seems to be truncated.\n") ;
 		pgsm610->blocks = psf->datalength / GSM610_BLOCKSIZE + 1 ;
 		}
 	else
@@ -91,13 +129,11 @@
 ** WAV GSM610 writer initialisation function.
 */
 
-int	wav_gsm610_writer_init (SF_PRIVATE *psf, WAV_FMT *fmt)
+int	
+wav_gsm610_writer_init (SF_PRIVATE *psf)
 {	GSM610_PRIVATE	*pgsm610 ;
-	int  true = 1 ;
+	int  true = 1, samplesperblock, bytespersec ;
 	
-	if (fmt->format != 0x0031)
-		psf_sprintf (psf, "*** Warning : format tag != WAVE_FORMAT_GSM610.\n") ;
-		
 	if (psf->mode != SF_MODE_WRITE)
 		return SFE_BAD_MODE_RW ;
 
@@ -115,15 +151,27 @@
 	pgsm610->blockcount  = 0 ;
 	pgsm610->samplecount = 0 ;
 	
-	fmt->gsm610.blockalign      = GSM610_BLOCKSIZE ;
-	fmt->gsm610.bitwidth        = 0 ;
-	fmt->gsm610.extrabytes      = 2 ;
-	fmt->gsm610.samplesperblock = GSM610_SAMPLES ;
-	fmt->gsm610.bytespersec     = fmt->gsm610.samplerate * GSM610_BLOCKSIZE / GSM610_SAMPLES ;
+	samplesperblock = GSM610_SAMPLES ;
+	bytespersec     = psf->sf.samplerate * GSM610_BLOCKSIZE / GSM610_SAMPLES ;
 	
-	if (fmt->gsm610.bytespersec * GSM610_SAMPLES / GSM610_BLOCKSIZE < fmt->gsm610.samplerate) 
-		fmt->gsm610.bytespersec ++ ;
+	if (bytespersec * GSM610_SAMPLES / GSM610_BLOCKSIZE < psf->sf.samplerate) 
+		bytespersec ++ ;
 
+	psf->datalength  = (psf->sf.samples / samplesperblock) * samplesperblock ;
+	if (psf->sf.samples % samplesperblock)
+		psf->datalength += samplesperblock ;
+
+	wav_gsm610_write_header (psf) ;
+
+	psf->write_short  = (func_short)   wav_gsm610_write_s ;
+	psf->write_int    = (func_int)     wav_gsm610_write_i ;
+	psf->write_float  = (func_float)   wav_gsm610_write_f ;
+	psf->write_double = (func_double)  wav_gsm610_write_d ;
+	
+	psf->seek_func    = NULL ; /* Not seekable */
+	psf->close        = (func_close)   wav_gsm610_close ;
+	psf->write_header = (func_wr_hdr)  wav_gsm610_write_header ;
+					
 	return 0 ;
 } /* wav_gsm610_writer_init */
 
@@ -131,8 +179,8 @@
 ** GSM 6.10 Read Functions.
 */
 
-static
-int		wav_gsm610_read_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610)
+static int		
+wav_gsm610_read_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610)
 {	int	k ;
 	
 	pgsm610->blockcount ++ ;
@@ -144,15 +192,15 @@
 		} ;
 
 	if ((k = fread (pgsm610->block, 1, GSM610_BLOCKSIZE, psf->file)) != GSM610_BLOCKSIZE)
-		psf_sprintf (psf, "*** Warning : short read (%d != %d).\n", k, GSM610_BLOCKSIZE) ;
+		psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, GSM610_BLOCKSIZE) ;
 
 	if (gsm_decode (pgsm610->gsm_data, pgsm610->block, pgsm610->samples) < 0)
-	{	psf_sprintf (psf, "Error from gsm_decode() on frame : %d\n", pgsm610->blockcount) ;
+	{	psf_log_printf (psf, "Error from gsm_decode() on frame : %d\n", pgsm610->blockcount) ;
 		return 0 ;
 		} ;
 			
 	if (gsm_decode (pgsm610->gsm_data, pgsm610->block+(GSM610_BLOCKSIZE+1)/2, pgsm610->samples+GSM610_SAMPLES/2) < 0)
-	{	psf_sprintf (psf, "Error from gsm_decode() on frame : %d.5\n", pgsm610->blockcount) ;
+	{	psf_log_printf (psf, "Error from gsm_decode() on frame : %d.5\n", pgsm610->blockcount) ;
 		return 0 ;
 		} ;
 
@@ -159,8 +207,8 @@
 	return 1 ;
 } /* wav_gsm610_read_block */
 
-static
-int wav_gsm610_read (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, short *ptr, int len)
+static int 
+wav_gsm610_read (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, short *ptr, int len)
 {	int		count, total = 0, index = 0 ;
 
 	while (index < len)
@@ -184,7 +232,8 @@
 	return total ;		
 } /* wav_gsm610_read */
 
-int		wav_gsm610_read_s (SF_PRIVATE *psf, short *ptr, int len)
+static int		
+wav_gsm610_read_s (SF_PRIVATE *psf, short *ptr, int len)
 {	GSM610_PRIVATE 	*pgsm610 ; 
 	int				total ;
 
@@ -197,7 +246,8 @@
 	return total ;
 } /* wav_gsm610_read_s */
 
-int		wav_gsm610_read_i  (SF_PRIVATE *psf, int *ptr, int len)
+static int		
+wav_gsm610_read_i  (SF_PRIVATE *psf, int *ptr, int len)
 {	GSM610_PRIVATE *pgsm610 ; 
 	short		*sptr ;
 	int			k, bufferlen, readcount = 0, count ;
@@ -221,11 +271,40 @@
 	return total ;
 } /* wav_gsm610_read_i */
 
-int		wav_gsm610_read_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int		
+wav_gsm610_read_f  (SF_PRIVATE *psf, float *ptr, int len)
 {	GSM610_PRIVATE *pgsm610 ; 
 	short		*sptr ;
 	int			k, bufferlen, readcount = 0, count ;
 	int			index = 0, total = 0 ;
+	float		normfact ;
+
+	if (! psf->fdata)
+		return 0 ;
+	pgsm610 = (GSM610_PRIVATE*) psf->fdata ;
+	
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
+
+	sptr = (short*) psf->buffer ;
+	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
+	while (len > 0)
+	{	readcount = (len >= bufferlen) ? bufferlen : len ;
+		count = wav_gsm610_read (psf, pgsm610, sptr, readcount) ;
+		for (k = 0 ; k < readcount ; k++)
+			ptr [index+k] = normfact * (sptr [k]) ;
+		index += readcount ;
+		total += count ;
+		len -= readcount ;
+		} ;
+	return total ;
+} /* wav_gsm610_read_d */
+
+static int		
+wav_gsm610_read_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	GSM610_PRIVATE *pgsm610 ; 
+	short		*sptr ;
+	int			k, bufferlen, readcount = 0, count ;
+	int			index = 0, total = 0 ;
 	double		normfact ;
 	
 	normfact = (normalize ? 1.0 / ((double) 0x8000) : 1.0) ;
@@ -248,8 +327,8 @@
 	return total ;
 } /* wav_gsm610_read_d */
 
-
-off_t    wav_gsm610_seek   (SF_PRIVATE *psf, off_t offset, int whence)
+static long    
+wav_gsm610_seek   (SF_PRIVATE *psf, long offset, int whence)
 {	GSM610_PRIVATE *pgsm610 ; 
 	int			newblock, newsample ;
 	
@@ -259,7 +338,7 @@
 
 	if (! (psf->blockwidth && psf->datalength && psf->dataoffset))
 	{	psf->error = SFE_BAD_SEEK ;
-		return	((off_t) -1) ;
+		return	((long) -1) ;
 		} ;
 		
 	switch (whence)
@@ -266,7 +345,7 @@
 	{	case SEEK_SET :
 				if (offset < 0 || offset > pgsm610->blocks * GSM610_SAMPLES)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				newblock  = offset / GSM610_SAMPLES ;
 				newsample = offset % GSM610_SAMPLES ;
@@ -275,7 +354,7 @@
 		case SEEK_CUR :
 				if (psf->current + offset < 0 || psf->current + offset > pgsm610->blocks * GSM610_SAMPLES)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				newblock  = (psf->current + offset) / GSM610_SAMPLES ;
 				newsample = (psf->current + offset) % GSM610_SAMPLES ;
@@ -284,7 +363,7 @@
 		case SEEK_END :
 				if (offset > 0 || GSM610_SAMPLES * pgsm610->blocks + offset < 0)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				newblock  = (GSM610_SAMPLES * pgsm610->blocks + offset) / GSM610_SAMPLES ;
 				newsample = (GSM610_SAMPLES * pgsm610->blocks + offset) % GSM610_SAMPLES ;
@@ -292,7 +371,7 @@
 				
 		default : 
 				psf->error = SFE_BAD_SEEK ;
-				return	((off_t) -1) ;
+				return	((long) -1) ;
 		} ;
 		
 	if (psf->mode == SF_MODE_READ)
@@ -304,7 +383,7 @@
 	else
 	{	/* What to do about write??? */ 
 		psf->error = SFE_BAD_SEEK ;
-		return	((off_t) -1) ;
+		return	((long) -1) ;
 		} ;
 
 	psf->current = newblock * GSM610_SAMPLES + newsample ;
@@ -320,8 +399,8 @@
 /*==========================================================================================
 */
 
-static
-int		wav_gsm610_write_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610)
+static int
+wav_gsm610_write_block (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610)
 {	int k ;
 
 	/* Encode the samples. */
@@ -330,7 +409,7 @@
 
 	/* Write the block to disk. */
 	if ((k = fwrite (pgsm610->block, 1, GSM610_BLOCKSIZE, psf->file)) != GSM610_BLOCKSIZE)
-		psf_sprintf (psf, "*** Warning : short write (%d != %d).\n", k, GSM610_BLOCKSIZE) ;
+		psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, GSM610_BLOCKSIZE) ;
 
 	pgsm610->samplecount = 0 ;
 	pgsm610->blockcount ++ ;
@@ -337,12 +416,12 @@
 
 	/* Set samples to zero for next block. */
 	memset (pgsm610->samples, 0, GSM610_SAMPLES * sizeof (short)) ;
-			
+
 	return 1 ;
 } /* wav_gsm610_write_block */
 
-static
-int wav_gsm610_write (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, short *ptr, int len)
+static int 
+wav_gsm610_write (SF_PRIVATE *psf, GSM610_PRIVATE *pgsm610, short *ptr, int len)
 {	int		count, total = 0, index = 0 ;
 	
 	while (index < len)
@@ -363,7 +442,8 @@
 	return total ;		
 } /* wav_gsm610_write */
 
-int		wav_gsm610_write_s (SF_PRIVATE *psf, short *ptr, int len)
+static int		
+wav_gsm610_write_s (SF_PRIVATE *psf, short *ptr, int len)
 {	GSM610_PRIVATE 	*pgsm610 ; 
 	int				total ;
 
@@ -376,7 +456,8 @@
 	return total ;
 } /* wav_gsm610_write_s */
 
-int		wav_gsm610_write_i  (SF_PRIVATE *psf, int *ptr, int len)
+static int		
+wav_gsm610_write_i  (SF_PRIVATE *psf, int *ptr, int len)
 {	GSM610_PRIVATE *pgsm610 ; 
 	short		*sptr ;
 	int			k, bufferlen, writecount = 0, count ;
@@ -400,11 +481,40 @@
 	return total ;
 } /* wav_gsm610_write_i */
 
-int		wav_gsm610_write_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int		
+wav_gsm610_write_f  (SF_PRIVATE *psf, float *ptr, int len)
 {	GSM610_PRIVATE *pgsm610 ; 
 	short		*sptr ;
 	int			k, bufferlen, writecount = 0, count ;
 	int			index = 0, total = 0 ;
+	float		normfact ;
+	
+	if (! psf->fdata)
+		return 0 ;
+	pgsm610 = (GSM610_PRIVATE*) psf->fdata ;
+	
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x8000) : 1.0 ;
+	
+	sptr = (short*) psf->buffer ;
+	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
+	while (len > 0)
+	{	writecount = (len >= bufferlen) ? bufferlen : len ;
+		for (k = 0 ; k < writecount ; k++)
+			sptr [k] = FLOAT_TO_SHORT (normfact * ptr [index+k])  ;
+		count = wav_gsm610_write (psf, pgsm610, sptr, writecount) ;
+		index += writecount ;
+		total += count ;
+		len -= writecount ;
+		} ;
+	return total ;
+} /* wav_gsm610_write_f */
+
+static int		
+wav_gsm610_write_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	GSM610_PRIVATE *pgsm610 ; 
+	short		*sptr ;
+	int			k, bufferlen, writecount = 0, count ;
+	int			index = 0, total = 0 ;
 	double		normfact ;
 	
 	normfact = (normalize ? (double) 0x8000 : 1.0) ;
@@ -418,7 +528,7 @@
 	while (len > 0)
 	{	writecount = (len >= bufferlen) ? bufferlen : len ;
 		for (k = 0 ; k < writecount ; k++)
-			sptr [k] = (short) (normfact * ptr [index+k])  ;
+			sptr [k] = DOUBLE_TO_SHORT (normfact * ptr [index+k])  ;
 		count = wav_gsm610_write (psf, pgsm610, sptr, writecount) ;
 		index += writecount ;
 		total += count ;
@@ -427,12 +537,57 @@
 	return total ;
 } /* wav_gsm610_write_d */
 
-int	wav_gsm610_close	(SF_PRIVATE  *psf)
+static int
+wav_gsm610_write_header (SF_PRIVATE  *psf)
+{	int  fmt_size, blockalign, samplesperblock, bytespersec ;
+
+	blockalign      = GSM610_BLOCKSIZE ;
+	samplesperblock = GSM610_SAMPLES ;
+	bytespersec     = (psf->sf.samplerate * blockalign) / samplesperblock ;
+
+	/* Reset the current header length to zero. */
+	psf->header [0] = 0 ;
+	psf->headindex = 0 ;
+	fseek (psf->file, 0, SEEK_SET) ;
+
+	/* RIFF marker, length, WAVE and 'fmt ' markers. */		
+	psf_binheader_writef (psf, "mlmm", RIFF_MARKER, psf->filelength - 8, WAVE_MARKER, fmt_MARKER) ;
+
+	/* fmt chunk. */
+	fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 ;
+	
+	/* fmt : size, WAV format type, channels. */
+	psf_binheader_writef (psf, "lww", fmt_size, WAVE_FORMAT_GSM610, psf->sf.channels) ;
+
+	/* fmt : samplerate, bytespersec. */
+	psf_binheader_writef (psf, "ll", psf->sf.samplerate, bytespersec) ;
+
+	/* fmt : blockalign, bitwidth, extrabytes, samplesperblock. */
+	psf_binheader_writef (psf, "wwww", blockalign, 0, 2, samplesperblock) ;
+
+	/* Fact chunk : marker, chunk size, samples */	
+	psf_binheader_writef (psf, "mll", fact_MARKER, sizeof (int), psf->sf.samples) ;
+
+	/* DATA chunk : marker, datalength. */
+	psf_binheader_writef (psf, "ml", data_MARKER, psf->datalength) ;
+
+	fwrite (psf->header, psf->headindex, 1, psf->file) ;
+
+	psf->dataoffset = psf->headindex ;
+
+	psf->datalength  = (psf->sf.samples / samplesperblock) * samplesperblock ;
+	if (psf->sf.samples % samplesperblock)
+		psf->datalength += samplesperblock ;
+
+	return 0 ;
+} /* wav_gsm610_write_header */
+
+int	
+wav_gsm610_close	(SF_PRIVATE  *psf)
 {	GSM610_PRIVATE *pgsm610 ; 
-	unsigned int		dword ;
 
 	if (! psf->fdata)
-		return wav_close (psf) ;
+		return 0 ;
 
 	pgsm610 = (GSM610_PRIVATE*) psf->fdata ;
 
@@ -451,15 +606,10 @@
 		fseek (psf->file, 0, SEEK_END) ;
 		psf->filelength = ftell (psf->file) ;
 
-		/* Fix RIFF size. */
-		dword = H2LE_INT (psf->filelength - 2 * sizeof (dword)) ;
-		fseek (psf->file, sizeof (dword), SEEK_SET) ;
-		fwrite (&dword, sizeof (dword), 1, psf->file) ;
-		
+		psf->sf.samples = GSM610_SAMPLES * pgsm610->blockcount ;
 		psf->datalength = psf->filelength - psf->dataoffset ;
-		fseek (psf->file, (int) (psf->dataoffset - sizeof (dword)), SEEK_SET) ;
-		dword = H2LE_INT (psf->datalength) ;
-		fwrite (&dword, sizeof (dword), 1, psf->file) ;
+
+		wav_gsm610_write_header (psf) ;
 		} ;
 
 	if (pgsm610->gsm_data)
--- a/common/libsndfile/src/wav_ima_adpcm.c
+++ b/common/libsndfile/src/wav_ima_adpcm.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -25,9 +25,18 @@
 #include	"sndfile.h"
 #include	"config.h"
 #include	"sfendian.h"
+#include	"floatcast.h"
 #include	"common.h"
 #include	"wav.h"
 
+#define RIFF_MARKER	(MAKE_MARKER ('R', 'I', 'F', 'F')) 
+#define WAVE_MARKER	(MAKE_MARKER ('W', 'A', 'V', 'E')) 
+#define fmt_MARKER	(MAKE_MARKER ('f', 'm', 't', ' ')) 
+#define fact_MARKER	(MAKE_MARKER ('f', 'a', 'c', 't')) 
+#define data_MARKER	(MAKE_MARKER ('d', 'a', 't', 'a')) 
+
+#define WAVE_FORMAT_IMA_ADPCM		0x0011		/* Intel Corporation */
+
 typedef struct
 {	unsigned int	channels ;
 	unsigned int	blocksize ;
@@ -65,21 +74,76 @@
 	32767
 } ;
 
-static	int	ima_read_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) ;
-static	int ima_read (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, short *ptr, int len) ;
+static int	ima_reader_init (SF_PRIVATE *psf, IMA_ADPCM_PUBLIC *public) ;
+static int	ima_writer_init (SF_PRIVATE *psf, IMA_ADPCM_PUBLIC *public) ;
 
-static	int	ima_write_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) ;
-static	int ima_write (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, short *ptr, int len) ;
+static int ima_read_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) ;
+static int ima_read (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, short *ptr, int len) ;
 
-static	unsigned int wav_srate2blocksize (unsigned int srate) ;
+static int ima_write_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima) ;
+static int ima_write (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, short *ptr, int len) ;
 
+static int ima_read_s (SF_PRIVATE *psf, short *ptr, int len) ;
+static int ima_read_i (SF_PRIVATE *psf, int *ptr, int len) ;
+static int ima_read_f (SF_PRIVATE *psf, float *ptr, int len) ;
+static int ima_read_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
 
+static int ima_write_s (SF_PRIVATE *psf, short *ptr, int len) ;
+static int ima_write_i (SF_PRIVATE *psf, int *ptr, int len) ;
+static int ima_write_f (SF_PRIVATE *psf, float *ptr, int len) ;
+static int ima_write_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
 
+static long	ima_seek   (SF_PRIVATE *psf, long offset, int whence) ;
+static int		wav_ima_close			(SF_PRIVATE  *psf) ;
+static int		wav_ima_write_header 	(SF_PRIVATE  *psf) ;
+
+static	unsigned int wav_srate2blocksize (unsigned int srate) ;
+
 /*============================================================================================
 ** IMA ADPCM Reader initialisation function.
 */
 
-int  ima_reader_init (SF_PRIVATE *psf, IMA_ADPCM_PUBLIC *public)
+int	
+wav_ima_reader_init (SF_PRIVATE *psf, WAV_FMT *fmt)
+{	IMA_ADPCM_PUBLIC public ;
+
+	public.blocksize       = fmt->ima.blockalign ;
+	public.channels        = fmt->ima.channels ;
+	public.samplesperblock = fmt->ima.samplesperblock ;
+	return ima_reader_init (psf, &public) ;
+} /* wav_ima_reader_init */
+
+int	
+wav_ima_writer_init (SF_PRIVATE *psf)
+{	IMA_ADPCM_PUBLIC 	public ;
+	int					error ;
+	
+	public.blocksize = wav_srate2blocksize (psf->sf.samplerate) ;	
+	public.channels  = psf->sf.channels ;
+	public.samplesperblock = 2 * (public.blocksize - 4 * psf->sf.channels) / psf->sf.channels + 1 ;
+	
+	if ((error = ima_writer_init (psf, &public)))
+		return error ;
+		
+	wav_ima_write_header (psf) ;
+
+	psf->write_short  = (func_short)  ima_write_s ;
+	psf->write_int    = (func_int)    ima_write_i ;
+	psf->write_float  = (func_float)  ima_write_f ;
+	psf->write_double = (func_double) ima_write_d ;
+	psf->seek_func    = (func_seek)   ima_seek ;
+	psf->close        = (func_close)  wav_ima_close ;
+	psf->write_header = (func_wr_hdr) wav_ima_write_header ;
+		
+	return 0 ;
+} /* wav_ima_writer_init */
+
+/*============================================================================================
+** IMA ADPCM Read Functions.
+*/
+
+static int
+ima_reader_init (SF_PRIVATE *psf, IMA_ADPCM_PUBLIC *public)
 {	IMA_ADPCM_PRIVATE	*pima ;
 	unsigned int		pimasize, count ;
 	
@@ -103,7 +167,7 @@
 	pima->samplesperblock = public->samplesperblock ;
 	
 	if (psf->datalength % pima->blocksize)
-	{	psf_sprintf (psf, "*** Warning : data chunk seems to be truncated.\n") ;
+	{	psf_log_printf (psf, "*** Warning : data chunk seems to be truncated.\n") ;
 		pima->blocks = psf->datalength / pima->blocksize  + 1 ;
 		}
 	else
@@ -111,63 +175,24 @@
 	
 	count = 2 * (pima->blocksize - 4 * pima->channels) / pima->channels + 1 ;
 	if (pima->samplesperblock != count)
-		psf_sprintf (psf, "*** Warning : samplesperblock should be %d.\n", count) ;
+		psf_log_printf (psf, "*** Warning : samplesperblock should be %d.\n", count) ;
 
 	psf->sf.samples = pima->samplesperblock * pima->blocks ;
 
 	ima_read_block (psf, pima) ;	/* Read first block. */
 	
+	psf->read_short  = (func_short)  ima_read_s ;
+	psf->read_int    = (func_int)    ima_read_i ;
+	psf->read_float  = (func_float)  ima_read_f ;
+	psf->read_double = (func_double) ima_read_d ;
+
+	psf->seek_func = (func_seek) ima_seek ;
+
 	return 0 ;	
 } /* ima_reader_init */
 
-int	ima_writer_init (SF_PRIVATE *psf, IMA_ADPCM_PUBLIC *public)
-{	IMA_ADPCM_PRIVATE	*pima ;
-	unsigned int 		pimasize ;
-	
-	if (psf->mode != SF_MODE_WRITE)
-		return SFE_BAD_MODE_RW ;
-
-	public->blocksize       = wav_srate2blocksize (psf->sf.samplerate) ;	
-	public->samplesperblock = 2 * (public->blocksize - 4 * public->channels) / public->channels + 1 ;
-
-	pimasize = sizeof (IMA_ADPCM_PRIVATE) + public->blocksize + 3 * public->channels * public->samplesperblock ;
-
-	if (! (pima = malloc (pimasize)))
-		return SFE_MALLOC_FAILED ;
-		
-	psf->fdata = (void*) pima ;
-
-	memset (pima, 0, pimasize) ;
-	
-	pima->channels        = public->channels ;
-	pima->blocksize       = public->blocksize ;
-	pima->samplesperblock = public->samplesperblock ;
-
-	pima->block   = (unsigned char*) pima->data ;
-	pima->samples = (short*) (pima->data + public->blocksize) ;
-	
-	pima->samplecount = 0 ;
-	
-	return 0 ;
-} /* ima_writer_init */
-
-
-
-/*============================================================================================
-** IMA ADPCM Read Functions.
-*/
-
-int	wav_ima_reader_init (SF_PRIVATE *psf, WAV_FMT *fmt)
-{	IMA_ADPCM_PUBLIC public ;
-
-	public.blocksize       = fmt->ima.blockalign ;
-	public.channels        = fmt->ima.channels ;
-	public.samplesperblock = fmt->ima.samplesperblock ;
-	return ima_reader_init (psf, &public) ;
-} /* wav_ima_reader_init */
-
-static
-int		ima_read_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
+static int
+ima_read_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
 {	int		chan, k, current, blockindex, index, indexstart ;
 	short	step, diff, bytecode, stepindex [2] ;
 	
@@ -180,7 +205,7 @@
 		} ;
 
 	if ((k = fread (pima->block, 1, pima->blocksize, psf->file)) != pima->blocksize)
-		psf_sprintf (psf, "*** Warning : short read (%d != %d).\n", k, pima->blocksize) ;
+		psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, pima->blocksize) ;
 
 	/* Read and check the block header. */
 	
@@ -196,11 +221,11 @@
 			stepindex [chan] = 88 ;
 
 		if (pima->block [chan*4+3] != 0)
-			psf_sprintf (psf, "IMA ADPCM synchronisation error.\n") ;
+			psf_log_printf (psf, "IMA ADPCM synchronisation error.\n") ;
 		
 		pima->samples [chan] = current ;
 
-		/* psf_sprintf (psf, "block %d : channel %d (current, index) : (%d, %d)\n", 
+		/* psf_log_printf (psf, "block %d : channel %d (current, index) : (%d, %d)\n", 
 		**	pima->blockcount, chan,  current, stepindex [chan]) ;
 		*/
 		} ;
@@ -266,8 +291,8 @@
 	return 1 ;
 } /* ima_read_block */
 
-static
-int ima_read (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, short *ptr, int len)
+static int 
+ima_read (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, short *ptr, int len)
 {	int		count, total = 0, index = 0 ;
 
 	while (index < len)
@@ -291,7 +316,8 @@
 	return total ;		
 } /* ima_read */
 
-int		ima_read_s (SF_PRIVATE *psf, short *ptr, int len)
+static int		
+ima_read_s (SF_PRIVATE *psf, short *ptr, int len)
 {	IMA_ADPCM_PRIVATE 	*pima ; 
 	int				total ;
 
@@ -304,7 +330,8 @@
 	return total ;
 } /* ima_read_s */
 
-int		ima_read_i  (SF_PRIVATE *psf, int *ptr, int len)
+static int		
+ima_read_i  (SF_PRIVATE *psf, int *ptr, int len)
 {	IMA_ADPCM_PRIVATE *pima ; 
 	short		*sptr ;
 	int			k, bufferlen, readcount = 0, count ;
@@ -328,11 +355,40 @@
 	return total ;
 } /* ima_read_i */
 
-int		ima_read_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+ima_read_f  (SF_PRIVATE *psf, float *ptr, int len)
 {	IMA_ADPCM_PRIVATE *pima ; 
 	short		*sptr ;
 	int			k, bufferlen, readcount = 0, count ;
 	int			index = 0, total = 0 ;
+	float		normfact ;
+
+	if (! psf->fdata)
+		return 0 ;
+	pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
+	
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
+
+	sptr = (short*) psf->buffer ;
+	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
+	while (len > 0)
+	{	readcount = (len >= bufferlen) ? bufferlen : len ;
+		count = ima_read (psf, pima, sptr, readcount) ;
+		for (k = 0 ; k < readcount ; k++)
+			ptr [index+k] = normfact * (float) (sptr [k]) ;
+		index += readcount ;
+		total += count ;
+		len -= readcount ;
+		} ;
+	return total ;
+} /* ima_read_f */
+
+static int
+ima_read_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	IMA_ADPCM_PRIVATE *pima ; 
+	short		*sptr ;
+	int			k, bufferlen, readcount = 0, count ;
+	int			index = 0, total = 0 ;
 	double 		normfact ;
 	
 	normfact = (normalize ? 1.0 / ((double) 0x8000) : 1.0) ;
@@ -355,8 +411,8 @@
 	return total ;
 } /* ima_read_d */
 
-
-off_t    ima_seek   (SF_PRIVATE *psf, off_t offset, int whence)
+static long    
+ima_seek   (SF_PRIVATE *psf, long offset, int whence)
 {	IMA_ADPCM_PRIVATE *pima ; 
 	int			newblock, newsample ;
 	
@@ -366,7 +422,7 @@
 
 	if (! (psf->blockwidth && psf->datalength && psf->dataoffset))
 	{	psf->error = SFE_BAD_SEEK ;
-		return	((off_t) -1) ;
+		return	((long) -1) ;
 		} ;
 		
 	switch (whence)
@@ -373,7 +429,7 @@
 	{	case SEEK_SET :
 				if (offset < 0 || offset > pima->blocks * pima->samplesperblock)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				newblock  = offset / pima->samplesperblock ;
 				newsample = offset % pima->samplesperblock ;
@@ -382,7 +438,7 @@
 		case SEEK_CUR :
 				if (psf->current + offset < 0 || psf->current + offset > pima->blocks * pima->samplesperblock)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				newblock  = (psf->current + offset) / pima->samplesperblock ;
 				newsample = (psf->current + offset) % pima->samplesperblock ;
@@ -391,7 +447,7 @@
 		case SEEK_END :
 				if (offset > 0 || pima->samplesperblock * pima->blocks + offset < 0)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				newblock  = (pima->samplesperblock * pima->blocks + offset) / pima->samplesperblock ;
 				newsample = (pima->samplesperblock * pima->blocks + offset) % pima->samplesperblock ;
@@ -399,7 +455,7 @@
 				
 		default : 
 				psf->error = SFE_BAD_SEEK ;
-				return	((off_t) -1) ;
+				return	((long) -1) ;
 		} ;
 		
 	if (psf->mode == SF_MODE_READ)
@@ -411,7 +467,7 @@
 	else
 	{	/* What to do about write??? */ 
 		psf->error = SFE_BAD_SEEK ;
-		return	((off_t) -1) ;
+		return	((long) -1) ;
 		} ;
 
 	psf->current = newblock * pima->samplesperblock + newsample ;
@@ -422,35 +478,45 @@
 ** IMA ADPCM Write Functions.
 */
 
-int	wav_ima_writer_init (SF_PRIVATE *psf, WAV_FMT *fmt)
-{	IMA_ADPCM_PUBLIC 	public ;
-	int					error ;
+static int	
+ima_writer_init (SF_PRIVATE *psf, IMA_ADPCM_PUBLIC *public)
+{	IMA_ADPCM_PRIVATE	*pima ;
+	unsigned int 		pimasize ;
 	
-	if (fmt->format != 0x0011)
-		psf_sprintf (psf, "*** Warning : format tag != WAVE_FORMAT_IMA_ADPCM.\n") ;
+	if (psf->mode != SF_MODE_WRITE)
+		return SFE_BAD_MODE_RW ;
+
+	public->blocksize       = wav_srate2blocksize (psf->sf.samplerate) ;	
+	public->samplesperblock = 2 * (public->blocksize - 4 * public->channels) / public->channels + 1 ;
+
+	pimasize = sizeof (IMA_ADPCM_PRIVATE) + public->blocksize + 3 * public->channels * public->samplesperblock ;
+
+	if (! (pima = malloc (pimasize)))
+		return SFE_MALLOC_FAILED ;
 		
-	public.blocksize = wav_srate2blocksize (fmt->ima.samplerate) ;	
-	public.channels  = psf->sf.channels ;
-	public.samplesperblock = 2 * (public.blocksize - 4 * psf->sf.channels) / psf->sf.channels + 1 ;
+	psf->fdata = (void*) pima ;
+
+	memset (pima, 0, pimasize) ;
 	
-	if ((error = ima_writer_init (psf, &public)))
-		return error ;
+	pima->channels        = public->channels ;
+	pima->blocksize       = public->blocksize ;
+	pima->samplesperblock = public->samplesperblock ;
 
-	fmt->ima.blockalign      = public.blocksize ;
-	fmt->ima.bitwidth        = 4 ;
-	fmt->ima.extrabytes      = 2 ;
-	fmt->ima.samplesperblock = public.samplesperblock ;
-	fmt->ima.bytespersec     = (fmt->ima.samplerate * fmt->ima.blockalign) / fmt->ima.samplesperblock ;
+	pima->block   = (unsigned char*) pima->data ;
+	pima->samples = (short*) (pima->data + public->blocksize) ;
 	
+	pima->samplecount = 0 ;
+	
 	return 0 ;
-} /* wav_ima_writer_init */
+} /* ima_writer_init */
 
 
+
 /*==========================================================================================
 */
 
-static
-int		ima_write_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
+static int		
+ima_write_block (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima)
 {	int		chan, k, step, diff, vpdiff, blockindex, index, indexstart ;
 	short	bytecode, mask ;
 	
@@ -533,7 +599,7 @@
 	/* Write the block to disk. */
 
 	if ((k = fwrite (pima->block, 1, pima->blocksize, psf->file)) != pima->blocksize)
-		psf_sprintf (psf, "*** Warning : short write (%d != %d).\n", k, pima->blocksize) ;
+		psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, pima->blocksize) ;
 		
 	memset (pima->samples, 0, pima->samplesperblock * sizeof (short)) ;
 	pima->samplecount = 0 ;
@@ -541,8 +607,8 @@
 	return 1 ;
 } /* ima_write_block */
 
-static
-int ima_write (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, short *ptr, int len)
+static int 
+ima_write (SF_PRIVATE *psf, IMA_ADPCM_PRIVATE *pima, short *ptr, int len)
 {	int		count, total = 0, index = 0 ;
 	
 	while (index < len)
@@ -563,7 +629,8 @@
 	return total ;		
 } /* ima_write */
 
-int		ima_write_s (SF_PRIVATE *psf, short *ptr, int len)
+static int		
+ima_write_s (SF_PRIVATE *psf, short *ptr, int len)
 {	IMA_ADPCM_PRIVATE 	*pima ; 
 	int				total ;
 
@@ -576,7 +643,8 @@
 	return total ;
 } /* ima_write_s */
 
-int		ima_write_i  (SF_PRIVATE *psf, int *ptr, int len)
+static int		
+ima_write_i  (SF_PRIVATE *psf, int *ptr, int len)
 {	IMA_ADPCM_PRIVATE *pima ; 
 	short		*sptr ;
 	int			k, bufferlen, writecount = 0, count ;
@@ -600,11 +668,40 @@
 	return total ;
 } /* ima_write_i */
 
-int		ima_write_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int		
+ima_write_f  (SF_PRIVATE *psf, float *ptr, int len)
 {	IMA_ADPCM_PRIVATE *pima ; 
 	short		*sptr ;
 	int			k, bufferlen, writecount = 0, count ;
 	int			index = 0, total = 0 ;
+	float		normfact ;
+
+	if (! psf->fdata)
+		return 0 ;
+	pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
+	
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x8000) : 1.0 ;
+	
+	sptr = (short*) psf->buffer ;
+	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
+	while (len > 0)
+	{	writecount = (len >= bufferlen) ? bufferlen : len ;
+		for (k = 0 ; k < writecount ; k++)
+			sptr [k] = FLOAT_TO_SHORT (normfact * ptr [index+k])  ;
+		count = ima_write (psf, pima, sptr, writecount) ;
+		index += writecount ;
+		total += count ;
+		len -= writecount ;
+		} ;
+	return total ;
+} /* ima_write_f */
+
+static int		
+ima_write_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	IMA_ADPCM_PRIVATE *pima ; 
+	short		*sptr ;
+	int			k, bufferlen, writecount = 0, count ;
+	int			index = 0, total = 0 ;
 	double 		normfact ;
 	
 	normfact = (normalize ? ((double) 0x8000) : 1.0) ;
@@ -618,7 +715,7 @@
 	while (len > 0)
 	{	writecount = (len >= bufferlen) ? bufferlen : len ;
 		for (k = 0 ; k < writecount ; k++)
-			sptr [k] = (short) (normfact * ptr [index+k])  ;
+			sptr [k] = DOUBLE_TO_SHORT (normfact * ptr [index+k])  ;
 		count = ima_write (psf, pima, sptr, writecount) ;
 		index += writecount ;
 		total += count ;
@@ -627,12 +724,57 @@
 	return total ;
 } /* ima_write_d */
 
-int	wav_ima_close	(SF_PRIVATE  *psf)
+static int
+wav_ima_write_header (SF_PRIVATE  *psf)
+{	int  fmt_size, blockalign, samplesperblock, bytespersec ;
+
+	blockalign      = wav_srate2blocksize (psf->sf.samplerate) ;
+	samplesperblock = 2 * (blockalign - 4 * psf->sf.channels) / psf->sf.channels + 1 ;
+	bytespersec     = (psf->sf.samplerate * blockalign) / samplesperblock ;
+
+	/* Reset the current header length to zero. */
+	psf->header [0] = 0 ;
+	psf->headindex = 0 ;
+	fseek (psf->file, 0, SEEK_SET) ;
+
+	/* RIFF marker, length, WAVE and 'fmt ' markers. */		
+	psf_binheader_writef (psf, "mlmm", RIFF_MARKER, psf->filelength - 8, WAVE_MARKER, fmt_MARKER) ;
+
+	/* fmt chunk. */
+	fmt_size = 2 + 2 + 4 + 4 + 2 + 2 + 2 + 2 ;
+	
+	/* fmt : size, WAV format type, channels. */
+	psf_binheader_writef (psf, "lww", fmt_size, WAVE_FORMAT_IMA_ADPCM, psf->sf.channels) ;
+
+	/* fmt : samplerate, bytespersec. */
+	psf_binheader_writef (psf, "ll", psf->sf.samplerate, bytespersec) ;
+
+	/* fmt : blockalign, bitwidth, extrabytes, samplesperblock. */
+	psf_binheader_writef (psf, "wwww", blockalign, 4, 2, samplesperblock) ;
+
+	/* Fact chunk. */	
+	psf_binheader_writef (psf, "mll", fact_MARKER, sizeof (int), psf->sf.samples) ;
+
+	/* DATA chunk. */
+	psf_binheader_writef (psf, "ml", data_MARKER, psf->datalength) ;
+
+	fwrite (psf->header, psf->headindex, 1, psf->file) ;
+
+	psf->dataoffset = psf->headindex ;
+
+	psf->datalength  = (psf->sf.samples / samplesperblock) * samplesperblock ;
+	if (psf->sf.samples % samplesperblock)
+		psf->datalength += samplesperblock ;
+
+	return 0 ;
+} /* wav_ima_write_header */
+
+static int	
+wav_ima_close	(SF_PRIVATE  *psf)
 {	IMA_ADPCM_PRIVATE *pima ; 
-	unsigned int		dword ;
 
 	if (! psf->fdata)
-		return wav_close (psf) ;
+		return 0 ;
 
 	pima = (IMA_ADPCM_PRIVATE*) psf->fdata ;
 
@@ -645,21 +787,16 @@
 			ima_write_block (psf, pima) ;	
 
 		/*  Now we know for certain the length of the file we can
-		**  re-write correct values for the RIFF and data chunks.
+		**  re-write the header.
 		*/
 		 
 		fseek (psf->file, 0, SEEK_END) ;
 		psf->filelength = ftell (psf->file) ;
 
-		/* Fix RIFF size. */
-		dword = H2LE_INT (psf->filelength - 2 * sizeof (dword)) ;
-		fseek (psf->file, sizeof (dword), SEEK_SET) ;
-		fwrite (&dword, sizeof (dword), 1, psf->file) ;
-		
+		psf->sf.samples = pima->samplesperblock * pima->blockcount ;
 		psf->datalength = psf->filelength - psf->dataoffset ;
-		fseek (psf->file, (int) (psf->dataoffset - sizeof (dword)), SEEK_SET) ;
-		dword = H2LE_INT (psf->datalength) ;
-		fwrite (&dword, sizeof (dword), 1, psf->file) ;
+
+		wav_ima_write_header (psf) ;
 		} ;
 
 	if (psf->fdata)
@@ -669,8 +806,8 @@
 	return 0 ;
 } /* wav_ima_close */
 
-static	
-unsigned int wav_srate2blocksize (unsigned int srate)
+static unsigned 
+int wav_srate2blocksize (unsigned int srate)
 {	if (srate < 12000)
 		return 256 ;
 	if (srate < 23000)
--- a/common/libsndfile/src/wav_ms_adpcm.c
+++ b/common/libsndfile/src/wav_ms_adpcm.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
+** Copyright (C) 1999-2001 Erik de Castro Lopo <erikd@zip.com.au>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -25,10 +25,20 @@
 #include	"sndfile.h"
 #include	"config.h"
 #include	"sfendian.h"
+#include	"floatcast.h"
 #include	"common.h"
 #include	"wav.h"
 
+/* These required here because we write the header in this file. */
 
+#define RIFF_MARKER	(MAKE_MARKER ('R', 'I', 'F', 'F')) 
+#define WAVE_MARKER	(MAKE_MARKER ('W', 'A', 'V', 'E')) 
+#define fmt_MARKER	(MAKE_MARKER ('f', 'm', 't', ' ')) 
+#define fact_MARKER	(MAKE_MARKER ('f', 'a', 'c', 't')) 
+#define data_MARKER	(MAKE_MARKER ('d', 'a', 't', 'a')) 
+
+#define WAVE_FORMAT_MS_ADPCM	0x0002
+
 typedef struct
 {	unsigned int	channels, blocksize, samplesperblock, blocks, dataremaining ; 
 	int				blockcount, samplecount ;
@@ -87,13 +97,28 @@
 ** Static functions.
 */
 
-static	int	msadpcm_read_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms) ;
+static	int	msadpcm_decode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms) ;
 static	int msadpcm_read (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms, short *ptr, int len) ;
 
-static	int	msadpcm_write_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms) ;
+static	int	msadpcm_encode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms) ;
 static	int msadpcm_write (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms, short *ptr, int len) ;
 
-static	unsigned int srate2blocksize (unsigned int srate) ;
+static	int	msadpcm_read_s (SF_PRIVATE *psf, short *ptr, int len) ;
+static	int	msadpcm_read_i (SF_PRIVATE *psf, int *ptr, int len) ;
+static	int	msadpcm_read_f (SF_PRIVATE *psf, float *ptr, int len) ;
+static	int	msadpcm_read_d (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+
+static int	msadpcm_write_s (SF_PRIVATE *psf, short *ptr, int len) ;
+static int	msadpcm_write_i  (SF_PRIVATE *psf, int *ptr, int len) ;
+static int	msadpcm_write_f  (SF_PRIVATE *psf, float *ptr, int len) ;
+static int	msadpcm_write_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize) ;
+
+static long msadpcm_seek   (SF_PRIVATE *psf, long offset, int whence) ;
+static	int	msadpcm_close	(SF_PRIVATE  *psf) ;
+
+static int	msadpcm_write_header (SF_PRIVATE  *psf) ;
+
+static	unsigned int srate2blocksize (unsigned int srate_chan_product) ;
 static	void	choose_predictor (unsigned int channels, short *data, int *bpred, int *idelta) ;
 
 /*============================================================================================
@@ -100,7 +125,8 @@
 ** MS ADPCM Read Functions.
 */
 
-int	msadpcm_reader_init (SF_PRIVATE *psf, WAV_FMT *fmt)
+int	
+wav_msadpcm_reader_init (SF_PRIVATE *psf, WAV_FMT *fmt)
 {	MSADPCM_PRIVATE	*pms ;
 	unsigned int	pmssize ;
 	int				count ;
@@ -128,19 +154,26 @@
 
 	count = 2 * (pms->blocksize - 6 * pms->channels) / pms->channels ;
 	if (pms->samplesperblock != count)
-		psf_sprintf (psf, "*** Warning : samplesperblock shoud be %d.\n", count) ;
+		psf_log_printf (psf, "*** Warning : samplesperblock shoud be %d.\n", count) ;
 
 	psf->sf.samples = (psf->datalength / pms->blocksize) * pms->samplesperblock ;
 
-	psf_sprintf (psf, " bpred   idelta\n") ;
+	psf_log_printf (psf, " bpred   idelta\n") ;
 
-	msadpcm_read_block (psf, pms) ;
+	msadpcm_decode_block (psf, pms) ;
 	
+	psf->read_short  = (func_short)  msadpcm_read_s ;
+	psf->read_int    = (func_int)    msadpcm_read_i ;
+	psf->read_float  = (func_float)  msadpcm_read_f ;
+	psf->read_double = (func_double) msadpcm_read_d ;
+
+	psf->seek_func   = (func_seek)   msadpcm_seek ;
+
 	return 0 ;
-} /* msadpcm_reader_init */
+} /* wav_msadpcm_reader_init */
 
-static
-int		msadpcm_read_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms)
+static int		
+msadpcm_decode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms)
 {	int		chan, k, blockindex, sampleindex ;
 	short	bytecode, bpred [2], chan_idelta [2] ;
 	
@@ -157,7 +190,7 @@
 		} ;
 
 	if ((k = fread (pms->block, 1, pms->blocksize, psf->file)) != pms->blocksize)
-		psf_sprintf (psf, "*** Warning : short read (%d != %d).\n", k, pms->blocksize) ;
+		psf_log_printf (psf, "*** Warning : short read (%d != %d).\n", k, pms->blocksize) ;
 
 	/* Read and check the block header. */
 	
@@ -165,12 +198,12 @@
 	{	bpred [0] = pms->block [0] ;
 	
 		if (bpred [0] >= 7)
-			psf_sprintf (psf, "MS ADPCM synchronisation error (%d).\n", bpred [0]) ;
+			psf_log_printf (psf, "MS ADPCM synchronisation error (%d).\n", bpred [0]) ;
 	
 		chan_idelta [0] = pms->block [1] | (pms->block [2] << 8) ;
 		chan_idelta [1] = 0 ;
 
-		psf_sprintf (psf, "(%d) (%d)\n", bpred [0], chan_idelta [0]) ;
+		psf_log_printf (psf, "(%d) (%d)\n", bpred [0], chan_idelta [0]) ;
 
 		pms->samples [1] = pms->block [3] | (pms->block [4] << 8) ;
 		pms->samples [0] = pms->block [5] | (pms->block [6] << 8) ;
@@ -181,12 +214,12 @@
 		bpred [1] = pms->block [1] ;
 	
 		if (bpred [0] >= 7 || bpred [1] >= 7)
-			psf_sprintf (psf, "MS ADPCM synchronisation error (%d %d).\n", bpred [0], bpred [1]) ;
+			psf_log_printf (psf, "MS ADPCM synchronisation error (%d %d).\n", bpred [0], bpred [1]) ;
 	
 		chan_idelta [0] = pms->block [2] | (pms->block [3] << 8) ;
 		chan_idelta [1] = pms->block [4] | (pms->block [5] << 8) ;
 
-		psf_sprintf (psf, "(%d, %d) (%d, %d)\n", bpred [0], bpred [1], chan_idelta [0], chan_idelta [1]) ;
+		psf_log_printf (psf, "(%d, %d) (%d, %d)\n", bpred [0], bpred [1], chan_idelta [0], chan_idelta [1]) ;
 
 		pms->samples [2] = pms->block [6] | (pms->block [7] << 8) ;
 		pms->samples [3] = pms->block [8] | (pms->block [9] << 8) ;
@@ -241,10 +274,10 @@
 		} ;
 
 	return 1 ;
-} /* msadpcm_read_block */
+} /* msadpcm_decode_block */
 
-static
-int msadpcm_read (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms, short *ptr, int len)
+static int 
+msadpcm_read (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms, short *ptr, int len)
 {	int		count, total = 0, index = 0 ;
 	
 	while (index < len)
@@ -254,7 +287,7 @@
 			} ;
 		
 		if (pms->samplecount >= pms->samplesperblock)
-			msadpcm_read_block (psf, pms) ;
+			msadpcm_decode_block (psf, pms) ;
 		
 		count = (pms->samplesperblock - pms->samplecount) * pms->channels ;
 		count = (len - index > count) ? count : len - index ;
@@ -268,7 +301,8 @@
 	return total ;		
 } /* msadpcm_read */
 
-int		msadpcm_read_s (SF_PRIVATE *psf, short *ptr, int len)
+static int		
+msadpcm_read_s (SF_PRIVATE *psf, short *ptr, int len)
 {	MSADPCM_PRIVATE 	*pms ; 
 	int				total ;
 
@@ -281,7 +315,8 @@
 	return total ;
 } /* msadpcm_read_s */
 
-int		msadpcm_read_i  (SF_PRIVATE *psf, int *ptr, int len)
+static int		
+msadpcm_read_i  (SF_PRIVATE *psf, int *ptr, int len)
 {	MSADPCM_PRIVATE *pms ; 
 	short		*sptr ;
 	int			k, bufferlen, readcount = 0, count ;
@@ -305,11 +340,39 @@
 	return total ;
 } /* msadpcm_read_i */
 
-int		msadpcm_read_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+msadpcm_read_f  (SF_PRIVATE *psf, float *ptr, int len)
 {	MSADPCM_PRIVATE *pms ; 
 	short		*sptr ;
 	int			k, bufferlen, readcount = 0, count ;
 	int			index = 0, total = 0 ;
+	float		normfact ;
+
+	if (! psf->fdata)
+		return 0 ;
+	pms = (MSADPCM_PRIVATE*) psf->fdata ;
+	
+	normfact = (psf->norm_float == SF_TRUE) ? 1.0 / ((float) 0x8000) : 1.0 ;
+	sptr = (short*) psf->buffer ;
+	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
+	while (len > 0)
+	{	readcount = (len >= bufferlen) ? bufferlen : len ;
+		count = msadpcm_read (psf, pms, sptr, readcount) ;
+		for (k = 0 ; k < readcount ; k++)
+			ptr [index+k] = normfact * (float) (sptr [k]) ;
+		index += readcount ;
+		total += count ;
+		len -= readcount ;
+		} ;
+	return total ;
+} /* msadpcm_read_f */
+
+static int		
+msadpcm_read_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	MSADPCM_PRIVATE *pms ; 
+	short		*sptr ;
+	int			k, bufferlen, readcount = 0, count ;
+	int			index = 0, total = 0 ;
 	double 		normfact ;
 	
 	normfact = (normalize ? 1.0 / ((double) 0x8000) : 1.0) ;
@@ -332,8 +395,8 @@
 	return total ;
 } /* msadpcm_read_d */
 
-
-off_t    msadpcm_seek   (SF_PRIVATE *psf, off_t offset, int whence)
+static long    
+msadpcm_seek   (SF_PRIVATE *psf, long offset, int whence)
 {	MSADPCM_PRIVATE *pms ; 
 	int			newblock, newsample ;
 	
@@ -343,7 +406,7 @@
 
 	if (! (psf->blockwidth && psf->datalength && psf->dataoffset))
 	{	psf->error = SFE_BAD_SEEK ;
-		return	((off_t) -1) ;
+		return	((long) -1) ;
 		} ;
 		
 	switch (whence)
@@ -350,7 +413,7 @@
 	{	case SEEK_SET :
 				if (offset < 0 || offset > pms->blocks * pms->samplesperblock)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				newblock  = offset / pms->samplesperblock ;
 				newsample = offset % pms->samplesperblock ;
@@ -359,7 +422,7 @@
 		case SEEK_CUR :
 				if (psf->current + offset < 0 || psf->current + offset > pms->blocks * pms->samplesperblock)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				newblock  = (psf->current + offset) / pms->samplesperblock ;
 				newsample = (psf->current + offset) % pms->samplesperblock ;
@@ -368,7 +431,7 @@
 		case SEEK_END :
 				if (offset > 0 || pms->samplesperblock * pms->blocks + offset < 0)
 				{	psf->error = SFE_BAD_SEEK ;
-					return	((off_t) -1) ;
+					return	((long) -1) ;
 					} ;
 				newblock  = (pms->samplesperblock * pms->blocks + offset) / pms->samplesperblock ;
 				newsample = (pms->samplesperblock * pms->blocks + offset) % pms->samplesperblock ;
@@ -376,19 +439,19 @@
 				
 		default : 
 				psf->error = SFE_BAD_SEEK ;
-				return	((off_t) -1) ;
+				return	((long) -1) ;
 		} ;
 		
 	if (psf->mode == SF_MODE_READ)
 	{	fseek (psf->file, (int) (psf->dataoffset + newblock * pms->blocksize), SEEK_SET) ;
 		pms->blockcount  = newblock ;
-		msadpcm_read_block (psf, pms) ;
+		msadpcm_decode_block (psf, pms) ;
 		pms->samplecount = newsample ;
 		}
 	else
 	{	/* What to do about write??? */ 
 		psf->error = SFE_BAD_SEEK ;
-		return	((off_t) -1) ;
+		return	((long) -1) ;
 		} ;
 
 	psf->current = newblock * pms->samplesperblock + newsample ;
@@ -399,50 +462,49 @@
 ** MS ADPCM Write Functions.
 */
 
-int	msadpcm_writer_init (SF_PRIVATE *psf, WAV_FMT *fmt)
+int	
+wav_msadpcm_writer_init (SF_PRIVATE *psf)
 {	MSADPCM_PRIVATE	*pms ;
-	unsigned int 	k, pmssize ;
+	unsigned int 	pmssize, blockalign, samplesperblock ;
 	
-	if (fmt->format != 0x0002)
-		psf_sprintf (psf, "*** Warning : format tag != WAVE_FORMAT_MS_ADPCM.\n") ;
+	blockalign      = srate2blocksize (psf->sf.samplerate * psf->sf.channels) ;	
+	samplesperblock = 2 + 2 * (blockalign - 7 * psf->sf.channels) / psf->sf.channels ;
 	
-	fmt->msadpcm.blockalign      = srate2blocksize (fmt->msadpcm.samplerate) ;	
-	fmt->msadpcm.bitwidth        = 4 ;
-	fmt->msadpcm.extrabytes      = 32 ;
-	fmt->msadpcm.samplesperblock = 2 + 2 * (fmt->msadpcm.blockalign - 7 * fmt->msadpcm.channels) / fmt->msadpcm.channels ;
+	pmssize = sizeof (MSADPCM_PRIVATE) + blockalign + 3 * psf->sf.channels * samplesperblock ;
 
-	fmt->msadpcm.bytespersec     = (fmt->msadpcm.samplerate * fmt->msadpcm.blockalign) / fmt->msadpcm.samplesperblock ;
-	
-	fmt->msadpcm.numcoeffs = 7 ;
-	for (k = 0 ; k < 7 ; k++)
-	{	fmt->msadpcm.coeffs[k].coeff1 = AdaptCoeff1 [k] ;
-		fmt->msadpcm.coeffs[k].coeff2 = AdaptCoeff2 [k] ;
-		} ;	
-	
-	pmssize = sizeof (MSADPCM_PRIVATE) + fmt->msadpcm.blockalign + 3 * fmt->msadpcm.channels * fmt->msadpcm.samplesperblock ;
-
 	if (! (psf->fdata = malloc (pmssize)))
 		return SFE_MALLOC_FAILED ;
 	pms = (MSADPCM_PRIVATE*) psf->fdata ;
 	memset (pms, 0, pmssize) ;
 	
-	pms->channels        = fmt->msadpcm.channels ;
-	pms->blocksize       = fmt->msadpcm.blockalign ;
-	pms->samplesperblock = fmt->msadpcm.samplesperblock ;
+	pms->channels        = psf->sf.channels ;
+	pms->blocksize       = blockalign ;
+	pms->samplesperblock = samplesperblock ;
 
 	pms->block   = (unsigned char*) pms->dummydata ;
-	pms->samples = (short*) (pms->dummydata + fmt->msadpcm.blockalign) ;
+	pms->samples = (short*) (pms->dummydata + blockalign) ;
 	
 	pms->samplecount = 0 ;
 	
+	msadpcm_write_header (psf) ;
+	
+	psf->write_short  = (func_short)   msadpcm_write_s ;
+	psf->write_int    = (func_int)     msadpcm_write_i ;
+	psf->write_float  = (func_float)   msadpcm_write_f ;
+	psf->write_double = (func_double)  msadpcm_write_d ;
+	
+	psf->seek_func    = (func_seek)    msadpcm_seek ;
+	psf->close        = (func_close)   msadpcm_close ;
+	psf->write_header = (func_wr_hdr)  msadpcm_write_header ;
+
 	return 0 ;
-} /* msadpcm_writer_init */
+} /* wav_msadpcm_writer_init */
 
 /*==========================================================================================
 */
 
-static
-int		msadpcm_write_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms)
+static int		
+msadpcm_encode_block (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms)
 {	unsigned int	blockindex ;
 	unsigned char	byte ;
 	int				chan, k, predict, bpred [2], idelta [2], errordelta, newsamp ;
@@ -494,7 +556,6 @@
 		}
 	else
 	{	/* Stereo file. */
-	
 		pms->block [0]	= bpred [0] ;	
 		pms->block [1]	= bpred [1] ;	
 
@@ -517,10 +578,13 @@
 		byte = 0 ;
 		chan = 1 ;
 		
-		for (k = 4 ; k < pms->samplesperblock ; k+=2)
-		{	chan = chan ? 0 : 1 ;
+		for (k = 4 ; k < 2 * pms->samplesperblock ; k++)
+		{	chan = k & 1 ;
+
 			predict = (pms->samples [k-2] * AdaptCoeff1 [bpred [chan]] + pms->samples [k-4] * AdaptCoeff2 [bpred [chan]]) >> 8 ;
 			errordelta = (pms->samples [k] - predict) / idelta [chan] ;
+
+
 			if (errordelta < -8)
 				errordelta = -8 ;
 			else if (errordelta > 7)
@@ -534,7 +598,8 @@
 				errordelta += 0x10 ;
 				
 			byte = (byte << 4) | (errordelta & 0xF) ;
-			if (k % 2)
+
+			if (chan)
 			{	pms->block [blockindex++] = byte ;
 				byte = 0 ;
 				} ;
@@ -542,7 +607,7 @@
 			idelta [chan] = (idelta [chan] * AdaptationTable [errordelta]) >> 8 ;
 			if (idelta [chan] < 16)
 				idelta [chan] = 16 ;
-			pms->samples [k-2] = newsamp ;
+			pms->samples [k] = newsamp ;
 			} ;
 		} ;
 
@@ -549,7 +614,7 @@
 	/* Write the block to disk. */
 
 	if ((k = fwrite (pms->block, 1, pms->blocksize, psf->file)) != pms->blocksize)
-		psf_sprintf (psf, "*** Warning : short write (%d != %d).\n", k, pms->blocksize) ;
+		psf_log_printf (psf, "*** Warning : short write (%d != %d).\n", k, pms->blocksize) ;
 		
 	memset (pms->samples, 0, pms->samplesperblock * sizeof (short)) ;
 
@@ -557,10 +622,10 @@
 	pms->samplecount = 0 ;
 			
 	return 1 ;
-} /* msadpcm_write_block */
+} /* msadpcm_encode_block */
 
-static
-int msadpcm_write (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms, short *ptr, int len)
+static int 
+msadpcm_write (SF_PRIVATE *psf, MSADPCM_PRIVATE *pms, short *ptr, int len)
 {	int		count, total = 0, index = 0 ;
 	
 	while (index < len)
@@ -575,13 +640,14 @@
 		total = index ;
 
 		if (pms->samplecount >= pms->samplesperblock)
-			msadpcm_write_block (psf, pms) ;	
+			msadpcm_encode_block (psf, pms) ;	
 		} ;
 
 	return total ;		
 } /* msadpcm_write */
 
-int		msadpcm_write_s (SF_PRIVATE *psf, short *ptr, int len)
+static int		
+msadpcm_write_s (SF_PRIVATE *psf, short *ptr, int len)
 {	MSADPCM_PRIVATE *pms ; 
 	int				total ;
 
@@ -594,7 +660,8 @@
 	return total ;
 } /* msadpcm_write_s */
 
-int		msadpcm_write_i  (SF_PRIVATE *psf, int *ptr, int len)
+static int		
+msadpcm_write_i  (SF_PRIVATE *psf, int *ptr, int len)
 {	MSADPCM_PRIVATE *pms ; 
 	short		*sptr ;
 	int			k, bufferlen, writecount = 0, count ;
@@ -618,11 +685,40 @@
 	return total ;
 } /* msadpcm_write_i */
 
-int		msadpcm_write_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+static int
+msadpcm_write_f  (SF_PRIVATE *psf, float *ptr, int len)
 {	MSADPCM_PRIVATE *pms ; 
 	short		*sptr ;
 	int			k, bufferlen, writecount = 0, count ;
 	int			index = 0, total = 0 ;
+	float		normfact ;
+	
+	if (! psf->fdata)
+		return 0 ;
+	pms = (MSADPCM_PRIVATE*) psf->fdata ;
+	
+	normfact = (psf->norm_float == SF_TRUE) ? ((float) 0x8000) : 1.0 ;
+	
+	sptr = (short*) psf->buffer ;
+	bufferlen = ((SF_BUFFER_LEN / psf->blockwidth) * psf->blockwidth) / sizeof (short) ;
+	while (len > 0)
+	{	writecount = (len >= bufferlen) ? bufferlen : len ;
+		for (k = 0 ; k < writecount ; k++)
+			sptr [k] = FLOAT_TO_SHORT (normfact * ptr [index+k]) ;
+		count = msadpcm_write (psf, pms, sptr, writecount) ;
+		index += writecount ;
+		total += count ;
+		len -= writecount ;
+		} ;
+	return total ;
+} /* msadpcm_write_f */
+
+static int		
+msadpcm_write_d  (SF_PRIVATE *psf, double *ptr, int len, int normalize)
+{	MSADPCM_PRIVATE *pms ; 
+	short		*sptr ;
+	int			k, bufferlen, writecount = 0, count ;
+	int			index = 0, total = 0 ;
 	double 		normfact ;
 	
 	normfact = (normalize ? ((double) 0x8000) : 1.0) ;
@@ -636,7 +732,7 @@
 	while (len > 0)
 	{	writecount = (len >= bufferlen) ? bufferlen : len ;
 		for (k = 0 ; k < writecount ; k++)
-			sptr [k] = (short) (normfact * ptr [index+k]) ;
+			sptr [k] = DOUBLE_TO_SHORT (normfact * ptr [index+k]) ;
 		count = msadpcm_write (psf, pms, sptr, writecount) ;
 		index += writecount ;
 		total += count ;
@@ -648,35 +744,79 @@
 /*========================================================================================
 */
 
-int	msadpcm_close	(SF_PRIVATE  *psf)
+static int
+msadpcm_write_header (SF_PRIVATE  *psf)
+{	int  k, fmt_size, blockalign, samplesperblock, bytespersec, extrabytes ;
+
+	blockalign      = srate2blocksize (psf->sf.samplerate * psf->sf.channels) ;	
+	samplesperblock = 2 + 2 * (blockalign - 7 * psf->sf.channels) / psf->sf.channels ;
+	bytespersec     = (psf->sf.samplerate * blockalign) / samplesperblock ;
+	
+	/* Reset the current header length to zero. */
+	psf->header [0] = 0 ;
+	psf->headindex = 0 ;
+	fseek (psf->file, 0, SEEK_SET) ;
+
+	/* RIFF marker, length, WAVE and 'fmt ' markers. */		
+	psf_binheader_writef (psf, "mlmm", RIFF_MARKER, psf->filelength - 8, WAVE_MARKER, fmt_MARKER) ;
+
+	/* fmt chunk. */
+	extrabytes = 2 + 2 + 7 * (2 + 2) ;
+	fmt_size   = 2 + 2 + 4 + 4 + 2 + 2 + 2 + extrabytes ;
+	
+	/* fmt : size, WAV format type, channels. */
+	psf_binheader_writef (psf, "lww", fmt_size, WAVE_FORMAT_MS_ADPCM, psf->sf.channels) ;
+
+	/* fmt : samplerate, bytespersec. */
+	psf_binheader_writef (psf, "ll", psf->sf.samplerate, bytespersec) ;
+
+	/* fmt : blockalign, bitwidth, extrabytes, samplesperblock. */
+	psf_binheader_writef (psf, "wwwww", blockalign, 4, extrabytes, samplesperblock, 7) ;
+	
+	for (k = 0 ; k < 7 ; k++)
+		psf_binheader_writef (psf, "ww", AdaptCoeff1 [k], AdaptCoeff2 [k]) ;
+
+	/* Fact chunk. */	
+	psf_binheader_writef (psf, "mll", fact_MARKER, sizeof (int), psf->sf.samples) ;
+
+	/* DATA chunk. */
+	psf_binheader_writef (psf, "ml", data_MARKER, psf->datalength) ;
+
+	fwrite (psf->header, psf->headindex, 1, psf->file) ;
+
+	psf->dataoffset = psf->headindex ;
+
+	psf->datalength  = (psf->sf.samples / samplesperblock) * samplesperblock ;
+	if (psf->sf.samples % samplesperblock)
+		psf->datalength += samplesperblock ;
+
+	return 0 ;
+} /* msadpcm_write_header */
+
+static int	
+msadpcm_close	(SF_PRIVATE  *psf)
 {	MSADPCM_PRIVATE *pms ; 
-	unsigned int		dword ;
 
 	if (! psf->fdata)
-		return wav_close (psf) ;
+		return 0 ;
 
 	pms = (MSADPCM_PRIVATE*) psf->fdata ;
 
 	if (psf->mode == SF_MODE_WRITE)
-	{	/*  Now we know for certain the length of the file we can
-		**  re-write correct values for the RIFF and data chunks.
+	{	/*  Now we know static int for certain the length of the file we can
+		**  re-write the header.
 		*/
 		 
 		if (pms->samplecount && pms->samplecount < pms->samplesperblock)
-			msadpcm_write_block (psf, pms) ;	
+			msadpcm_encode_block (psf, pms) ;	
 
 		fseek (psf->file, 0, SEEK_END) ;
 		psf->filelength = ftell (psf->file) ;
 
-		/* Fix RIFF size. */
-		dword = H2LE_INT (psf->filelength - 2 * sizeof (dword)) ;
-		fseek (psf->file, sizeof (dword), SEEK_SET) ;
-		fwrite (&dword, sizeof (dword), 1, psf->file) ;
-		
+		psf->sf.samples = pms->samplesperblock * pms->blockcount ;
 		psf->datalength = psf->filelength - psf->dataoffset ;
-		fseek (psf->file, (int) (psf->dataoffset - sizeof (dword)), SEEK_SET) ;
-		dword = H2LE_INT (psf->datalength) ;
-		fwrite (&dword, sizeof (dword), 1, psf->file) ;
+
+		msadpcm_write_header (psf) ;
 		} ;
 
 	if (psf->fdata)
@@ -690,17 +830,17 @@
 ** Static functions.
 */
 
-static	
-unsigned int srate2blocksize (unsigned int srate)
-{	if (srate < 12000)
+static	unsigned int 
+srate2blocksize (unsigned int srate_chan_product)
+{	if (srate_chan_product < 12000)
 		return 256 ;
-	if (srate < 23000)
+	if (srate_chan_product < 23000)
 		return 512 ;
-	return 1024 ;
+	if (srate_chan_product < 44000)
+		return 1024 ;
+	return 2048 ;
 } /* srate2blocksize */
 
-
-
 /*----------------------------------------------------------------------------------------
 **	Choosing the block predictor.
 **	Each block requires a predictor and an idelta for each channel. 
@@ -719,8 +859,8 @@
 
 #define		IDELTA_COUNT	3
 
-static	
-void	choose_predictor (unsigned int channels, short *data, int *block_pred, int *idelta)
+static	void	
+choose_predictor (unsigned int channels, short *data, int *block_pred, int *idelta)
 {	unsigned int	chan, k, bpred, idelta_sum, best_bpred, best_idelta ;
 	
 	for (chan = 0 ; chan < channels; chan++)
--- a/common/libsndfile/tests/Makefile.am
+++ /dev/null
@@ -1,103 +1,0 @@
-noinst_PROGRAMS = sfversion read_seek_test double_test write_read_test \
-	lossy_comp_test error_test ulaw_test alaw_test sftest
-
-SNDFILEDIR =../src
-INCLUDES = -I$(srcdir)/$(SNDFILEDIR)
-
-sfversion_SOURCES = sfversion.c 
-sfversion_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-read_seek_test_SOURCES = read_seek_test.c 
-read_seek_test_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-write_read_test_SOURCES = write_read_test.c 
-write_read_test_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-lossy_comp_test_SOURCES = lossy_comp_test.c 
-lossy_comp_test_LDADD = $(SNDFILEDIR)/libsndfile.la -lm
-
-error_test_SOURCES = error_test.c 
-error_test_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-ulaw_test_SOURCES = ulaw_test.c 
-ulaw_test_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-alaw_test_SOURCES = alaw_test.c 
-alaw_test_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-double_test_SOURCES = double_test.c 
-double_test_LDADD = $(SNDFILEDIR)/libsndfile.la -lm
-
-sftest_SOURCES = sftest.c 
-sftest_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-check: generic-test ulaw_test alaw_test double_test first-test \
-		wav-tests aiff-tests au-tests raw-tests paf-tests svx-tests
-
-generic-test : error_test
-	./error_test
-	./ulaw_test
-	./alaw_test
-	./double_test
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed common tests."
-	@echo "--------------------------------------------------------------------"
-
-first-test: read_seek_test
-	./read_seek_test wav
-	./read_seek_test aiff
-	./read_seek_test au
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed first set of tests."
-	@echo "--------------------------------------------------------------------"
-
-wav-tests: write_read_test
-	./write_read_test wav
-	./lossy_comp_test wav_ima
-	./lossy_comp_test wav_msadpcm
-	./lossy_comp_test wav_ulaw
-	./lossy_comp_test wav_alaw
-	./lossy_comp_test wav_gsm610
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed tests on WAV files."
-	@echo "--------------------------------------------------------------------"
-
-aiff-tests: write_read_test
-	./write_read_test aiff
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed tests on AIFF files."
-	@echo "--------------------------------------------------------------------"
-
-au-tests: write_read_test
-	./write_read_test au
-	./write_read_test aule
-	./lossy_comp_test au_ulaw
-	./lossy_comp_test au_alaw
-	./lossy_comp_test aule_ulaw
-	./lossy_comp_test aule_alaw
-	./lossy_comp_test au_g721
-	./lossy_comp_test au_g723
-	./lossy_comp_test aule_g721
-	./lossy_comp_test aule_g723
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed tests on AU files."
-	@echo "--------------------------------------------------------------------"
-
-raw-tests: write_read_test
-	./write_read_test raw
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed tests on RAW (header-less PCM) files."
-	@echo "--------------------------------------------------------------------"
-
-paf-tests: write_read_test
-	./write_read_test paf
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed tests on PAF files."
-	@echo "--------------------------------------------------------------------"
-
-svx-tests: write_read_test
-	./write_read_test svx
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed tests on SVX files."
-	@echo "--------------------------------------------------------------------"
-
--- a/common/libsndfile/tests/Makefile.in
+++ /dev/null
@@ -1,460 +1,0 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
-
-# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-
-SHELL = @SHELL@
-
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
-pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-
-top_builddir = ..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_alias = @build_alias@
-build_triplet = @build@
-host_alias = @host_alias@
-host_triplet = @host@
-target_alias = @target_alias@
-target_triplet = @target@
-AS = @AS@
-CC = @CC@
-DLLTOOL = @DLLTOOL@
-LD = @LD@
-LIBTOOL = @LIBTOOL@
-LN_S = @LN_S@
-MAKEINFO = @MAKEINFO@
-NM = @NM@
-OBJDUMP = @OBJDUMP@
-PACKAGE = @PACKAGE@
-RANLIB = @RANLIB@
-SHARED_VERSION_INFO = @SHARED_VERSION_INFO@
-VERSION = @VERSION@
-subdirs = @subdirs@
-
-noinst_PROGRAMS = sfversion read_seek_test double_test write_read_test 	lossy_comp_test error_test ulaw_test alaw_test sftest
-
-
-SNDFILEDIR = ../src
-INCLUDES = -I$(srcdir)/$(SNDFILEDIR)
-
-sfversion_SOURCES = sfversion.c 
-sfversion_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-read_seek_test_SOURCES = read_seek_test.c 
-read_seek_test_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-write_read_test_SOURCES = write_read_test.c 
-write_read_test_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-lossy_comp_test_SOURCES = lossy_comp_test.c 
-lossy_comp_test_LDADD = $(SNDFILEDIR)/libsndfile.la -lm
-
-error_test_SOURCES = error_test.c 
-error_test_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-ulaw_test_SOURCES = ulaw_test.c 
-ulaw_test_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-alaw_test_SOURCES = alaw_test.c 
-alaw_test_LDADD = $(SNDFILEDIR)/libsndfile.la
-
-double_test_SOURCES = double_test.c 
-double_test_LDADD = $(SNDFILEDIR)/libsndfile.la -lm
-
-sftest_SOURCES = sftest.c 
-sftest_LDADD = $(SNDFILEDIR)/libsndfile.la
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../src/config.h
-CONFIG_CLEAN_FILES = 
-PROGRAMS =  $(noinst_PROGRAMS)
-
-
-DEFS = @DEFS@ -I. -I$(srcdir) -I../src
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-sfversion_OBJECTS =  sfversion.o
-sfversion_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-sfversion_LDFLAGS = 
-read_seek_test_OBJECTS =  read_seek_test.o
-read_seek_test_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-read_seek_test_LDFLAGS = 
-double_test_OBJECTS =  double_test.o
-double_test_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-double_test_LDFLAGS = 
-write_read_test_OBJECTS =  write_read_test.o
-write_read_test_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-write_read_test_LDFLAGS = 
-lossy_comp_test_OBJECTS =  lossy_comp_test.o
-lossy_comp_test_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-lossy_comp_test_LDFLAGS = 
-error_test_OBJECTS =  error_test.o
-error_test_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-error_test_LDFLAGS = 
-ulaw_test_OBJECTS =  ulaw_test.o
-ulaw_test_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-ulaw_test_LDFLAGS = 
-alaw_test_OBJECTS =  alaw_test.o
-alaw_test_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-alaw_test_LDFLAGS = 
-sftest_OBJECTS =  sftest.o
-sftest_DEPENDENCIES =  $(SNDFILEDIR)/libsndfile.la
-sftest_LDFLAGS = 
-CFLAGS = @CFLAGS@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-DIST_COMMON =  Makefile.am Makefile.in
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = gtar
-GZIP_ENV = --best
-SOURCES = $(sfversion_SOURCES) $(read_seek_test_SOURCES) $(double_test_SOURCES) $(write_read_test_SOURCES) $(lossy_comp_test_SOURCES) $(error_test_SOURCES) $(ulaw_test_SOURCES) $(alaw_test_SOURCES) $(sftest_SOURCES)
-OBJECTS = $(sfversion_OBJECTS) $(read_seek_test_OBJECTS) $(double_test_OBJECTS) $(write_read_test_OBJECTS) $(lossy_comp_test_OBJECTS) $(error_test_OBJECTS) $(ulaw_test_OBJECTS) $(alaw_test_OBJECTS) $(sftest_OBJECTS)
-
-all: all-redirect
-.SUFFIXES:
-.SUFFIXES: .S .c .lo .o .s
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
-	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps tests/Makefile
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-mostlyclean-noinstPROGRAMS:
-
-clean-noinstPROGRAMS:
-	-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
-
-distclean-noinstPROGRAMS:
-
-maintainer-clean-noinstPROGRAMS:
-
-.c.o:
-	$(COMPILE) -c $<
-
-.s.o:
-	$(COMPILE) -c $<
-
-.S.o:
-	$(COMPILE) -c $<
-
-mostlyclean-compile:
-	-rm -f *.o core *.core
-
-clean-compile:
-
-distclean-compile:
-	-rm -f *.tab.c
-
-maintainer-clean-compile:
-
-.c.lo:
-	$(LIBTOOL) --mode=compile $(COMPILE) -c $<
-
-.s.lo:
-	$(LIBTOOL) --mode=compile $(COMPILE) -c $<
-
-.S.lo:
-	$(LIBTOOL) --mode=compile $(COMPILE) -c $<
-
-mostlyclean-libtool:
-	-rm -f *.lo
-
-clean-libtool:
-	-rm -rf .libs _libs
-
-distclean-libtool:
-
-maintainer-clean-libtool:
-
-sfversion: $(sfversion_OBJECTS) $(sfversion_DEPENDENCIES)
-	@rm -f sfversion
-	$(LINK) $(sfversion_LDFLAGS) $(sfversion_OBJECTS) $(sfversion_LDADD) $(LIBS)
-
-read_seek_test: $(read_seek_test_OBJECTS) $(read_seek_test_DEPENDENCIES)
-	@rm -f read_seek_test
-	$(LINK) $(read_seek_test_LDFLAGS) $(read_seek_test_OBJECTS) $(read_seek_test_LDADD) $(LIBS)
-
-double_test: $(double_test_OBJECTS) $(double_test_DEPENDENCIES)
-	@rm -f double_test
-	$(LINK) $(double_test_LDFLAGS) $(double_test_OBJECTS) $(double_test_LDADD) $(LIBS)
-
-write_read_test: $(write_read_test_OBJECTS) $(write_read_test_DEPENDENCIES)
-	@rm -f write_read_test
-	$(LINK) $(write_read_test_LDFLAGS) $(write_read_test_OBJECTS) $(write_read_test_LDADD) $(LIBS)
-
-lossy_comp_test: $(lossy_comp_test_OBJECTS) $(lossy_comp_test_DEPENDENCIES)
-	@rm -f lossy_comp_test
-	$(LINK) $(lossy_comp_test_LDFLAGS) $(lossy_comp_test_OBJECTS) $(lossy_comp_test_LDADD) $(LIBS)
-
-error_test: $(error_test_OBJECTS) $(error_test_DEPENDENCIES)
-	@rm -f error_test
-	$(LINK) $(error_test_LDFLAGS) $(error_test_OBJECTS) $(error_test_LDADD) $(LIBS)
-
-ulaw_test: $(ulaw_test_OBJECTS) $(ulaw_test_DEPENDENCIES)
-	@rm -f ulaw_test
-	$(LINK) $(ulaw_test_LDFLAGS) $(ulaw_test_OBJECTS) $(ulaw_test_LDADD) $(LIBS)
-
-alaw_test: $(alaw_test_OBJECTS) $(alaw_test_DEPENDENCIES)
-	@rm -f alaw_test
-	$(LINK) $(alaw_test_LDFLAGS) $(alaw_test_OBJECTS) $(alaw_test_LDADD) $(LIBS)
-
-sftest: $(sftest_OBJECTS) $(sftest_DEPENDENCIES)
-	@rm -f sftest
-	$(LINK) $(sftest_LDFLAGS) $(sftest_OBJECTS) $(sftest_LDADD) $(LIBS)
-
-tags: TAGS
-
-ID: $(HEADERS) $(SOURCES) $(LISP)
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	here=`pwd` && cd $(srcdir) \
-	  && mkid -f$$here/ID $$unique $(LISP)
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
-	tags=; \
-	here=`pwd`; \
-	list='$(SOURCES) $(HEADERS)'; \
-	unique=`for i in $$list; do echo $$i; done | \
-	  awk '    { files[$$0] = 1; } \
-	       END { for (i in files) print i; }'`; \
-	test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
-	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
-
-mostlyclean-tags:
-
-clean-tags:
-
-distclean-tags:
-	-rm -f TAGS ID
-
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = tests
-
-distdir: $(DISTFILES)
-	@for file in $(DISTFILES); do \
-	  d=$(srcdir); \
-	  if test -d $$d/$$file; then \
-	    cp -pr $$/$$file $(distdir)/$$file; \
-	  else \
-	    test -f $(distdir)/$$file \
-	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
-	    || cp -p $$d/$$file $(distdir)/$$file || :; \
-	  fi; \
-	done
-alaw_test.o: alaw_test.c ../src/sndfile.h
-double_test.o: double_test.c ../src/sndfile.h
-error_test.o: error_test.c ../src/sndfile.h
-lossy_comp_test.o: lossy_comp_test.c ../src/sndfile.h
-read_seek_test.o: read_seek_test.c ../src/sndfile.h
-sftest.o: sftest.c ../src/sndfile.h
-sfversion.o: sfversion.c ../src/sndfile.h
-ulaw_test.o: ulaw_test.c ../src/sndfile.h
-write_read_test.o: write_read_test.c ../src/sndfile.h
-
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
-check-am: all-am
-check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am:
-install-exec: install-exec-am
-
-install-data-am:
-install-data: install-data-am
-
-install-am: all-am
-	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am:
-uninstall: uninstall-am
-all-am: Makefile $(PROGRAMS)
-all-redirect: all-am
-install-strip:
-	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
-
-
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
-	-rm -f Makefile $(CONFIG_CLEAN_FILES)
-	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
-
-maintainer-clean-generic:
-mostlyclean-am:  mostlyclean-noinstPROGRAMS mostlyclean-compile \
-		mostlyclean-libtool mostlyclean-tags \
-		mostlyclean-generic
-
-mostlyclean: mostlyclean-am
-
-clean-am:  clean-noinstPROGRAMS clean-compile clean-libtool clean-tags \
-		clean-generic mostlyclean-am
-
-clean: clean-am
-
-distclean-am:  distclean-noinstPROGRAMS distclean-compile \
-		distclean-libtool distclean-tags distclean-generic \
-		clean-am
-	-rm -f libtool
-
-distclean: distclean-am
-
-maintainer-clean-am:  maintainer-clean-noinstPROGRAMS \
-		maintainer-clean-compile maintainer-clean-libtool \
-		maintainer-clean-tags maintainer-clean-generic \
-		distclean-am
-	@echo "This command is intended for maintainers to use;"
-	@echo "it deletes files that may require special tools to rebuild."
-
-maintainer-clean: maintainer-clean-am
-
-.PHONY: mostlyclean-noinstPROGRAMS distclean-noinstPROGRAMS \
-clean-noinstPROGRAMS maintainer-clean-noinstPROGRAMS \
-mostlyclean-compile distclean-compile clean-compile \
-maintainer-clean-compile mostlyclean-libtool distclean-libtool \
-clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
-distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
-dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
-install-exec install-data-am install-data install-am install \
-uninstall-am uninstall all-redirect all-am all installdirs \
-mostlyclean-generic distclean-generic clean-generic \
-maintainer-clean-generic clean mostlyclean distclean maintainer-clean
-
-
-check: generic-test ulaw_test alaw_test double_test first-test \
-		wav-tests aiff-tests au-tests raw-tests paf-tests svx-tests
-
-generic-test : error_test
-	./error_test
-	./ulaw_test
-	./alaw_test
-	./double_test
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed common tests."
-	@echo "--------------------------------------------------------------------"
-
-first-test: read_seek_test
-	./read_seek_test wav
-	./read_seek_test aiff
-	./read_seek_test au
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed first set of tests."
-	@echo "--------------------------------------------------------------------"
-
-wav-tests: write_read_test
-	./write_read_test wav
-	./lossy_comp_test wav_ima
-	./lossy_comp_test wav_msadpcm
-	./lossy_comp_test wav_ulaw
-	./lossy_comp_test wav_alaw
-	./lossy_comp_test wav_gsm610
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed tests on WAV files."
-	@echo "--------------------------------------------------------------------"
-
-aiff-tests: write_read_test
-	./write_read_test aiff
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed tests on AIFF files."
-	@echo "--------------------------------------------------------------------"
-
-au-tests: write_read_test
-	./write_read_test au
-	./write_read_test aule
-	./lossy_comp_test au_ulaw
-	./lossy_comp_test au_alaw
-	./lossy_comp_test aule_ulaw
-	./lossy_comp_test aule_alaw
-	./lossy_comp_test au_g721
-	./lossy_comp_test au_g723
-	./lossy_comp_test aule_g721
-	./lossy_comp_test aule_g723
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed tests on AU files."
-	@echo "--------------------------------------------------------------------"
-
-raw-tests: write_read_test
-	./write_read_test raw
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed tests on RAW (header-less PCM) files."
-	@echo "--------------------------------------------------------------------"
-
-paf-tests: write_read_test
-	./write_read_test paf
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed tests on PAF files."
-	@echo "--------------------------------------------------------------------"
-
-svx-tests: write_read_test
-	./write_read_test svx
-	@echo "--------------------------------------------------------------------"
-	@echo "  `./sfversion` passed tests on SVX files."
-	@echo "--------------------------------------------------------------------"
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
--- a/common/libsndfile/tests/alaw_test.c
+++ /dev/null
@@ -1,243 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-
-#include	<stdio.h>
-#include	<unistd.h>
-
-#include	<sndfile.h>
-
-#define	BUFFER_SIZE		(65536)
-
-static unsigned char	alaw_encode (int sample) ;
-static int				alaw_decode (unsigned int alawbyte) ;
-
-static	short			short_buffer [BUFFER_SIZE] ;
-static	unsigned char	alaw_buffer [BUFFER_SIZE] ;
-
-int		main (int argc, char *argv[])
-{	SNDFILE	*file ;
-	SF_INFO sfinfo ;
-	char	*filename ;
-	int		k ;
-	
-	filename = "test.au" ;
-	
-	sfinfo.format      = SF_FORMAT_AU | SF_FORMAT_ALAW ;
-	sfinfo.samplerate  = 44100 ;
-	sfinfo.samples     = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
-	sfinfo.channels    = 1 ;
-	sfinfo.pcmbitwidth = 16 ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-		
-	/* Generate a file containing all possible 16 bit sample values 
-	** and write it to disk as alaw encoded samples. 
-	*/
-
-	for (k = 0 ; k < 0x10000 ; k++)
-		short_buffer [k] = k & 0xFFFF ;
-
-	sf_write_short (file, short_buffer, BUFFER_SIZE) ;
-	sf_close (file) ;
-	
-	/* Now open that file and compare the alaw encoded sample values 
-	** with what they should be.
-	*/
-
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-
-	if (sf_read_raw (file, alaw_buffer, BUFFER_SIZE) != BUFFER_SIZE)
-	{	printf ("sf_read_raw : ") ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-	
-	for (k = 0 ; k < 0x10000 ; k++)
-		if (alaw_encode (short_buffer [k]) != alaw_buffer [k])
-		{	printf ("Encoder error : sample #%d (0x%02X should be 0x%02X)\n", k, alaw_buffer [k], alaw_encode (short_buffer [k])) ;
-			exit (1) ;
-			} ;
-
-	sf_close (file) ;
-	
-	printf ("    alaw_test : encoder ... ok\n") ;
-
-	/* Now generate a file containing all possible 8 bit encoded
-	** sample values and write it to disk as alaw encoded samples. 
-	*/
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-
-	for (k = 0 ; k < 256 ; k++)
-		alaw_buffer [k] = k & 0xFF ;
-
-	sf_write_raw (file, alaw_buffer, 256) ;
-	sf_close (file) ;
-	
-	/* Now open that file and compare the alaw decoded sample values 
-	** with what they should be.
-	*/
-
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-
-	if (sf_read_short (file, short_buffer, 256) != 256)
-	{	printf ("sf_read_short : ") ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-	
-	
-	for (k = 0 ; k < 256 ; k++)
-		if (short_buffer [k] != alaw_decode (alaw_buffer [k]))
-		{	printf ("Decoder error : sample #%d (0x%02X should be 0x%02X)\n", k, short_buffer [k], alaw_decode (alaw_buffer [k])) ;
-			exit (1) ;
-			} ;
-
-	sf_close (file) ;
-	
-	printf ("    alaw_test : decoder ... ok\n") ;
-	
-	unlink (filename) ;
-
-	return 0 ;
-} /* main */
-
-
-/*=================================================================================
-**	The following routines came from the sox-12.15 (Sound eXcahcnge) distribution.
-**
-**	This code is not compiled into libsndfile. It is only used to test the 
-**	libsndfile lookup tables for correctness.
-**	
-**	I have included the original authors comments.
-*/
-
-/*
-** A-law routines by Graeme W. Gill.
-** Date: 93/5/7
-**
-** References:
-** 1) CCITT Recommendation G.711
-**
-*/
-
-#define ACLIP 31744
-
-static
-unsigned char alaw_encode (int sample)
-{	static int exp_lut[128] = {1,1,2,2,3,3,3,3,
-                               4,4,4,4,4,4,4,4,
-                               5,5,5,5,5,5,5,5,
-                               5,5,5,5,5,5,5,5,
-                               6,6,6,6,6,6,6,6,
-                               6,6,6,6,6,6,6,6,
-                               6,6,6,6,6,6,6,6,
-                               6,6,6,6,6,6,6,6,
-                               7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7};
-
-    int sign, exponent, mantissa;
-    unsigned char Alawbyte;
-
-    /* Get the sample into sign-magnitude. */
-    sign = ((~sample) >> 8) & 0x80 ;			/* set aside the sign */
-    if (sign == 0) 
-		sample = -sample ;		/* get magnitude */
-    if (sample > ACLIP) 
-		sample = ACLIP ;						/* clip the magnitude */
-
-    /* Convert from 16 bit linear to ulaw. */
-    if (sample >= 256)
-	{	exponent = exp_lut [(sample >> 8) & 0x7F] ;
-		mantissa = ( sample >> ( exponent + 3 ) ) & 0x0F ;
-		Alawbyte = ((exponent << 4) | mantissa) ;
-		}
-    else
-		Alawbyte = (sample >> 4) ;
-    
-	Alawbyte ^= (sign ^ 0x55) ;
-
-    return Alawbyte ;
-} /* alaw_encode */
-
-static
-int alaw_decode (unsigned int Alawbyte)
-{	static int exp_lut[8] = { 0, 264, 528, 1056, 2112, 4224, 8448, 16896 } ;
-    int sign, exponent, mantissa, sample ;
-
-    Alawbyte ^= 0x55 ;
-    sign = ( Alawbyte & 0x80 ) ;
-    Alawbyte &= 0x7f ;			/* get magnitude */
-    if (Alawbyte >= 16)
-	{	exponent = (Alawbyte >> 4 ) & 0x07 ;
-		mantissa = Alawbyte & 0x0F ;
-		sample = exp_lut[exponent] + (mantissa << ( exponent + 3 )) ;
-		}
-    else
-		sample = (Alawbyte << 4) + 8 ;
-    if (sign == 0) 
-		sample = -sample ;
-
-    return sample ;
-} /* alaw_decode */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
--- a/common/libsndfile/tests/double_test.c
+++ /dev/null
@@ -1,182 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include	<stdio.h>
-#include	<string.h>
-#include	<unistd.h>
-#include	<math.h>
-
-
-#include	<sndfile.h>
-
-#define	SAMPLE_RATE			11025
-#define	BUFFER_SIZE			(1<<14)
-
-static	void	scaled_test		(char *str, char *filename, int filetype, int bitwidth, double tolerance) ;
-
-static	int		error_function (double data, double orig, double margin) ;
-static	void	gen_signal (double *data, unsigned int datalen) ;
-
-static	double	orig_data [BUFFER_SIZE] ;
-static	double	test_data [BUFFER_SIZE] ;
-
-int		main (int argc, char *argv[])
-{	
-	scaled_test	("pcm8" , "test.wav", SF_FORMAT_WAV | SF_FORMAT_PCM, 8, 0.001) ;
-	scaled_test	("pcm16", "test.wav", SF_FORMAT_WAV | SF_FORMAT_PCM, 16, 0.001) ;
-	scaled_test	("pcm24", "test.wav", SF_FORMAT_WAV | SF_FORMAT_PCM, 24, 0.001) ;
-	scaled_test	("pcm32", "test.wav", SF_FORMAT_WAV | SF_FORMAT_PCM, 32, 0.001) ;
-	
-	scaled_test	("ulaw", "test.au", SF_FORMAT_AU | SF_FORMAT_ULAW, 16, 0.05) ;
-	scaled_test	("alaw", "test.au", SF_FORMAT_AU | SF_FORMAT_ALAW, 16, 0.05) ;
-	
-	scaled_test	("imaadpcm", "test.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM, 16, 0.21) ;
-	scaled_test	("msadpcm" , "test.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM, 16, 0.7) ;
-	scaled_test	("gsm610"  , "test.wav", SF_FORMAT_WAV | SF_FORMAT_GSM610, 16, 3.0) ;
-
-	scaled_test	("g721_32", "test.au", SF_FORMAT_AU | SF_FORMAT_G721_32, 16, 1.1) ;
-	scaled_test	("g723_24", "test.au", SF_FORMAT_AU | SF_FORMAT_G723_24, 16, 1.1) ;
-
-	return 0;
-} /* main */
-
-/*============================================================================================
- *	Here are the test functions.
- */ 
-
-static	
-void	scaled_test (char *str, char *filename, int filetype, int bitwidth, double tolerance)
-{	SNDFILE			*file ;
-	SF_INFO			sfinfo ;
-	unsigned int	k ;
-	double			scale ;
-
-	printf ("    scaled_test : %s ", str) ;
-	for (k = strlen (str) ; k < 10 ; k++)
-		putchar ('.') ;
-	putchar (' ') ;
-
-	gen_signal (orig_data, BUFFER_SIZE) ;
-		
-	sfinfo.samplerate  = SAMPLE_RATE ;
-	sfinfo.samples     = BUFFER_SIZE ;
-	sfinfo.channels    = 1 ;
-	sfinfo.pcmbitwidth = bitwidth ;
-	sfinfo.format 	   = filetype ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sf_write_double (file, orig_data, BUFFER_SIZE, 1) != BUFFER_SIZE)
-	{	printf ("sf_write_int failed with error : ") ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-		
-	sf_close (file) ;
-	
-	memset (test_data, 0, sizeof (test_data)) ;
-
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != filetype)
-	{	printf ("Returned format incorrect (0x%08X => 0x%08X).\n", filetype, sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples < BUFFER_SIZE)
-	{	printf ("Incorrect number of samples in file (too short). (%d should be %d)\n", sfinfo.samples, BUFFER_SIZE) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 1)
-	{	printf ("Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != bitwidth)
-	{	printf ("Incorrect bit width (%d => %d).\n", bitwidth, sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_read_double (file, test_data, BUFFER_SIZE, 1)) < 0.99 * BUFFER_SIZE)
-	{	printf ("short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	sf_close (file) ;
-
-	scale = bitwidth > 8 ? 32000.0 : 120.0 ;
-	for (k = 0 ; k < BUFFER_SIZE ; k++)
-		if (error_function (scale * test_data [k], scale * orig_data [k], tolerance))
-		{	printf ("Incorrect sample (#%d : %f should be %f).\n", k, test_data [k], orig_data [k]) ;
-			exit (1) ;
-			} ;
-
-	unlink (filename) ;
-			
-	printf ("ok\n") ;
-} /* scaled_test */
-
-/*========================================================================================
-**	Auxiliary functions
-*/
-
-static
-void	gen_signal (double *data, unsigned int datalen)
-{	unsigned int k, ramplen ;
-	double	amp = 0.0 ;
-	
-	ramplen = datalen / 20 ;
-
-	for (k = 0 ; k < datalen ; k++)
-	{	if (k <= ramplen)
-			amp = k / ((double) ramplen) ;
-		else if (k > datalen - ramplen)
-			amp = (datalen - k) / ((double) ramplen) ;
-		data [k] = amp * (0.4 * sin (33.3 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE))
-							+ 0.3 * cos (201.1 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE))) ;
-		} ;
-	return ;
-} /* gen_signal */
-
-static
-int error_function (double data, double orig, double margin)
-{	double error ;
-
-	if (fabs (orig) <= 500.0)
-		error = fabs (fabs (data) - fabs(orig)) / 2000.0 ;
-	else if (fabs (orig) <= 1000.0)
-		error = fabs (data - orig) / 3000.0 ;
-	else
-		error = fabs (data - orig) / fabs (orig) ;
-		
-	if (error > margin)
-	{	printf ("\n\n*******************\nError : %f\n", error) ;
-		return 1 ;
-		} ;
-	return 0 ;
-} /* error_function */
-
--- a/common/libsndfile/tests/error_test.c
+++ /dev/null
@@ -1,53 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-
-#include	<stdio.h>
-#include	<string.h>
-#include	<unistd.h>
-
-#include	<sndfile.h>
-
-extern int	sf_error_number	(int errnum, char *str, size_t maxlen) ;
-
-#define	BUFFER_SIZE		(1<<15)
-#define	SHORT_BUFFER	(256)
-
-static	char	strbuffer [BUFFER_SIZE] ;
-static	char	noerror   [SHORT_BUFFER] ;
-
-int		main (int argc, char *argv[])
-{	int		k ;
-
-	sf_error_number (0, noerror, SHORT_BUFFER) ;
-		
-	printf ("Testing to see if all internal error numbers have corresponding error messages :\n") ;
-
-	for (k = 1 ; k < 1000 ; k++)
-	{	sf_error_number (k, strbuffer, BUFFER_SIZE) ;
-		printf ("\t%3d : %s\n", k, strbuffer) ;
-		if (! strcmp (strbuffer, noerror))
-			break ;
-		if (strstr (strbuffer, "This is a bug in libsndfile."))
-			return 1 ;
-		} ;
-
-	return 0 ;
-} /* main */
-
--- a/common/libsndfile/tests/lossy_comp_test.c
+++ /dev/null
@@ -1,1472 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include	<stdio.h>
-#include	<string.h>
-#include	<unistd.h>
-#include	<math.h>
-
-#include	<sndfile.h>
-
-#ifndef M_PI
-	#define M_PI 3.14159
-#endif
-
-#define	BUFFER_SIZE		(1<<14)
-#define	SAMPLE_RATE		11025
-
-static	void	lcomp_test_short	(char *str, char *filename, int typemajor, int typeminor, double margin) ;
-static	void	lcomp_test_int		(char *str, char *filename, int typemajor, int typeminor, double margin) ;
-static	void	lcomp_test_double	(char *str, char *filename, int typemajor, int typeminor, double margin) ;
-
-static	void	sdlcomp_test_short	(char *str, char *filename, int typemajor, int typeminor, double margin) ;
-static	void	sdlcomp_test_int	(char *str, char *filename, int typemajor, int typeminor, double margin) ;
-static	void	sdlcomp_test_double	(char *str, char *filename, int typemajor, int typeminor, double margin) ;
-
-static	int		error_function (double data, double orig, double margin) ;
-static	int		decay_response (int k) ;
-static	void	gen_signal (double *data, unsigned int datalen) ;
-static	void	smoothed_diff_short (short *data, unsigned int datalen) ;
-static	void	smoothed_diff_int (int *data, unsigned int datalen) ;
-static	void	smoothed_diff_double (double *data, unsigned int datalen) ;
-
-/* Force the start of these buffers to be double aligned. Sparc-solaris will
-** choke if they are not.
-*/
-static	double	data_buffer [BUFFER_SIZE + 1] ;
-static	double	orig_buffer [BUFFER_SIZE + 1] ;
-static	double	smooth_buffer [BUFFER_SIZE + 1] ;
-
-int		main (int argc, char *argv[])
-{	char	*filename ;
-	int		bDoAll = 0 ;
-	int		nTests = 0 ;
-
-	if (argc != 2)
-	{	printf ("Usage : %s <test>\n", argv [0]) ;
-		printf ("    Where <test> is one of the following:\n") ;
-		printf ("           wav_ima     - test IMA ADPCM WAV file functions\n") ;
-		printf ("           wav_msadpcm - test MS ADPCM WAV file functions\n") ;
-		printf ("           wav_gsm610  - test GSM 6.10 WAV file functions\n") ;
-		printf ("           wav_ulaw    - test u-law WAV file functions\n") ;
-		printf ("           wav_alaw    - test A-law WAV file functions\n") ;
-		printf ("           wav_pcm     - test PCM WAV file functions\n") ;
-		printf ("           all         - perform all tests\n") ;
-		exit (1) ;
-		} ;
-		
-	bDoAll = !strcmp (argv [1], "all") ;
-
-	if (bDoAll || ! strcmp (argv [1], "wav_pcm"))
-	{	filename = "test.wav" ;
-		lcomp_test_short	("wav_pcm", filename, SF_FORMAT_WAV, SF_FORMAT_PCM, 0.00001) ;
-		lcomp_test_int		("wav_pcm", filename, SF_FORMAT_WAV, SF_FORMAT_PCM, 0.00001) ;
-		lcomp_test_double	("wav_pcm", filename, SF_FORMAT_WAV, SF_FORMAT_PCM, 0.005) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "wav_ima"))
-	{	filename = "test.wav" ;
-		lcomp_test_short	("wav_ima", filename, SF_FORMAT_WAV, SF_FORMAT_IMA_ADPCM, 0.17) ;
-		lcomp_test_int		("wav_ima", filename, SF_FORMAT_WAV, SF_FORMAT_IMA_ADPCM, 0.17) ;
-		lcomp_test_double	("wav_ima", filename, SF_FORMAT_WAV, SF_FORMAT_IMA_ADPCM, 0.17) ;
-
-		sdlcomp_test_short	("wav_ima", filename, SF_FORMAT_WAV, SF_FORMAT_IMA_ADPCM, 0.17) ;
-		sdlcomp_test_int	("wav_ima", filename, SF_FORMAT_WAV, SF_FORMAT_IMA_ADPCM, 0.17) ;
-		sdlcomp_test_double	("wav_ima", filename, SF_FORMAT_WAV, SF_FORMAT_IMA_ADPCM, 0.17) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "wav_msadpcm"))
-	{	filename = "test.wav" ;
-		lcomp_test_short	("wav_msadpcm", filename, SF_FORMAT_WAV, SF_FORMAT_MS_ADPCM, 0.36) ;
-		lcomp_test_int		("wav_msadpcm", filename, SF_FORMAT_WAV, SF_FORMAT_MS_ADPCM, 0.36) ;
-		lcomp_test_double	("wav_msadpcm", filename, SF_FORMAT_WAV, SF_FORMAT_MS_ADPCM, 0.36) ;
-
-		sdlcomp_test_short	("wav_msadpcm", filename, SF_FORMAT_WAV, SF_FORMAT_MS_ADPCM, 0.36) ;
-		sdlcomp_test_int	("wav_msadpcm", filename, SF_FORMAT_WAV, SF_FORMAT_MS_ADPCM, 0.36) ;
-		sdlcomp_test_double	("wav_msadpcm", filename, SF_FORMAT_WAV, SF_FORMAT_MS_ADPCM, 0.36) ;
-
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "wav_ulaw"))
-	{	filename = "test.wav" ;
-		lcomp_test_short	("wav_ulaw", filename, SF_FORMAT_WAV, SF_FORMAT_ULAW, 0.04) ;
-		lcomp_test_int		("wav_ulaw", filename, SF_FORMAT_WAV, SF_FORMAT_ULAW, 0.04) ;
-		lcomp_test_double	("wav_ulaw", filename, SF_FORMAT_WAV, SF_FORMAT_ULAW, 0.04) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "wav_alaw"))
-	{	filename = "test.wav" ;
-		lcomp_test_short	("wav_alaw", filename, SF_FORMAT_WAV, SF_FORMAT_ALAW, 0.04) ;
-		lcomp_test_int		("wav_alaw", filename, SF_FORMAT_WAV, SF_FORMAT_ALAW, 0.04) ;
-		lcomp_test_double	("wav_alaw", filename, SF_FORMAT_WAV, SF_FORMAT_ALAW, 0.04) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "wav_gsm610"))
-	{	filename = "test.wav" ;
-		sdlcomp_test_short	("wav_gsm610", filename, SF_FORMAT_WAV, SF_FORMAT_GSM610, 0.2) ;
-		sdlcomp_test_int	("wav_gsm610", filename, SF_FORMAT_WAV, SF_FORMAT_GSM610, 0.2) ;
-		sdlcomp_test_double	("wav_gsm610", filename, SF_FORMAT_WAV, SF_FORMAT_GSM610, 0.2) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "au_ulaw"))
-	{	filename = "test.au" ;
-		lcomp_test_short	("au_ulaw", filename, SF_FORMAT_AU, SF_FORMAT_ULAW, 0.04) ;
-		lcomp_test_int		("au_ulaw", filename, SF_FORMAT_AU, SF_FORMAT_ULAW, 0.04) ;
-		lcomp_test_double	("au_ulaw", filename, SF_FORMAT_AU, SF_FORMAT_ULAW, 0.04) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "au_alaw"))
-	{	filename = "test.au" ;
-		lcomp_test_short	("au_alaw", filename, SF_FORMAT_AU, SF_FORMAT_ALAW, 0.04) ;
-		lcomp_test_int		("au_alaw", filename, SF_FORMAT_AU, SF_FORMAT_ALAW, 0.04) ;
-		lcomp_test_double	("au_alaw", filename, SF_FORMAT_AU, SF_FORMAT_ALAW, 0.04) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "aule_ulaw"))
-	{	filename = "test.au" ;
-		lcomp_test_short	("aule_ulaw", filename, SF_FORMAT_AULE, SF_FORMAT_ULAW, 0.04) ;
-		lcomp_test_int		("aule_ulaw", filename, SF_FORMAT_AULE, SF_FORMAT_ULAW, 0.04) ;
-		lcomp_test_double	("aule_ulaw", filename, SF_FORMAT_AULE, SF_FORMAT_ULAW, 0.04) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "aule_alaw"))
-	{	filename = "test.au" ;
-		lcomp_test_short	("aule_alaw", filename, SF_FORMAT_AULE, SF_FORMAT_ALAW, 0.04) ;
-		lcomp_test_int		("aule_alaw", filename, SF_FORMAT_AULE, SF_FORMAT_ALAW, 0.04) ;
-		lcomp_test_double	("aule_alaw", filename, SF_FORMAT_AULE, SF_FORMAT_ALAW, 0.04) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "au_g721"))
-	{	filename = "test.au" ;
-		lcomp_test_short	("au_g721", filename, SF_FORMAT_AU, SF_FORMAT_G721_32, 0.05) ;
-		lcomp_test_int		("au_g721", filename, SF_FORMAT_AU, SF_FORMAT_G721_32, 0.05) ;
-		lcomp_test_double	("au_g721", filename, SF_FORMAT_AU, SF_FORMAT_G721_32, 0.05) ;
-
-		sdlcomp_test_short	("au_g721", filename, SF_FORMAT_AU, SF_FORMAT_G721_32, 0.05) ;
-		sdlcomp_test_int	("au_g721", filename, SF_FORMAT_AU, SF_FORMAT_G721_32, 0.05) ;
-		sdlcomp_test_double	("au_g721", filename, SF_FORMAT_AU, SF_FORMAT_G721_32, 0.05) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "aule_g721"))
-	{	filename = "test.au" ;
-		lcomp_test_short	("aule_g721", filename, SF_FORMAT_AULE, SF_FORMAT_G721_32, 0.05) ;
-		lcomp_test_int		("aule_g721", filename, SF_FORMAT_AULE, SF_FORMAT_G721_32, 0.05) ;
-		lcomp_test_double	("aule_g721", filename, SF_FORMAT_AULE, SF_FORMAT_G721_32, 0.05) ;
-		
-		sdlcomp_test_short	("aule_g721", filename, SF_FORMAT_AULE, SF_FORMAT_G721_32, 0.05) ;
-		sdlcomp_test_int	("aule_g721", filename, SF_FORMAT_AULE, SF_FORMAT_G721_32, 0.05) ;
-		sdlcomp_test_double	("aule_g721", filename, SF_FORMAT_AULE, SF_FORMAT_G721_32, 0.05) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "au_g723"))
-	{	filename = "test.au" ;
-		lcomp_test_short	("au_g723", filename, SF_FORMAT_AU, SF_FORMAT_G723_24, 0.15) ;
-		lcomp_test_int		("au_g723", filename, SF_FORMAT_AU, SF_FORMAT_G723_24, 0.15) ;
-		lcomp_test_double	("au_g723", filename, SF_FORMAT_AU, SF_FORMAT_G723_24, 0.15) ;
-		
-		sdlcomp_test_short	("au_g723", filename, SF_FORMAT_AU, SF_FORMAT_G723_24, 0.15) ;
-		sdlcomp_test_int	("au_g723", filename, SF_FORMAT_AU, SF_FORMAT_G723_24, 0.15) ;
-		sdlcomp_test_double	("au_g723", filename, SF_FORMAT_AU, SF_FORMAT_G723_24, 0.15) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "aule_g723"))
-	{	filename = "test.au" ;
-		lcomp_test_short	("aule_g723", filename, SF_FORMAT_AULE, SF_FORMAT_G723_24, 0.15) ;
-		lcomp_test_int		("aule_g723", filename, SF_FORMAT_AULE, SF_FORMAT_G723_24, 0.15) ;
-		lcomp_test_double	("aule_g723", filename, SF_FORMAT_AULE, SF_FORMAT_G723_24, 0.15) ;
-		
-		sdlcomp_test_short	("aule_g723", filename, SF_FORMAT_AULE, SF_FORMAT_G723_24, 0.15) ;
-		sdlcomp_test_int	("aule_g723", filename, SF_FORMAT_AULE, SF_FORMAT_G723_24, 0.15) ;
-		sdlcomp_test_double	("aule_g723", filename, SF_FORMAT_AULE, SF_FORMAT_G723_24, 0.15) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (nTests == 0)
-	{	printf ("************************************\n") ;
-		printf ("*  No '%s' test defined.\n", argv [1]) ;
-		printf ("************************************\n") ;
-		return 1 ;
-		} ;
-
-	return 0;
-} /* main */
-
-/*============================================================================================
-**	Here are the test functions.
-*/ 
- 
-static	
-void	lcomp_test_short (char *str, char *filename, int typemajor, int typeminor, double margin)
-{	SNDFILE			*file ;
-	SF_INFO			sfinfo ;
-	int				k, m, seekpos ;
-	unsigned int	datalen ;
-	short			*orig, *data ;
-
-	printf ("    lcomp_test_short    : %s ... ", str) ;
-	
-	datalen = BUFFER_SIZE ;
-
-	orig = (short*) orig_buffer ;
-	data = (short*) data_buffer ;
-	gen_signal (orig_buffer, datalen) ;
-	for (k = 0 ; k < datalen ; k++)
-		orig [k] = (short) (orig_buffer [k]) ;
-		
-	sfinfo.samplerate  = SAMPLE_RATE ;
-	sfinfo.samples     = 123456789 ;	/* Ridiculous value. */
-	sfinfo.channels    = 1 ;
-	sfinfo.pcmbitwidth = 16 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if ((k = sf_write_short (file, orig, datalen)) != datalen)
-	{	printf ("sf_write_short failed with short write (%d => %d).\n", datalen, k) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, datalen * sizeof (short)) ;
-	memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples < datalen)
-	{	printf ("Too few samples in file. (%d should be a little more than %d)\n", datalen, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples > (datalen + datalen/2))
-	{	printf ("Too many samples in file. (%d should be a little more than %d)\n", sfinfo.samples, datalen) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 1)
-	{	printf ("Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 16)
-	{	printf ("Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_read_short (file, data, datalen)) < 0.99 * datalen)
-	{	printf ("short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (k = 0 ; k < datalen ; k++)
-	{	if (error_function ((double) data [k], (double) orig [k], margin))
-		{	printf ("Incorrect sample A (#%d : %d should be %d).\n", k, data [k], orig [k]) ;
-			exit (1) ;
-			} ;
-		} ;
-
-	if ((k = sf_read_short (file, data, datalen)) != sfinfo.samples - datalen)
-	{	printf ("Incorrect read length A (%d should be %d).\n", sfinfo.samples - datalen, k) ;
-		exit (1) ;
-		} ;
-		
-	if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM)
-		for (k = 0 ; k < sfinfo.samples - datalen ; k++)
-			if (abs (data [k]) > decay_response (k))
-			{	printf ("Incorrect sample B (#%d : abs (%d) should be < %d).\n", datalen + k, data [k], decay_response (k)) ;
-				exit (1) ;
-				} ;
-
-	if (! sfinfo.seekable)
-	{	printf ("ok\n") ;
-		return ;
-		} ;
-
-	/* Now test sf_seek function. */
-	
-	if ((k = sf_seek (file, 0, SEEK_SET)) != 0)
-	{	printf ("Seek to start of file failed (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (m = 0 ; m < 3 ; m++)
-	{	if ((k = sf_read_short (file, data, datalen/7)) != datalen / 7)
-		{	printf ("Incorrect read length B (%d => %d).\n", datalen / 7, k) ;
-			exit (1) ;
-			} ;
-
-		for (k = 0 ; k < datalen/7 ; k++)
-			if (error_function ((double) data [k], (double) orig [k + m * (datalen / 7)], margin))
-			{	printf ("Incorrect sample C (#%d : %d => %d).\n", k + m * (datalen / 7), orig [k + m * (datalen / 7)], data [k]) ;
-				for (m = 0 ; m < 10 ; m++)
-					printf ("%d ", data [k]) ;
-				printf ("\n") ;
-				exit (1) ;
-				} ;
-		} ;
-
-	seekpos = BUFFER_SIZE / 10 ;
-	
-	/* Check seek from start of file. */
-	if ((k = sf_seek (file, seekpos, SEEK_SET)) != seekpos)
-	{	printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ;
-		exit (1) ;
-		} ;
-	if ((k = sf_read_short (file, data, 1)) != 1)
-	{	printf ("sf_read_short (file, data, 1) returned %d.\n", k) ;
-		exit (1) ;
-		} ;
-	
-	if (error_function ((double) data [0], (double) orig [seekpos], margin))
-	{	printf ("sf_seek (SEEK_SET) followed by sf_read_short failed (%d, %d).\n", orig [1], data [0]) ;
-		exit (1) ;
-		} ;
-	
-	if ((k = sf_seek (file, 0, SEEK_CUR)) != seekpos + 1)
-	{	printf ("sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", k, seekpos + 1) ;
-		exit (1) ;
-		} ;
-
-	seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
-	k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
-	sf_read_short (file, data, 1) ;
-	if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos)
-	{	printf ("sf_seek (forwards, SEEK_CUR) followed by sf_read_short failed (%d, %d) (%d, %d).\n", data [0], orig [seekpos], k, seekpos + 1) ;
-		exit (1) ;
-		} ;
-	
-	seekpos = sf_seek (file, 0, SEEK_CUR) - 20 ;
-	/* Check seek backward from current position. */
-	k = sf_seek (file, -20, SEEK_CUR) ;
-	sf_read_short (file, data, 1) ;
-	if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos)
-	{	printf ("sf_seek (backwards, SEEK_CUR) followed by sf_read_short failed (%d, %d) (%d, %d).\n", data [0], orig [seekpos], k, seekpos) ;
-		exit (1) ;
-		} ;
-	
-	/* Check that read past end of file returns number of items. */
-	sf_seek (file, (int) datalen, SEEK_SET) ;
-
- 	if ((k = sf_read_short (file, data, datalen)) != sfinfo.samples - datalen)
- 	{	printf ("Return value from sf_read_short past end of file incorrect (%d).\n", k) ;
- 		exit (1) ;
- 		} ;
-	
-	/* Check seek backward from end. */
-	if ((k = sf_seek (file, 5 - (int) sfinfo.samples, SEEK_END)) != 5)
-	{	printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
-		exit (1) ;
-		} ;
-
-	sf_read_short (file, data, 1) ;
-	if (error_function ((double) data [0], (double) orig [5], margin))
-	{	printf ("sf_seek (SEEK_END) followed by sf_read_short failed (%d should be %d).\n", data [0], orig [5]) ;
-		exit (1) ;
-		} ;
-
-	sf_close (file) ;
-
-	printf ("ok\n") ;
-} /* lcomp_test_short */
-
-/*--------------------------------------------------------------------------------------------
-*/ 
- 
-static	
-void	lcomp_test_int (char *str, char *filename, int typemajor, int typeminor, double margin)
-{	SNDFILE			*file ;
-	SF_INFO			sfinfo ;
-	int				k, m, seekpos ;
-	unsigned int	datalen ;
-	int				*orig, *data ;
-
-	printf ("    lcomp_test_int      : %s ... ", str) ;
-	
-	datalen = BUFFER_SIZE ;
-
-	data = (int*) data_buffer ;
-	orig = (int*) orig_buffer ;
-	gen_signal (orig_buffer, datalen) ;
-	for (k = 0 ; k < datalen ; k++)
-		orig [k] = (int) (orig_buffer [k]) ;
-		
-	sfinfo.samplerate  = SAMPLE_RATE ;
-	sfinfo.samples     = 123456789 ;	/* Ridiculous value. */
-	sfinfo.channels    = 1 ;
-	sfinfo.pcmbitwidth = 16 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if ((k = sf_write_int (file, orig, datalen)) != datalen)
-	{	printf ("sf_write_int failed with short write (%d => %d).\n", datalen, k) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, datalen * sizeof (short)) ;
-	memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples < datalen)
-	{	printf ("Too few samples in file. (%d should be a little more than %d)\n", datalen, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples > (datalen + datalen/2))
-	{	printf ("Too many samples in file. (%d should be a little more than %d)\n", datalen, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 1)
-	{	printf ("Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 16)
-	{	printf ("Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_read_int (file, data, datalen)) != datalen)
-	{	printf ("short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (k = 0 ; k < datalen ; k++)
-	{	if (error_function ((double) data [k], (double) orig [k], margin))
-		{	printf ("Incorrect sample A (#%d : %d should be %d).\n", k, data [k], orig [k]) ;
-			exit (1) ;
-			} ;
-		} ;
-
-	if ((k = sf_read_int (file, data, datalen)) != sfinfo.samples - datalen)
-	{	printf ("Incorrect read length A (%d should be %d).\n", sfinfo.samples - datalen, k) ;
-		exit (1) ;
-		} ;
-		
-	if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM)
-		for (k = 0 ; k < sfinfo.samples - datalen ; k++)
-			if (abs (data [k]) > decay_response (k))
-			{	printf ("Incorrect sample B (#%d : abs (%d) should be < %d).\n", datalen + k, data [k], decay_response (k)) ;
-				exit (1) ;
-				} ;
-
-	if (! sfinfo.seekable)
-	{	printf ("ok\n") ;
-		return ;
-		} ;
-
-	/* Now test sf_seek function. */
-	
-	if ((k = sf_seek (file, 0, SEEK_SET)) != 0)
-	{	printf ("Seek to start of file failed (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (m = 0 ; m < 3 ; m++)
-	{	if ((k = sf_read_int (file, data, datalen/7)) != datalen / 7)
-		{	printf ("Incorrect read length B (%d => %d).\n", datalen / 7, k) ;
-			exit (1) ;
-			} ;
-
-		for (k = 0 ; k < datalen/7 ; k++)
-			if (error_function ((double) data [k], (double) orig [k + m * (datalen / 7)], margin))
-			{	printf ("Incorrect sample C (#%d : %d => %d).\n", k + m * (datalen / 7), orig [k + m * (datalen / 7)], data [k]) ;
-				for (m = 0 ; m < 10 ; m++)
-					printf ("%d ", data [k]) ;
-				printf ("\n") ;
-				exit (1) ;
-				} ;
-		} ;
-
-	seekpos = BUFFER_SIZE / 10 ;
-	
-	/* Check seek from start of file. */
-	if ((k = sf_seek (file, seekpos, SEEK_SET)) != seekpos)
-	{	printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ;
-		exit (1) ;
-		} ;
-	if ((k = sf_read_int (file, data, 1)) != 1)
-	{	printf ("sf_read_int (file, data, 1) returned %d.\n", k) ;
-		exit (1) ;
-		} ;
-	
-	if (error_function ((double) data [0], (double) orig [seekpos], margin))
-	{	printf ("sf_seek (SEEK_SET) followed by sf_read_int failed (%d, %d).\n", orig [1], data [0]) ;
-		exit (1) ;
-		} ;
-	
-	if ((k = sf_seek (file, 0, SEEK_CUR)) != seekpos + 1)
-	{	printf ("sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", k, seekpos + 1) ;
-		exit (1) ;
-		} ;
-
-	seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
-	k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
-	sf_read_int (file, data, 1) ;
-	if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos)
-	{	printf ("sf_seek (forwards, SEEK_CUR) followed by sf_read_int failed (%d, %d) (%d, %d).\n", data [0], orig [seekpos], k, seekpos + 1) ;
-		exit (1) ;
-		} ;
-	
-	seekpos = sf_seek (file, 0, SEEK_CUR) - 20 ;
-	/* Check seek backward from current position. */
-	k = sf_seek (file, -20, SEEK_CUR) ;
-	sf_read_int (file, data, 1) ;
-	if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos)
-	{	printf ("sf_seek (backwards, SEEK_CUR) followed by sf_read_int failed (%d, %d) (%d, %d).\n", data [0], orig [seekpos], k, seekpos) ;
-		exit (1) ;
-		} ;
-	
-	/* Check that read past end of file returns number of items. */
-	sf_seek (file, (int) datalen, SEEK_SET) ;
-
- 	if ((k = sf_read_int (file, data, datalen)) != sfinfo.samples - datalen)
- 	{	printf ("Return value from sf_read_int past end of file incorrect (%d).\n", k) ;
- 		exit (1) ;
- 		} ;
-	
-	/* Check seek backward from end. */
-	if ((k = sf_seek (file, 5 - (int) sfinfo.samples, SEEK_END)) != 5)
-	{	printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
-		exit (1) ;
-		} ;
-
-	sf_read_int (file, data, 1) ;
-	if (error_function ((double) data [0], (double) orig [5], margin))
-	{	printf ("sf_seek (SEEK_END) followed by sf_read_short failed (%d should be %d).\n", data [0], orig [5]) ;
-		exit (1) ;
-		} ;
-
-	sf_close (file) ;
-
-	printf ("ok\n") ;
-} /* lcomp_test_int */
-
-/*--------------------------------------------------------------------------------------------
-*/ 
-
-static	
-void	lcomp_test_double (char *str, char *filename, int typemajor, int typeminor, double margin)
-{	SNDFILE			*file ;
-	SF_INFO			sfinfo ;
-	int				k, m, seekpos ;
-	unsigned int	datalen ;
-	double			*orig, *data ;
-
-	printf ("    lcomp_test_double   : %s ... ", str) ;
-	
-	datalen = BUFFER_SIZE ;
-
-	orig = (double*) orig_buffer ;
-	data = (double*) data_buffer ;
-	gen_signal (orig_buffer, datalen) ;
-		
-	sfinfo.samplerate  = SAMPLE_RATE ;
-	sfinfo.samples     = 123456789 ;	/* Ridiculous value. */
-	sfinfo.channels    = 1 ;
-	sfinfo.pcmbitwidth = 16 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if ((k = sf_write_double (file, orig, datalen, 0)) != datalen)
-	{	printf ("sf_write_double failed with double write (%d => %d).\n", datalen, k) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, datalen * sizeof (double)) ;
-	memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples < datalen)
-	{	printf ("Too few samples in file. (%d should be a little more than %d)\n", datalen, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples > (datalen + datalen/2))
-	{	printf ("Too many samples in file. (%d should be a little more than %d)\n", datalen, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 1)
-	{	printf ("Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 16)
-	{	printf ("Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_read_double (file, data, datalen, 0)) != datalen)
-	{	printf ("double read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (k = 0 ; k < datalen ; k++)
-		if (error_function (data [k], orig [k], margin))
-		{	printf ("Incorrect sample A (#%d : %f should be %f).\n", k, data [k], orig [k]) ;
-			exit (1) ;
-			} ;
-
-	if ((k = sf_read_double (file, data, datalen, 0)) != sfinfo.samples - datalen)
-	{	printf ("Incorrect read length A (%d should be %d).\n", sfinfo.samples - datalen, k) ;
-		exit (1) ;
-		} ;
-		
-	if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM)
-		for (k = 0 ; k < sfinfo.samples - datalen ; k++)
-			if (abs ((int) data [k]) > decay_response (k))
-			{	printf ("Incorrect sample B (#%d : abs (%d) should be < %d).\n", datalen + k, (int) data [k], decay_response (k)) ;
-				exit (1) ;
-				} ;
-
-	if (! sfinfo.seekable)
-	{	printf ("ok\n") ;
-		return ;
-		} ;
-
-	/* Now test sf_seek function. */
-	
-	if ((k = sf_seek (file, 0, SEEK_SET)) != 0)
-	{	printf ("Seek to start of file failed (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (m = 0 ; m < 3 ; m++)
-	{	if ((k = sf_read_double (file, data, datalen/7, 0)) != datalen / 7)
-		{	printf ("Incorrect read length B (%d => %d).\n", datalen / 7, k) ;
-			exit (1) ;
-			} ;
-
-		for (k = 0 ; k < datalen/7 ; k++)
-			if (error_function (data [k], orig [k + m * (datalen / 7)], margin))
-			{	printf ("Incorrect sample C (#%d : %d => %d).\n", k + m * (datalen / 7), (int) orig [k + m * (datalen / 7)], (int) data [k]) ;
-				for (m = 0 ; m < 10 ; m++)
-					printf ("%d ", (int) data [k]) ;
-				printf ("\n") ;
-				exit (1) ;
-				} ;
-		} ;
-
-	seekpos = BUFFER_SIZE / 10 ;
-	
-	/* Check seek from start of file. */
-	if ((k = sf_seek (file, seekpos, SEEK_SET)) != seekpos)
-	{	printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ;
-		exit (1) ;
-		} ;
-	if ((k = sf_read_double (file, data, 1, 0)) != 1)
-	{	printf ("sf_read_double (file, data, 1, 0) returned %d.\n", k) ;
-		exit (1) ;
-		} ;
-	
-	if (error_function ((double) data [0], (double) orig [seekpos], margin))
-	{	printf ("sf_seek (SEEK_SET) followed by sf_read_double failed (%d, %d).\n", (int) orig [1], (int) data [0]) ;
-		exit (1) ;
-		} ;
-	
-	if ((k = sf_seek (file, 0, SEEK_CUR)) != seekpos + 1)
-	{	printf ("sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", k, seekpos + 1) ;
-		exit (1) ;
-		} ;
-
-	seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
-	k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
-	sf_read_double (file, data, 1, 0) ;
-	if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos)
-	{	printf ("sf_seek (forwards, SEEK_CUR) followed by sf_read_double failed (%d, %d) (%d, %d).\n", (int) data [0], (int) orig [seekpos], k, seekpos + 1) ;
-		exit (1) ;
-		} ;
-	
-	seekpos = sf_seek (file, 0, SEEK_CUR) - 20 ;
-	/* Check seek backward from current position. */
-	k = sf_seek (file, -20, SEEK_CUR) ;
-	sf_read_double (file, data, 1, 0) ;
-	if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos)
-	{	printf ("sf_seek (backwards, SEEK_CUR) followed by sf_read_double failed (%d, %d) (%d, %d).\n", (int) data [0], (int) orig [seekpos], k, seekpos) ;
-		exit (1) ;
-		} ;
-	
-	/* Check that read past end of file returns number of items. */
-	sf_seek (file, (int) datalen, SEEK_SET) ;
-
- 	if ((k = sf_read_double (file, data, datalen, 0)) != sfinfo.samples - datalen)
- 	{	printf ("Return value from sf_read_double past end of file incorrect (%d).\n", k) ;
- 		exit (1) ;
- 		} ;
-	
-	/* Check seek backward from end. */
-	if ((k = sf_seek (file, 5 - (int) sfinfo.samples, SEEK_END)) != 5)
-	{	printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
-		exit (1) ;
-		} ;
-
-	sf_read_double (file, data, 1, 0) ;
-	if (error_function (data [0], orig [5], margin))
-	{	printf ("sf_seek (SEEK_END) followed by sf_read_double failed (%d, %d).\n", (int) data [0], (int) orig [5]) ;
-		exit (1) ;
-		} ;
-
-	sf_close (file) ;
-
-	printf ("ok\n") ;
-} /* lcomp_test_double */
-
-/*========================================================================================
-**	Smoothed differential loss compression tests.
-*/
-
-static	
-void	sdlcomp_test_short	(char *str, char *filename, int typemajor, int typeminor, double margin)
-{	SNDFILE			*file ;
-	SF_INFO			sfinfo ;
-	int				k, m, seekpos ;
-	unsigned int	datalen ;
-	short			*orig, *data, *smooth ;
-
-	printf ("    sdlcomp_test_short  : %s ... ", str) ;
-	
-	datalen = BUFFER_SIZE ;
-
-	orig = (short*) orig_buffer ;
-	data = (short*) data_buffer ;
-	smooth = (short*) smooth_buffer ;
-
-	gen_signal (orig_buffer, datalen) ;
-	for (k = 0 ; k < datalen ; k++)
-		orig [k] = (short) (orig_buffer [k]) ;
-		
-	sfinfo.samplerate  = SAMPLE_RATE ;
-	sfinfo.samples     = 123456789 ;	/* Ridiculous value. */
-	sfinfo.channels    = 1 ;
-	sfinfo.pcmbitwidth = 16 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if ((k = sf_write_short (file, orig, datalen)) != datalen)
-	{	printf ("sf_write_short failed with short write (%d => %d).\n", datalen, k) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, datalen * sizeof (short)) ;
-	memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples < datalen)
-	{	printf ("Too few samples in file. (%d should be a little more than %d)\n", datalen, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples > (datalen + 400))
-	{	printf ("Too many samples in file. (%d should be a little more than %d)\n", sfinfo.samples, datalen) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 1)
-	{	printf ("Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 16)
-	{	printf ("Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_read_short (file, data, datalen)) != datalen)
-	{	printf ("short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	memcpy (smooth, orig, datalen * sizeof (short)) ;
-	smoothed_diff_short (data, datalen) ;
-	smoothed_diff_short (smooth, datalen) ;
-
-	for (k = 1 ; k < datalen ; k++)
-	{	if (error_function ((double) data [k], (double) smooth [k], margin))
-		{	printf ("Incorrect sample A (#%d : %d should be %d).\n", k, data [k], smooth [k]) ;
-			exit (1) ;
-			} ;
-		} ;
-
-	if ((k = sf_read_short (file, data, datalen)) != sfinfo.samples - datalen)
-	{	printf ("Incorrect read length A (%d should be %d).\n", k, sfinfo.samples - datalen) ;
-		exit (1) ;
-		} ;
-		
-	if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM &&
-		(sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_GSM610)
-		for (k = 0 ; k < sfinfo.samples - datalen ; k++)
-			if (abs (data [k]) > decay_response (k))
-			{	printf ("Incorrect sample B (#%d : abs (%d) should be < %d).\n", datalen + k, data [k], decay_response (k)) ;
-				exit (1) ;
-				} ;
-
-	/* Now test sf_seek function. */
-	if (sfinfo.seekable)
-	{	if ((k = sf_seek (file, 0, SEEK_SET)) != 0)
-		{	printf ("Seek to start of file failed (%d).\n", k) ;
-			exit (1) ;
-			} ;
-	
-		for (m = 0 ; m < 3 ; m++)
-		{	if ((k = sf_read_short (file, data, datalen/7)) != datalen / 7)
-			{	printf ("Incorrect read length B (%d => %d).\n", datalen / 7, k) ;
-				exit (1) ;
-				} ;
-	
-			smoothed_diff_short (data, datalen/7) ;
-			memcpy (smooth, orig + m * datalen/7, datalen/7 * sizeof (short)) ;
-			smoothed_diff_short (smooth, datalen/7) ;
-			
-			for (k = 0 ; k < datalen/7 ; k++)
-				if (error_function ((double) data [k], (double) smooth [k], margin))
-				{	printf ("Incorrect sample C (#%d (%d) : %d => %d).\n", k, k + m * (datalen / 7), smooth [k], data [k]) ;
-					for (m = 0 ; m < 10 ; m++)
-						printf ("%d ", data [k]) ;
-					printf ("\n") ;
-					exit (1) ;
-					} ;
-			} ; /* for (m = 0 ; m < 3 ; m++) */
-	
-		seekpos = BUFFER_SIZE / 10 ;
-		
-		/* Check seek from start of file. */
-		if ((k = sf_seek (file, seekpos, SEEK_SET)) != seekpos)
-		{	printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ;
-			exit (1) ;
-			} ;
-		if ((k = sf_read_short (file, data, 1)) != 1)
-		{	printf ("sf_read_short (file, data, 1) returned %d.\n", k) ;
-			exit (1) ;
-			} ;
-		
-		if (error_function ((double) data [0], (double) orig [seekpos], margin))
-		{	printf ("sf_seek (SEEK_SET) followed by sf_read_short failed (%d, %d).\n", orig [1], data [0]) ;
-			exit (1) ;
-			} ;
-		
-		if ((k = sf_seek (file, 0, SEEK_CUR)) != seekpos + 1)
-		{	printf ("sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", k, seekpos + 1) ;
-			exit (1) ;
-			} ;
-	
-		seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
-		k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
-		sf_read_short (file, data, 1) ;
-		if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos)
-		{	printf ("sf_seek (forwards, SEEK_CUR) followed by sf_read_short failed (%d, %d) (%d, %d).\n", data [0], orig [seekpos], k, seekpos + 1) ;
-			exit (1) ;
-			} ;
-		
-		seekpos = sf_seek (file, 0, SEEK_CUR) - 20 ;
-		/* Check seek backward from current position. */
-		k = sf_seek (file, -20, SEEK_CUR) ;
-		sf_read_short (file, data, 1) ;
-		if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos)
-		{	printf ("sf_seek (backwards, SEEK_CUR) followed by sf_read_short failed (%d, %d) (%d, %d).\n", data [0], orig [seekpos], k, seekpos) ;
-			exit (1) ;
-			} ;
-		
-		/* Check that read past end of file returns number of items. */
-		sf_seek (file, (int) datalen, SEEK_SET) ;
-	
-	 	if ((k = sf_read_short (file, data, datalen)) != sfinfo.samples - datalen)
-	 	{	printf ("Return value from sf_read_short past end of file incorrect (%d).\n", k) ;
-	 		exit (1) ;
-	 		} ;
-		
-		/* Check seek backward from end. */
-		
-		if ((k = sf_seek (file, 5 - (int) sfinfo.samples, SEEK_END)) != 5)
-		{	printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
-			exit (1) ;
-			} ;
-	
-		sf_read_short (file, data, 1) ;
-		if (error_function ((double) data [0], (double) orig [5], margin))
-		{	printf ("sf_seek (SEEK_END) followed by sf_read_short failed (%d should be %d).\n", data [0], orig [5]) ;
-			exit (1) ;
-			} ;
-		} /* if (sfinfo.seekable) */
-
-	sf_close (file) ;
-
-	printf ("ok\n") ;
-} /* sdlcomp_test_short */
-
-static	
-void	sdlcomp_test_int	(char *str, char *filename, int typemajor, int typeminor, double margin)
-{	SNDFILE			*file ;
-	SF_INFO			sfinfo ;
-	int				k, m, seekpos ;
-	unsigned int	datalen ;
-	int			*orig, *data, *smooth ;
-
-	printf ("    sdlcomp_test_int    : %s ... ", str) ;
-	
-	datalen = BUFFER_SIZE ;
-
-	orig = (int*) orig_buffer ;
-	data = (int*) data_buffer ;
-	smooth = (int*) smooth_buffer ;
-
-	gen_signal (orig_buffer, datalen) ;
-	for (k = 0 ; k < datalen ; k++)
-		orig [k] = (int) (orig_buffer [k]) ;
-		
-	sfinfo.samplerate  = SAMPLE_RATE ;
-	sfinfo.samples     = 123456789 ;	/* Ridiculous value. */
-	sfinfo.channels    = 1 ;
-	sfinfo.pcmbitwidth = 16 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if ((k = sf_write_int (file, orig, datalen)) != datalen)
-	{	printf ("sf_write_int failed with int write (%d => %d).\n", datalen, k) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, datalen * sizeof (int)) ;
-	memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples < datalen)
-	{	printf ("Too few samples in file. (%d should be a little more than %d)\n", datalen, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples > (datalen + 400))
-	{	printf ("Too many samples in file. (%d should be a little more than %d)\n", sfinfo.samples, datalen) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 1)
-	{	printf ("Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 16)
-	{	printf ("Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_read_int (file, data, datalen)) != datalen)
-	{	printf ("int read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	memcpy (smooth, orig, datalen * sizeof (int)) ;
-	smoothed_diff_int (data, datalen) ;
-	smoothed_diff_int (smooth, datalen) ;
-
-	for (k = 1 ; k < datalen ; k++)
-	{	if (error_function ((double) data [k], (double) smooth [k], margin))
-		{	printf ("Incorrect sample A (#%d : %d should be %d).\n", k, data [k], smooth [k]) ;
-			exit (1) ;
-			} ;
-		} ;
-
-	if ((k = sf_read_int (file, data, datalen)) != sfinfo.samples - datalen)
-	{	printf ("Incorrect read length A (%d should be %d).\n", k, sfinfo.samples - datalen) ;
-		exit (1) ;
-		} ;
-		
-	if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM &&
-		(sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_GSM610)
-		for (k = 0 ; k < sfinfo.samples - datalen ; k++)
-			if (abs (data [k]) > decay_response (k))
-			{	printf ("Incorrect sample B (#%d : abs (%d) should be < %d).\n", datalen + k, data [k], decay_response (k)) ;
-				exit (1) ;
-				} ;
-
-	/* Now test sf_seek function. */
-	if (sfinfo.seekable)
-	{	if ((k = sf_seek (file, 0, SEEK_SET)) != 0)
-		{	printf ("Seek to start of file failed (%d).\n", k) ;
-			exit (1) ;
-			} ;
-	
-		for (m = 0 ; m < 3 ; m++)
-		{	if ((k = sf_read_int (file, data, datalen/7)) != datalen / 7)
-			{	printf ("Incorrect read length B (%d => %d).\n", datalen / 7, k) ;
-				exit (1) ;
-				} ;
-	
-			smoothed_diff_int (data, datalen/7) ;
-			memcpy (smooth, orig + m * datalen/7, datalen/7 * sizeof (int)) ;
-			smoothed_diff_int (smooth, datalen/7) ;
-			
-			for (k = 0 ; k < datalen/7 ; k++)
-				if (error_function ((double) data [k], (double) smooth [k], margin))
-				{	printf ("Incorrect sample C (#%d (%d) : %d => %d).\n", k, k + m * (datalen / 7), smooth [k], data [k]) ;
-					for (m = 0 ; m < 10 ; m++)
-						printf ("%d ", data [k]) ;
-					printf ("\n") ;
-					exit (1) ;
-					} ;
-			} ; /* for (m = 0 ; m < 3 ; m++) */
-	
-		seekpos = BUFFER_SIZE / 10 ;
-		
-		/* Check seek from start of file. */
-		if ((k = sf_seek (file, seekpos, SEEK_SET)) != seekpos)
-		{	printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ;
-			exit (1) ;
-			} ;
-		if ((k = sf_read_int (file, data, 1)) != 1)
-		{	printf ("sf_read_int (file, data, 1) returned %d.\n", k) ;
-			exit (1) ;
-			} ;
-		
-		if (error_function ((double) data [0], (double) orig [seekpos], margin))
-		{	printf ("sf_seek (SEEK_SET) followed by sf_read_int failed (%d, %d).\n", orig [1], data [0]) ;
-			exit (1) ;
-			} ;
-		
-		if ((k = sf_seek (file, 0, SEEK_CUR)) != seekpos + 1)
-		{	printf ("sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", k, seekpos + 1) ;
-			exit (1) ;
-			} ;
-	
-		seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
-		k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
-		sf_read_int (file, data, 1) ;
-		if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos)
-		{	printf ("sf_seek (forwards, SEEK_CUR) followed by sf_read_int failed (%d, %d) (%d, %d).\n", data [0], orig [seekpos], k, seekpos + 1) ;
-			exit (1) ;
-			} ;
-		
-		seekpos = sf_seek (file, 0, SEEK_CUR) - 20 ;
-		/* Check seek backward from current position. */
-		k = sf_seek (file, -20, SEEK_CUR) ;
-		sf_read_int (file, data, 1) ;
-		if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos)
-		{	printf ("sf_seek (backwards, SEEK_CUR) followed by sf_read_int failed (%d, %d) (%d, %d).\n", data [0], orig [seekpos], k, seekpos) ;
-			exit (1) ;
-			} ;
-		
-		/* Check that read past end of file returns number of items. */
-		sf_seek (file, (int) datalen, SEEK_SET) ;
-	
-	 	if ((k = sf_read_int (file, data, datalen)) != sfinfo.samples - datalen)
-	 	{	printf ("Return value from sf_read_int past end of file incorrect (%d).\n", k) ;
-	 		exit (1) ;
-	 		} ;
-		
-		/* Check seek backward from end. */
-		
-		if ((k = sf_seek (file, 5 - (int) sfinfo.samples, SEEK_END)) != 5)
-		{	printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
-			exit (1) ;
-			} ;
-	
-		sf_read_int (file, data, 1) ;
-		if (error_function ((double) data [0], (double) orig [5], margin))
-		{	printf ("sf_seek (SEEK_END) followed by sf_read_int failed (%d should be %d).\n", data [0], orig [5]) ;
-			exit (1) ;
-			} ;
-		} /* if (sfinfo.seekable) */
-
-	sf_close (file) ;
-
-	printf ("ok\n") ;
-} /* sdlcomp_test_int */
-
-static	
-void	sdlcomp_test_double	(char *str, char *filename, int typemajor, int typeminor, double margin)
-{	SNDFILE			*file ;
-	SF_INFO			sfinfo ;
-	int				k, m, seekpos ;
-	unsigned int	datalen ;
-	double			*orig, *data, *smooth ;
-
-	printf ("    sdlcomp_test_double : %s ... ", str) ;
-	
-	datalen = BUFFER_SIZE ;
-
-	orig = orig_buffer ;
-	data = data_buffer ;
-	smooth = smooth_buffer ;
-
-	gen_signal (orig_buffer, datalen) ;
-		
-	sfinfo.samplerate  = SAMPLE_RATE ;
-	sfinfo.samples     = 123456789 ;	/* Ridiculous value. */
-	sfinfo.channels    = 1 ;
-	sfinfo.pcmbitwidth = 16 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if ((k = sf_write_double (file, orig, datalen, 0)) != datalen)
-	{	printf ("sf_write_double failed with int write (%d => %d).\n", datalen, k) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, datalen * sizeof (double)) ;
-	memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples < datalen)
-	{	printf ("Too few samples in file. (%d should be a little more than %d)\n", datalen, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples > (datalen + 400))
-	{	printf ("Too many samples in file. (%d should be a little more than %d)\n", sfinfo.samples, datalen) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 1)
-	{	printf ("Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 16)
-	{	printf ("Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_read_double (file, data, datalen, 0)) != datalen)
-	{	printf ("int read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	memcpy (smooth, orig, datalen * sizeof (double)) ;
-	smoothed_diff_double (data, datalen) ;
-	smoothed_diff_double (smooth, datalen) ;
-
-	for (k = 1 ; k < datalen ; k++)
-	{	if (error_function (data [k], smooth [k], margin))
-		{	printf ("Incorrect sample A (#%d : %d should be %d).\n", k, (int) data [k], (int) smooth [k]) ;
-			exit (1) ;
-			} ;
-		} ;
-
-	if ((k = sf_read_double (file, data, datalen, 0)) != sfinfo.samples - datalen)
-	{	printf ("Incorrect read length A (%d should be %d).\n", k, sfinfo.samples - datalen) ;
-		exit (1) ;
-		} ;
-		
-	if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM &&
-		(sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_GSM610)
-		for (k = 0 ; k < sfinfo.samples - datalen ; k++)
-			if (abs (data [k]) > decay_response (k))
-			{	printf ("Incorrect sample B (#%d : abs (%d) should be < %d).\n", datalen + k, (int) data [k], (int) decay_response (k)) ;
-				exit (1) ;
-				} ;
-
-	/* Now test sf_seek function. */
-	if (sfinfo.seekable)
-	{	if ((k = sf_seek (file, 0, SEEK_SET)) != 0)
-		{	printf ("Seek to start of file failed (%d).\n", k) ;
-			exit (1) ;
-			} ;
-	
-		for (m = 0 ; m < 3 ; m++)
-		{	if ((k = sf_read_double (file, data, datalen/7, 0)) != datalen / 7)
-			{	printf ("Incorrect read length B (%d => %d).\n", datalen / 7, k) ;
-				exit (1) ;
-				} ;
-	
-			smoothed_diff_double (data, datalen/7) ;
-			memcpy (smooth, orig + m * datalen/7, datalen/7 * sizeof (double)) ;
-			smoothed_diff_double (smooth, datalen/7) ;
-			
-			for (k = 0 ; k < datalen/7 ; k++)
-				if (error_function ((double) data [k], (double) smooth [k], margin))
-				{	printf ("Incorrect sample C (#%d (%d) : %d => %d).\n", k, k + m * (datalen / 7), (int) smooth [k], (int) data [k]) ;
-					for (m = 0 ; m < 10 ; m++)
-						printf ("%d ", (int) data [k]) ;
-					printf ("\n") ;
-					exit (1) ;
-					} ;
-			} ; /* for (m = 0 ; m < 3 ; m++) */
-	
-		seekpos = BUFFER_SIZE / 10 ;
-		
-		/* Check seek from start of file. */
-		if ((k = sf_seek (file, seekpos, SEEK_SET)) != seekpos)
-		{	printf ("Seek to start of file + %d failed (%d).\n", seekpos, k) ;
-			exit (1) ;
-			} ;
-		if ((k = sf_read_double (file, data, 1, 0)) != 1)
-		{	printf ("sf_read_double (file, data, 1) returned %d.\n", k) ;
-			exit (1) ;
-			} ;
-		
-		if (error_function ((double) data [0], (double) orig [seekpos], margin))
-		{	printf ("sf_seek (SEEK_SET) followed by sf_read_double failed (%d, %d).\n", (int) orig [1], (int) data [0]) ;
-			exit (1) ;
-			} ;
-		
-		if ((k = sf_seek (file, 0, SEEK_CUR)) != seekpos + 1)
-		{	printf ("sf_seek (SEEK_CUR) with 0 offset failed (%d should be %d)\n", k, seekpos + 1) ;
-			exit (1) ;
-			} ;
-	
-		seekpos = sf_seek (file, 0, SEEK_CUR) + BUFFER_SIZE / 5 ;
-		k = sf_seek (file, BUFFER_SIZE / 5, SEEK_CUR) ;
-		sf_read_double (file, data, 1, 0) ;
-		if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos)
-		{	printf ("sf_seek (forwards, SEEK_CUR) followed by sf_read_double failed (%d, %d) (%d, %d).\n", (int) data [0], (int) orig [seekpos], k, seekpos + 1) ;
-			exit (1) ;
-			} ;
-		
-		seekpos = sf_seek (file, 0, SEEK_CUR) - 20 ;
-		/* Check seek backward from current position. */
-		k = sf_seek (file, -20, SEEK_CUR) ;
-		sf_read_double (file, data, 1, 0) ;
-		if (error_function ((double) data [0], (double) orig [seekpos], margin) || k != seekpos)
-		{	printf ("sf_seek (backwards, SEEK_CUR) followed by sf_read_double failed (%d, %d) (%d, %d).\n", (int) data [0], (int) orig [seekpos], k, seekpos) ;
-			exit (1) ;
-			} ;
-		
-		/* Check that read past end of file returns number of items. */
-		sf_seek (file, (int) datalen, SEEK_SET) ;
-	
-	 	if ((k = sf_read_double (file, data, datalen, 0)) != sfinfo.samples - datalen)
-	 	{	printf ("Return value from sf_read_double past end of file incorrect (%d).\n", k) ;
-	 		exit (1) ;
-	 		} ;
-		
-		/* Check seek backward from end. */
-		
-		if ((k = sf_seek (file, 5 - (int) sfinfo.samples, SEEK_END)) != 5)
-		{	printf ("sf_seek (SEEK_END) returned %d instead of %d.\n", k, 5) ;
-			exit (1) ;
-			} ;
-	
-		sf_read_double (file, data, 1, 0) ;
-		if (error_function ((double) data [0], (double) orig [5], margin))
-		{	printf ("sf_seek (SEEK_END) followed by sf_read_double failed (%d should be %d).\n", (int) data [0], (int) orig [5]) ;
-			exit (1) ;
-			} ;
-		} /* if (sfinfo.seekable) */
-
-	sf_close (file) ;
-
-	printf ("ok\n") ;
-} /* sdlcomp_test_double */
-
-/*========================================================================================
-**	Auxiliary functions
-*/
-
-static
-int decay_response (int k)
-{	if (k < 1)
-		return ((int) 30000.0) ;
-	return (int) (30000.0 / (0.5 * k * k)) ;
-} /* decay_response */
-
-static
-void	gen_signal (double *data, unsigned int datalen)
-{	unsigned int k, ramplen ;
-	double	amp = 0.0 ;
-	
-	ramplen = datalen / 20 ;
-
-	for (k = 0 ; k < datalen ; k++)
-	{	if (k <= ramplen)
-			amp = 30000.0 * k / ((double) ramplen) ;
-		else if (k > datalen - ramplen)
-			amp = 30000.0 * (datalen - k) / ((double) ramplen) ;
-		data [k] = amp * (0.4 * sin (33.3 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE))
-							+ 0.3 * cos (201.1 * 2.0 * M_PI * ((double) (k+1)) / ((double) SAMPLE_RATE))) ;
-		} ;
-	return ;
-} /* gen_signal */
-
-static
-int error_function (double data, double orig, double margin)
-{	double error ;
-
-	if (fabs (orig) <= 500.0)
-		error = fabs (fabs (data) - fabs(orig)) / 2000.0 ;
-	else if (fabs (orig) <= 1000.0)
-		error = fabs (data - orig) / 3000.0 ;
-	else
-		error = fabs (data - orig) / fabs (orig) ;
-		
-	if (error > margin)
-	{	printf ("\n\n*******************\nError : %f\n", error) ;
-		return 1 ;
-		} ;
-	return 0 ;
-} /* error_function */
-
-static	
-void	smoothed_diff_short (short *data, unsigned int datalen)
-{	unsigned int k ;
-	double memory = 0.0 ;
-
-	/* Calculate the smoothed sample-to-sample difference. */
-	for (k = 0 ; k < datalen - 1 ; k++)
-	{	memory = 0.7 * memory + (1 - 0.7) * (double) (data [k+1] - data [k]) ;
-		data [k] = (short) memory ;
-		} ;
-	data [datalen-1] = data [datalen-2] ;
-	
-} /* smoothed_diff_short */
-
-static	
-void	smoothed_diff_int (int *data, unsigned int datalen)
-{	unsigned int k ;
-	double memory = 0.0 ;
-
-	/* Calculate the smoothed sample-to-sample difference. */
-	for (k = 0 ; k < datalen - 1 ; k++)
-	{	memory = 0.7 * memory + (1 - 0.7) * (double) (data [k+1] - data [k]) ;
-		data [k] = (int) memory ;
-		} ;
-	data [datalen-1] = data [datalen-2] ;
-	
-} /* smoothed_diff_int */
-
-static	
-void	smoothed_diff_double (double *data, unsigned int datalen)
-{	unsigned int k ;
-	double memory = 0.0 ;
-
-	/* Calculate the smoothed sample-to-sample difference. */
-	for (k = 0 ; k < datalen - 1 ; k++)
-	{	memory = 0.7 * memory + (1 - 0.7) * (data [k+1] - data [k]) ;
-		data [k] = memory ;
-		} ;
-	data [datalen-1] = data [datalen-2] ;
-	
-} /* smoothed_diff_double */
--- a/common/libsndfile/tests/read_seek_test.c
+++ /dev/null
@@ -1,627 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-
-#include	<stdio.h>
-#include	<unistd.h>
-#include	<sys/stat.h>
-#include	<fcntl.h>
-
-#include	<sndfile.h>
-
-static	unsigned char  wav_ieee [] =
-{	0x52, 0x49, 0x46, 0x46, 0x64, 0x00, 0x00, 0x00, 
-	0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74, 0x20,
-	0x10, 0x00, 0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 
-	0x34, 0x12, 0x00, 0x00, 0xD0, 0x48, 0x00, 0x00,
-	0x04, 0x00, 0x20, 0x00, 0x64, 0x61, 0x74, 0x61, 
-	0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x40, 
-	0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x80, 0x40,
-	0x00, 0x00, 0xA0, 0x40, 0x00, 0x00, 0xC0, 0x40, 
-	0x00, 0x00, 0xE0, 0x40, 0x00, 0x00, 0x00, 0x41,
-	0x00, 0x00, 0x10, 0x41, 0x00, 0x00, 0x20, 0x41, 
-	0x00, 0x00, 0x30, 0x41, 0x00, 0x00, 0x40, 0x41,
-	0x00, 0x00, 0x50, 0x41, 0x00, 0x00, 0x60, 0x41, 
-	0x00, 0x00, 0x70, 0x41, 0x49, 0x4E, 0x46, 0x4F,
-	0x04, 0x00, 0x00, 0x00, 0xFE, 0xED, 0xC0, 0xDE
-} ; /* wav_ieee */
-
-static	unsigned char  wav_pcm32 [] =
-{	0x52, 0x49, 0x46, 0x46, 0x64, 0x00, 0x00, 0x00, 
-	0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74, 0x20,
-	0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 
-	0x34, 0x12, 0x00, 0x00, 0xD0, 0x48, 0x00, 0x00,
-	0x04, 0x00, 0x20, 0x00, 0x64, 0x61, 0x74, 0x61, 
-	0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 
-	0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
-	0x05, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 
-	0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
-	0x09, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 
-	0x0B, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00,
-	0x0D, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 
-	0x0F, 0x00, 0x00, 0x00, 0x49, 0x4E, 0x46, 0x4F,
-	0x04, 0x00, 0x00, 0x00, 0xFE, 0xED, 0xC0, 0xDE
-} ; /* wav_pcm32 */
-
-static	unsigned char  wav_pcm24 [] =
-{	0x52, 0x49, 0x46, 0x46, 0x54, 0x00, 0x00, 0x00, 
-	0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74, 0x20,
-	0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 
-	0x34, 0x12, 0x00, 0x00, 0x9C, 0x36, 0x00, 0x00, 
-	0x03, 0x00, 0x18, 0x00, 0x64, 0x61, 0x74, 0x61, 
-	0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 
-	0x00, 0x00, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 
-	0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x06, 0x00, 
-	0x00, 0x07, 0x00, 0x00, 0x08, 0x00, 0x00, 0x09, 
-	0x00, 0x00, 0x0A, 0x00, 0x00, 0x0B, 0x00, 0x00, 
-	0x0C, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x0E, 0x00, 
-	0x00, 0x0F, 0x00, 0x00, 0x49, 0x4E, 0x46, 0x4F,
-	0x04, 0x00, 0x00, 0x00, 0xFE, 0xED, 0xC0, 0xDE
-} ; /* wav_pcm24 */
-
-static	unsigned char  wav_pcm16 [] =
-{	0x52, 0x49, 0x46, 0x46, 0x44, 0x00, 0x00, 0x00, 
-	0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74, 0x20, 
-	0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 
-	0x34, 0x12, 0x00, 0x00, 0x24, 0x68, 0x00, 0x00, 
-	0x02, 0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61, 
-	0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 
-	0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 
-	0x06, 0x00, 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 
-	0x0A, 0x00, 0x0B, 0x00, 0x0C, 0x00, 0x0D, 0x00, 
-	0x0E, 0x00, 0x0F, 0x00, 0x49, 0x4E, 0x46, 0x4F,
-	0x04, 0x00, 0x00, 0x00, 0xFE, 0xED, 0xC0, 0xDE
-} ; /* wav_pcm16 */
-
-static	unsigned char  wav_pcm8 [] =
-{	0x52, 0x49, 0x46, 0x46, 0x34, 0x00, 0x00, 0x00, 
-	0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74, 0x20, 
-	0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 
-	0x34, 0x12, 0x00, 0x00, 0x34, 0x12, 0x00, 0x00, 
-	0x01, 0x00, 0x08, 0x00, 0x64, 0x61, 0x74, 0x61, 
-	0x10, 0x00, 0x00, 0x00, 0x80, 0x81, 0x82, 0x83, 
-	0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 
-	0x8C, 0x8D, 0x8E, 0x8F, 0x49, 0x4E, 0x46, 0x4F,
-	0x04, 0x00, 0x00, 0x00, 0xFE, 0xED, 0xC0, 0xDE
-} ; /* wav_pcm8 */
-
-static	unsigned char  aiff_pcm32 [] =
-{	0x46, 0x4F, 0x52, 0x4D, 0x00, 0x00, 0x00, 0x6E, 
-	0x41, 0x49, 0x46, 0x46, 0x43, 0x4F, 0x4D, 0x4D,
-	0x00, 0x00, 0x00, 0x12, 0x00, 0x01, 0x00, 0x00, 
-	0x00, 0x10, 0x00, 0x20, 0x40, 0x0B, 0x91, 0xA0,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x53, 
-	0x4E, 0x44, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
-	0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
-	0x00, 0x04, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
-	0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 
-	0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
-	0x00, 0x0A, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 
-	0x00, 0x0C, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00,
-	0x00, 0x0E, 0x00, 0x00, 0x00, 0x0F
-} ; /* aiff_pcm32 */
-
-static	unsigned char  aiff_pcm24 [] =
-{	0x46, 0x4F, 0x52, 0x4D, 0x00, 0x00, 0x00, 0x5E, 
-	0x41, 0x49, 0x46, 0x46, 0x43, 0x4F, 0x4D, 0x4D, 
-	0x00, 0x00, 0x00, 0x12, 0x00, 0x01, 0x00, 0x00, 
-	0x00, 0x10, 0x00, 0x18, 0x40, 0x0B, 0x91, 0xA0, 
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x53, 
-	0x4E, 0x44, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-	0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 
-	0x00, 0x03, 0x00, 0x00, 0x04, 0x00, 0x00, 0x05, 
-	0x00, 0x00, 0x06, 0x00, 0x00, 0x07, 0x00, 0x00, 
-	0x08, 0x00, 0x00, 0x09, 0x00, 0x00, 0x0A, 0x00, 
-	0x00, 0x0B, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x0D, 
-	0x00, 0x00, 0x0E, 0x00, 0x00, 0x0F
-} ; /* aiff_pcm24 */
-
-static	unsigned char  aiff_pcm16 [] =
-{	0x46, 0x4F, 0x52, 0x4D, 0x00, 0x00, 0x00, 0x4E, 
-	0x41, 0x49, 0x46, 0x46, 0x43, 0x4F, 0x4D, 0x4D, 
-	0x00, 0x00, 0x00, 0x12, 0x00, 0x01, 0x00, 0x00, 
-	0x00, 0x10, 0x00, 0x10, 0x40, 0x0B, 0x91, 0xA0, 
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x53, 
-	0x4E, 0x44, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
-	0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 
-	0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 
-	0x00, 0x09, 0x00, 0x0A, 0x00, 0x0B, 0x00, 0x0C, 
-	0x00, 0x0D, 0x00, 0x0E, 0x00, 0x0F
-} ; /* aiff_pcm16 */
-
-
-static	unsigned char  aiff_pcm8 [] =
-{	0x46, 0x4F, 0x52, 0x4D, 0x00, 0x00, 0x00, 0x3E, 
-	0x41, 0x49, 0x46, 0x46, 0x43, 0x4F, 0x4D, 0x4D, 
-	0x00, 0x00, 0x00, 0x12, 0x00, 0x01, 0x00, 0x00, 
-	0x00, 0x10, 0x00, 0x08, 0x40, 0x0B, 0x91, 0xA0, 
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x53, 
-	0x4E, 0x44, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 
-	0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 
-	0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
-} ; /* aiff_pcm8 */
-
-
-static	unsigned char  au_pcm32 [] =
-{	0x2E, 0x73, 0x6E, 0x64, 0x00, 0x00, 0x00, 0x18, 
-	0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x05,
-	0x00, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x01, 
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
-	0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03,
-	0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x05,
-	0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07,
-	0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x09,
-	0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x0B,
-	0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x0D,
-	0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x0F
-} ; /* au_pcm32 */
-
-static	unsigned char  au_pcm24 [] =
-{	0x2E, 0x73, 0x6E, 0x64, 0x00, 0x00, 0x00, 0x18, 
-	0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x04,
-	0x00, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x01,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
-	0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x04, 0x00,
-	0x00, 0x05, 0x00, 0x00, 0x06, 0x00, 0x00, 0x07,
-	0x00, 0x00, 0x08, 0x00, 0x00, 0x09, 0x00, 0x00,
-	0x0A, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x0C, 0x00,
-	0x00, 0x0D, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x0F
-} ; /* au_pcm24 */
-
-static	unsigned char  au_pcm16 [] =
-{	0x2E, 0x73, 0x6E, 0x64, 0x00, 0x00, 0x00, 0x18, 
-	0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x03,
-	0x00, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x01, 
-	0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03,
-	0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00, 0x07, 
-	0x00, 0x08, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0B,
-	0x00, 0x0C, 0x00, 0x0D, 0x00, 0x0E, 0x00, 0x0F
-} ; /* au_pcm16 */
-
-static	unsigned char  au_pcm8 [] =
-{	0x2E, 0x73, 0x6E, 0x64, 0x00, 0x00, 0x00, 0x18, 
-	0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x02,
-	0x00, 0x00, 0x12, 0x34, 0x00, 0x00, 0x00, 0x01, 
-	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
-	0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
-} ; /* au_pcm8 */
-
-static
-void	write_file (char *filename, unsigned char *data, size_t len)
-{	FILE* fp = NULL ;
-
-	fp = fopen (filename,"wb") ;
-	
-	if (fp == NULL)
-	{	printf ("Could not open file '%s' for writing.\n", filename) ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-		
-	if (fwrite (data, 1, len, fp) != len)
-	{	printf ("Write to file '%s' failed.\n", filename) ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-		
-	fclose (fp) ;
-} /* write_file */
-
-static
-void	double_test (char *filename, int length)
-{	int		k, count ;
-	SNDFILE	*file ;
-	SF_INFO	sfinfo ;
-	double	*readdata ;
-
-	printf ("    double_test (%s) ... ", filename) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("Could not open file '%s' for read.\n", filename) ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-		
-	if (sfinfo.samples != length)
-	{	printf ("Expecting %d samples in file, found %d.\n", length, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-		
-	readdata = (double*) malloc (sfinfo.samples * sizeof (double)) ;
-
-	if ((count = sf_read_double (file, readdata, sfinfo.samples, 0)) != sfinfo.samples)
-	{	printf ("sf_read_double failed (%d items read).\n", count) ;
-		exit (1) ;
-		} ;
-	
-	for (k = 0 ; k < sfinfo.samples ; k++)
-		if (readdata [k] != (double) (k))
-		{	printf ("Incorrect sample (#%d => %g).\n", k, readdata [k]) ;
-			exit (1) ;
-			} ;
-
-	/* Check seek from start of file. */
-	k = sf_seek (file, 1, SEEK_SET) ;
-	sf_read_double (file, readdata, 1, 0) ;
-	if (readdata [0] != 1 || k != 1)
-	{	printf ("sf_seek (SEEK_SET) followed by sf_read_XXXX failed (%d, %d).\n", ((int) readdata [0]), k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check seek forward from current position. */
-	k = sf_seek (file, 2, SEEK_CUR) ;
-	sf_read_double (file, readdata, 1, 0) ;
-	if (readdata [0] != 4 || k != 4)
-	{	printf ("sf_seek (SEEK_CUR) followed by sf_read_XXXX failed (%d, %d).\n", ((int) readdata [0]), k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check seek backward from current position. */
-	k = sf_seek (file, -2, SEEK_CUR) ;
-	sf_read_double (file, readdata, 1, 0) ;
-	if (readdata [0] != 3 || k != 3)
-	{	printf ("sf_seek (SEEK_CUR) followed by sf_read_XXXX failed (%d, %d).\n", ((int) readdata [0]), k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check that read past end of file returns number of items. */
-	if ((k = sf_read_double (file, readdata, sfinfo.samples, 0)) != 12)
-	{	printf ("Return value from short sf_read_XXXX incorrect (%d).\n", k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check seek backward from end. */
-	k = sf_seek (file, -14, SEEK_END) ;
-	sf_read_double (file, readdata, 1, 0) ;
-	if (readdata [0] != 2 || k != 2)
-	{	printf ("sf_seek (SEEK_END) followed by sf_read_XXXX failed (%d, %d).\n", ((int) readdata [0]), k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check multiple reads. */
-	k = sf_seek (file, 0, SEEK_SET) ;
-	count = 0 ;
-	while ((k = sf_read_double (file, readdata, 3, 0)))
-		count += k ;
-	if (count != sfinfo.samples)
-	{	printf ("failed multiple read test (%d, %d).\n", count, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	free (readdata) ;
-	sf_close (file) ;
-	
-	printf ("ok\n") ;
-
-} /* double_test */
-
-
-static
-void	int_test (char *filename, int length)
-{	int		count, k ;
-	SNDFILE	*file ;
-	SF_INFO	sfinfo ;
-	int		*readdata ;
-
-	printf ("    int_test    (%s) ... ", filename) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("Could not open file '%s' for read.\n", filename) ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-		
-	if (sfinfo.samples != length)
-	{	printf ("Expecting %d samples in file, found %d.\n", length, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-		
-	readdata = (int*) malloc (sfinfo.samples * sizeof (int)) ;
-
-	if ((count = sf_read_int (file, readdata, sfinfo.samples)) != sfinfo.samples)
-	{	printf ("sf_read_int failed (%d items read).\n", count) ;
-		exit (1) ;
-		} ;
-	
-	for (k = 0 ; k < sfinfo.samples ; k++)
-		if (readdata [k] != (int) (k))
-		{	printf ("Incorrect sample (#%d => %d).\n", k, readdata [k]) ;
-			exit (1) ;
-			} ;
-	
-	/* Check seek from start of file. */
-	k = sf_seek (file, 1, SEEK_SET) ;
-	sf_read_int (file, readdata, 1) ;
-	if (readdata [0] != 1 || k != 1)
-	{	printf ("sf_seek (SEEK_SET) followed by sf_read_XXXX failed (%d, %d).\n", readdata [0], k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check seek forward from current position. */
-	k = sf_seek (file, 2, SEEK_CUR) ;
-	sf_read_int (file, readdata, 1) ;
-	if (readdata [0] != 4 || k != 4)
-	{	printf ("sf_seek (SEEK_CUR) followed by sf_read_XXXX failed (%d, %d).\n", readdata [0], k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check seek backward from current position. */
-	k = sf_seek (file, -2, SEEK_CUR) ;
-	sf_read_int (file, readdata, 1) ;
-	if (readdata [0] != 3 || k != 3)
-	{	printf ("sf_seek (SEEK_CUR) followed by sf_read_XXXX failed (%d, %d).\n", readdata [0], k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check that read past end of file returns number of items. */
-	if ((k = sf_read_int (file, readdata, sfinfo.samples)) != 12)
-	{	printf ("Return value from short sf_read_XXXX incorrect (%d).\n", k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check seek backward from end. */
-	k = sf_seek (file, -14, SEEK_END) ;
-	sf_read_int (file, readdata, 1) ;
-	if (readdata [0] != 2 || k != 2)
-	{	printf ("sf_seek (SEEK_END) followed by sf_read_XXXX failed (%d, %d).\n", readdata [0], k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check multiple reads. */
-	k = sf_seek (file, 0, SEEK_SET) ;
-	count = 0 ;
-	while ((k = sf_read_int (file, readdata, 3)))
-		count += k ;
-	if (count != sfinfo.samples)
-	{	printf ("failed multiple read test (%d, %d).\n", count, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	free (readdata) ;
-	sf_close (file) ;
-	
-	printf ("ok\n") ;
-
-} /* int_test */
-
-static
-void	short_test (char *filename, int length)
-{	int		count, k ;
-	SNDFILE	*file ;
-	SF_INFO	sfinfo ;
-	short	*readdata ;
-
-	printf ("    short_test  (%s) ... ", filename) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("Could not open file '%s' for read.\n", filename) ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-		
-	if (sfinfo.samples != length)
-	{	printf ("Expecting %d samples in file, found %d.\n", length, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-		
-	readdata = (short*) malloc (sfinfo.samples * sizeof (short)) ;
-
-	if ((count = sf_read_short (file, readdata, sfinfo.samples)) != sfinfo.samples)
-	{	printf ("sf_read_short failed (%d items read).\n", count) ;
-		exit (1) ;
-		} ;
-	
-	for (k = 0 ; k < sfinfo.samples ; k++)
-		if (readdata [k] != (short) (k))
-		{	printf ("Incorrect sample (#%d => %d).\n", k, readdata [k]) ;
-			exit (1) ;
-			} ;
-			
-	/* Check seek from start of file. */
-	k = sf_seek (file, 1, SEEK_SET) ;
-	sf_read_short (file, readdata, 1) ;
-	if (readdata [0] != 1 || k != 1)
-	{	printf ("sf_seek (SEEK_SET) followed by sf_read_XXXX failed (%d, %d).\n", readdata [0], k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check seek forward from current position. */
-	k = sf_seek (file, 2, SEEK_CUR) ;
-	sf_read_short (file, readdata, 1) ;
-	if (readdata [0] != 4 || k != 4)
-	{	printf ("sf_seek (SEEK_CUR) followed by sf_read_XXXX failed (%d, %d).\n", readdata [0], k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check seek backward from current position. */
-	k = sf_seek (file, -2, SEEK_CUR) ;
-	sf_read_short (file, readdata, 1) ;
-	if (readdata [0] != 3 || k != 3)
-	{	printf ("sf_seek (SEEK_CUR) followed by sf_read_XXXX failed (%d, %d).\n", readdata [0], k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check that read past end of file returns number of items. */
-	if ((k = sf_read_short (file, readdata, sfinfo.samples)) != 12)
-	{	printf ("Return value from short sf_read_XXXX incorrect (%d).\n", k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check seek backward from end. */
-	k = sf_seek (file, -14, SEEK_END) ;
-	sf_read_short (file, readdata, 1) ;
-	if (readdata [0] != 2 || k != 2)
-	{	printf ("sf_seek (SEEK_END) followed by sf_read_XXXX failed (%d, %d).\n", readdata [0], k) ;
-		exit (1) ;
-		} ;
-	
-	/* Check multiple reads. */
-	k = sf_seek (file, 0, SEEK_SET) ;
-	count = 0 ;
-	while ((k = sf_read_short (file, readdata, 3)))
-		count += k ;
-	if (count != sfinfo.samples)
-	{	printf ("failed multiple read test (%d, %d).\n", count, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	free (readdata) ;
-	sf_close (file) ;
-	
-	printf ("ok\n") ;
-
-} /* short_test */
-
-int		main (int argc, char *argv [])
-{	char	*filename ;
-	int		bDoAll = 0 ;
-	int		nTests = 0 ;
-
-	if (argc != 2)
-	{	printf ("Usage : %s <test>\n", argv [0]) ;
-		printf ("    Where <test> is one of the following:\n") ;
-		printf ("           wav      - test WAV file functions (little endian)\n") ;
-		printf ("           aiff     - test AIFF file functions (big endian)\n") ;
-		printf ("           au       - test AU file functions (big endian)\n") ;
-		/*
-		**	printf ("           paf      - test PAF file functions (little endian)\n") ;
-		**	printf ("           svx      - test SVX file functions (big endian)\n") ;
-		**	printf ("           nist     - test NIST file functions (little endian)\n") ;
-		*/
-		printf ("           all      - perform all tests\n") ;
-		exit (1) ;
-		} ;
-		
-	bDoAll = !strcmp (argv [1], "all") ;
-
-	if (bDoAll || ! strcmp (argv [1], "wav"))
-	{	filename = "wav_pcm8.wav" ;
-		write_file (filename, wav_pcm8, sizeof (wav_pcm8)) ;
- 		short_test	(filename, 16) ;
- 		int_test	(filename, 16) ;
- 		double_test (filename, 16) ;
- 		unlink (filename) ;
-
-		filename = "wav_pcm16.wav" ;
-		write_file (filename, wav_pcm16, sizeof (wav_pcm16)) ;
-		short_test	(filename, 16) ;
-		int_test	(filename, 16) ;
-		double_test (filename, 16) ;
-		unlink (filename) ;
-
-		filename = "wav_pcm24.wav" ;
-		write_file (filename, wav_pcm24, sizeof (wav_pcm24)) ;
-		int_test	(filename, 16) ;
-		double_test (filename, 16) ;
-		unlink (filename) ;
-
-		filename = "wav_pcm32.wav" ;
-		write_file	(filename, wav_pcm32, sizeof (wav_pcm32)) ;
-		int_test	(filename, 16) ;
-		double_test (filename, 16) ;
-		unlink (filename) ;
-
-		filename = "wav_ieee.wav" ;
-		write_file	(filename, wav_ieee, sizeof (wav_ieee)) ;
-		short_test	(filename, 16) ;
-		int_test	(filename, 16) ;
-		double_test (filename, 16) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-	
-	if (bDoAll || ! strcmp (argv [1], "aiff"))
-	{	filename = "aiff_pcm8.aiff" ;
- 		write_file (filename, aiff_pcm8, sizeof (aiff_pcm8)) ;
- 		short_test	(filename, 16) ;
- 		int_test	(filename, 16) ;
- 		double_test (filename, 16) ;
- 		unlink (filename) ;
-		
-		filename = "aiff_pcm16.aiff" ;
-		write_file (filename, aiff_pcm16, sizeof (aiff_pcm16)) ;
-		short_test	(filename, 16) ;
-		int_test	(filename, 16) ;
-		double_test (filename, 16) ;
-		unlink (filename) ;
-		
-		filename = "aiff_pcm24.aiff" ;
-		write_file (filename, aiff_pcm24, sizeof (aiff_pcm24)) ;
-		int_test	(filename, 16) ;
-		double_test (filename, 16) ;
-		unlink (filename) ;
-	
-		filename = "aiff_pcm32.aiff" ;
-		write_file (filename, aiff_pcm32, sizeof (aiff_pcm32)) ;
-		int_test	(filename, 16) ;
-		double_test (filename, 16) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-	
-	if (bDoAll || ! strcmp (argv [1], "au"))
-	{	filename = "au_pcm8.au" ;
- 		write_file (filename, au_pcm8, sizeof (au_pcm8)) ;
- 		short_test	(filename, 16) ;
- 		int_test	(filename, 16) ;
- 		double_test (filename, 16) ;
- 		unlink (filename) ;
-		
-		filename = "au_pcm16.au" ;
-		write_file (filename, au_pcm16, sizeof (au_pcm16)) ;
-		short_test	(filename, 16) ;
-		int_test	(filename, 16) ;
-		double_test (filename, 16) ;
-		unlink (filename) ;
-		
-		filename = "au_pcm24.au" ;
-		write_file (filename, au_pcm24, sizeof (au_pcm24)) ;
-		int_test	(filename, 16) ;
-		double_test (filename, 16) ;
-		unlink (filename) ;
-	
-		filename = "au_pcm32.au" ;
-		write_file (filename, au_pcm32, sizeof (au_pcm32)) ;
-		int_test	(filename, 16) ;
-		double_test (filename, 16) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-	
-	if (nTests == 0)
-	{	printf ("************************************\n") ;
-		printf ("*  No '%s' test defined.\n", argv [1]) ;
-		printf ("************************************\n") ;
-		return 1 ;
-		}
-
-	return 0;
-} /* main */
-
-/*============================================================================================
- *	Here are the test functions.
- */ 
-
--- a/common/libsndfile/tests/sftest.c
+++ /dev/null
@@ -1,62 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-
-#include	<stdio.h>
-#include	<unistd.h>
-
-#include	<sndfile.h>
-
-#define	BUFFER_SIZE		(1024)
-
-
-static short buffer [BUFFER_SIZE] ;
-
-int		main (int argc, char *argv[])
-{	SNDFILE	*file ;
-	SF_INFO sfinfo ;
-	int		k, count, max = 0, total = 0 ;
-	
-	if (argc < 2)
-	{	printf ("Expecting input file name.\n") ;
-		return 0 ;
-		} ;	
-	
-	if (! (file = sf_open_read (argv [1], &sfinfo)))
-	{	printf ("sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-
-	while ((count = sf_read_short (file, buffer, BUFFER_SIZE)))
-	{	for (k = 0 ; k < count ; k++)
-			if (abs (buffer [k]) > max)
-				max = abs (buffer [k]) ;
-		total += count ;
-		} ;
-				
-	printf ("Total         : %d\n", total) ;
-	printf ("Maximun value : %d\n", max) ;
-	
-	sf_close (file) ;
-
-	return 0 ;
-} /* main */
-
-
--- a/common/libsndfile/tests/sfversion.c
+++ /dev/null
@@ -1,38 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-
-#include	<stdio.h>
-#include	<string.h>
-#include	<unistd.h>
-
-#include	<sndfile.h>
-
-#define	BUFFER_SIZE	(256)
-
-static	char	strbuffer [BUFFER_SIZE] ;
-
-int		main (int argc, char *argv[])
-{	sf_get_lib_version (strbuffer, BUFFER_SIZE) ;
-		
-	printf (strbuffer) ;
-
-	return 0 ;
-} /* main */
-
--- a/common/libsndfile/tests/ulaw_test.c
+++ /dev/null
@@ -1,241 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-
-#include	<stdio.h>
-#include	<unistd.h>
-
-#include	<sndfile.h>
-
-#define	BUFFER_SIZE		(65536)
-
-static unsigned char	ulaw_encode (int sample) ;
-static int				ulaw_decode (unsigned int ulawbyte) ;
-
-static	short			short_buffer [BUFFER_SIZE] ;
-static	unsigned char	ulaw_buffer [BUFFER_SIZE] ;
-
-int		main (int argc, char *argv[])
-{	SNDFILE	*file ;
-	SF_INFO sfinfo ;
-	char	*filename ;
-	int		k ;
-	
-	filename = "test.au" ;
-	
-	sfinfo.format      = SF_FORMAT_AU | SF_FORMAT_ULAW ;
-	sfinfo.samplerate  = 44100 ;
-	sfinfo.samples     = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
-	sfinfo.channels    = 1 ;
-	sfinfo.pcmbitwidth = 16 ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-		
-	/* Generate a file containing all possible 16 bit sample values 
-	** and write it to disk as ulaw encoded samples. 
-	*/
-
-	for (k = 0 ; k < 0x10000 ; k++)
-		short_buffer [k] = k & 0xFFFF ;
-
-	sf_write_short (file, short_buffer, BUFFER_SIZE) ;
-	sf_close (file) ;
-	
-	/* Now open that file and compare the ulaw encoded sample values 
-	** with what they should be.
-	*/
-
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-
-	if (sf_read_raw (file, ulaw_buffer, BUFFER_SIZE) != BUFFER_SIZE)
-	{	printf ("sf_read_raw : ") ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-	
-	for (k = 0 ; k < 0x10000 ; k++)
-		if (ulaw_encode (short_buffer [k]) != ulaw_buffer [k])
-		{	printf ("Encoder error : sample #%d (0x%02X should be 0x%02X)\n", k, ulaw_buffer [k], ulaw_encode (short_buffer [k])) ;
-			exit (1) ;
-			} ;
-
-	sf_close (file) ;
-	
-	printf ("    ulaw_test : encoder ... ok\n") ;
-
-	/* Now generate a file containing all possible 8 bit encoded
-	** sample values and write it to disk as ulaw encoded samples. 
-	*/
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-
-	for (k = 0 ; k < 256 ; k++)
-		ulaw_buffer [k] = k & 0xFF ;
-
-	sf_write_raw (file, ulaw_buffer, 256) ;
-	sf_close (file) ;
-	
-	/* Now open that file and compare the ulaw decoded sample values 
-	** with what they should be.
-	*/
-
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-
-	if (sf_read_short (file, short_buffer, 256) != 256)
-	{	printf ("sf_read_short : ") ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-	
-	
-	for (k = 0 ; k < 256 ; k++)
-		if (short_buffer [k] != ulaw_decode (ulaw_buffer [k]))
-		{	printf ("Decoder error : sample #%d (0x%04X should be 0x%04X)\n", k, short_buffer [k], ulaw_decode (ulaw_buffer [k])) ;
-			exit (1) ;
-			} ;
-
-	sf_close (file) ;
-	
-	printf ("    ulaw_test : decoder ... ok\n") ;
-	
-	unlink (filename) ;
-
-	return 0 ;
-} /* main */
-
-
-/*=================================================================================
-**	The following routines came from the sox-12.15 (Sound eXcahcnge) distribution.
-**
-**	This code is not compiled into libsndfile. It is only used to test the 
-**	libsndfile lookup tables for correctness.
-**	
-**	I have included the original authors comments.
-*/
-
-/*
-** This routine converts from linear to ulaw.
-**
-** Craig Reese: IDA/Supercomputing Research Center
-** Joe Campbell: Department of Defense
-** 29 September 1989
-**
-** References:
-** 1) CCITT Recommendation G.711  (very difficult to follow)
-** 2) "A New Digital Technique for Implementation of Any
-**     Continuous PCM Companding Law," Villeret, Michel,
-**     et al. 1973 IEEE Int. Conf. on Communications, Vol 1,
-**     1973, pg. 11.12-11.17
-** 3) MIL-STD-188-113,"Interoperability and Performance Standards
-**     for Analog-to_Digital Conversion Techniques,"
-**     17 February 1987
-**
-** Input: Signed 16 bit linear sample
-** Output: 8 bit ulaw sample
-*/
-
-#define uBIAS 0x84   /* define the add-in bias for 16 bit samples */
-#define uCLIP 32635
-
-static 
-unsigned char ulaw_encode (int sample)
-{	static int exp_lut[256] = {0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,
-                               4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
-                               5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
-                               5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
-                               6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
-                               6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
-                               6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
-                               6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
-                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
-                               7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
-    int sign, exponent, mantissa;
-    unsigned char ulawbyte;
-
-    /* Get the sample into sign-magnitude. */
-    sign = (sample >> 8) & 0x80 ;					/* set aside the sign */
-    if ( sign != 0 ) 
-		sample = -sample ;							/* get magnitude */
-    if ( sample > uCLIP ) 
-		sample = uCLIP ;							/* clip the magnitude */
-
-    /* Convert from 16 bit linear to ulaw. */
-    sample = sample + uBIAS;
-    exponent = exp_lut[( sample >> 7 ) & 0xFF];
-    mantissa = ( sample >> ( exponent + 3 ) ) & 0x0F;
-    ulawbyte = ~ ( sign | ( exponent << 4 ) | mantissa );
-
-	return ulawbyte;
-} /* ulaw_encode */
-
-
-/*
-** This routine converts from ulaw to 16 bit linear.
-**
-** Craig Reese: IDA/Supercomputing Research Center
-** 29 September 1989
-**
-** References:
-** 1) CCITT Recommendation G.711  (very difficult to follow)
-** 2) MIL-STD-188-113,"Interoperability and Performance Standards
-**     for Analog-to_Digital Conversion Techniques,"
-**     17 February 1987
-**
-** Input: 8 bit ulaw sample
-** Output: signed 16 bit linear sample
-*/
-
-static 
-int ulaw_decode (unsigned int ulawbyte)
-{	static int exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 };
-    int sign, exponent, mantissa, sample;
-
-    ulawbyte = ~ ulawbyte ;
-    sign = (ulawbyte & 0x80) ;
-    exponent = (ulawbyte >> 4) & 0x07 ;
-    mantissa = ulawbyte & 0x0F ;
-    sample = exp_lut [exponent] + (mantissa << (exponent + 3)) ;
-    if ( sign != 0 ) 
-		sample = -sample ;
-
-    return sample;
-} /* ulaw_decode */
-
--- a/common/libsndfile/tests/write_read_test.c
+++ /dev/null
@@ -1,947 +1,0 @@
-/*
-** Copyright (C) 1999-2000 Erik de Castro Lopo <erikd@zip.com.au>
-**  
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-** 
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-** 
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software 
-** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-
-#include	<stdio.h>
-#include	<string.h>
-#include	<unistd.h>
-#include	<math.h>
-
-#include	<sndfile.h>
-
-#define	BUFFER_SIZE		(1<<15)
-
-static	void	pcm_test_char	(char *str, char *filename, int typemajor, int typeminor) ;
-static	void	pcm_test_short	(char *str, char *filename, int typemajor, int typeminor) ;
-static	void	pcm_test_24bit	(char *str, char *filename, int typemajor, int typeminor, int long_file_ok) ;
-static	void	pcm_test_int	(char *str, char *filename, int typemajor, int typeminor) ;
-
-static	void	pcm_float_test	(char *str, char *filename, int typemajor) ;
-
-/* Force the start of this buffer to be double aligned. Sparc-solaris will
-** choke if its not.
-*/
-static	double	test_buffer [(BUFFER_SIZE/sizeof(double))+1] ;
-
-int		main (int argc, char *argv[])
-{	char	*filename ;
-	int		bDoAll = 0 ;
-	int		nTests = 0 ;
-
-	if (argc != 2)
-	{	printf ("Usage : %s <test>\n", argv [0]) ;
-		printf ("    Where <test> is one of the following:\n") ;
-		printf ("           wav  - test WAV file functions (little endian)\n") ;
-		printf ("           aiff - test AIFF file functions (big endian)\n") ;
-		printf ("           au   - test AU file functions (big endian)\n") ;
-		printf ("           aule - test little endian AU file functions\n") ;
-		printf ("           raw  - test RAW header-less PCM file functions\n") ;
-		printf ("           paf  - test PAF file functions\n") ;
-		printf ("           svx  - test 8SVX/16SV file functions\n") ;
-		printf ("           all  - perform all tests\n") ;
-		exit (1) ;
-		} ;
-
-	bDoAll=!strcmp (argv [1], "all");
-		
-	if (bDoAll || ! strcmp (argv [1], "wav"))
-	{	filename = "test.wav" ;
-		pcm_test_char 	("wav", filename, SF_FORMAT_WAV, SF_FORMAT_PCM) ;
-		pcm_test_short	("wav", filename, SF_FORMAT_WAV, SF_FORMAT_PCM) ;
-		pcm_test_24bit	("wav", filename, SF_FORMAT_WAV, SF_FORMAT_PCM, 0) ;
-		pcm_test_int	("wav", filename, SF_FORMAT_WAV, SF_FORMAT_PCM) ;
-		pcm_float_test	("wav", filename, SF_FORMAT_WAV) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "aiff"))
-	{	filename = "test.aiff" ;
-		pcm_test_char  ("aiff", filename, SF_FORMAT_AIFF, SF_FORMAT_PCM) ;
-		pcm_test_short ("aiff", filename, SF_FORMAT_AIFF, SF_FORMAT_PCM) ;
-		pcm_test_24bit ("aiff", filename, SF_FORMAT_AIFF, SF_FORMAT_PCM, 0) ;
-		pcm_test_int   ("aiff", filename, SF_FORMAT_AIFF, SF_FORMAT_PCM) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "au"))
-	{	filename = "test.au" ;
-		pcm_test_char  ("au", filename, SF_FORMAT_AU, SF_FORMAT_PCM) ;
-		pcm_test_short ("au", filename, SF_FORMAT_AU, SF_FORMAT_PCM) ;
-		pcm_test_24bit ("au", filename, SF_FORMAT_AU, SF_FORMAT_PCM, 0) ;
-		pcm_test_int   ("au", filename, SF_FORMAT_AU, SF_FORMAT_PCM) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "aule"))
-	{	filename = "test.au" ;
-		pcm_test_char  ("aule", filename, SF_FORMAT_AULE, SF_FORMAT_PCM) ;
-		pcm_test_short ("aule", filename, SF_FORMAT_AULE, SF_FORMAT_PCM) ;
-		pcm_test_24bit ("aule", filename, SF_FORMAT_AULE, SF_FORMAT_PCM, 0) ;
-		pcm_test_int   ("aule", filename, SF_FORMAT_AULE, SF_FORMAT_PCM) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "raw"))
-	{	filename = "test.raw" ;
-		pcm_test_char  ("raw-s8", filename, SF_FORMAT_RAW, SF_FORMAT_PCM_S8) ;
-		pcm_test_char  ("raw-u8", filename, SF_FORMAT_RAW, SF_FORMAT_PCM_U8) ;
-		pcm_test_short ("raw-le", filename, SF_FORMAT_RAW, SF_FORMAT_PCM_LE) ;
-		pcm_test_short ("raw-be", filename, SF_FORMAT_RAW, SF_FORMAT_PCM_BE) ;
-		pcm_test_24bit ("raw-le", filename, SF_FORMAT_RAW, SF_FORMAT_PCM_LE, 0) ;
-		pcm_test_24bit ("raw-be", filename, SF_FORMAT_RAW, SF_FORMAT_PCM_BE, 0) ;
-		pcm_test_int   ("raw-le", filename, SF_FORMAT_RAW, SF_FORMAT_PCM_LE) ;
-		pcm_test_int   ("raw-be", filename, SF_FORMAT_RAW, SF_FORMAT_PCM_BE) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "paf"))
-	{	filename = "test.paf" ;
-		pcm_test_short ("paf-le", filename, SF_FORMAT_PAF, SF_FORMAT_PCM_LE) ;
-		pcm_test_short ("paf-be", filename, SF_FORMAT_PAF, SF_FORMAT_PCM_BE) ;
-		pcm_test_24bit ("paf-le", filename, SF_FORMAT_PAF, SF_FORMAT_PCM_LE, 1) ;
-		pcm_test_24bit ("paf-be", filename, SF_FORMAT_PAF, SF_FORMAT_PCM_BE, 1) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (bDoAll || ! strcmp (argv [1], "svx"))
-	{	filename = "test.svx" ;
-		pcm_test_char 	("svx", filename, SF_FORMAT_SVX, SF_FORMAT_PCM) ;
-		pcm_test_short	("svx", filename, SF_FORMAT_SVX, SF_FORMAT_PCM) ;
-		unlink (filename) ;
-		nTests++ ;
-		} ;
-
-	if (nTests == 0)
-	{	printf ("Mono : ************************************\n") ;
-		printf ("Mono : *  No '%s' test defined.\n", argv [1]) ;
-		printf ("Mono : ************************************\n") ;
-		return 1 ;
-		} ;
-
-	return 0;
-} /* main */
-
-/*============================================================================================
- *	Here are the test functions.
- */ 
-
-static	
-void	pcm_test_char (char *str, char *filename, int typemajor, int typeminor)
-{	SNDFILE			*file ;
-	SF_INFO			sfinfo ;
-	unsigned int	k, items, frames ;
-	short			*data ;
-
-	printf ("    pcm_test_char  : %s ... ", str) ;
-
-	items = 127 ;
-
-	data = (short*) test_buffer ;
-	for (k = 0 ; k < items ; k++)
-		data [k] = k * ((k % 2) ? 1 : -1) ;
-		
-	sfinfo.samplerate  = 44100 ;
-	sfinfo.samples     = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
-	sfinfo.channels    = 1 ;
-	sfinfo.pcmbitwidth = 8 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("Mono : sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if ((k = sf_write_short (file, data, items)) != items)
-	{	printf ("Mono : sf_write_short failed with short write (%d => %d).\n", items, k) ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, items * sizeof (short)) ;
-	
-	if (typemajor != SF_FORMAT_RAW)
-		memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("Mono : sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Mono : Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples != items)
-	{	printf ("Mono : Incorrect number of samples in file. (%u => %u)\n", items, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 1)
-	{	printf ("Mono : Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 8)
-	{	printf ("Mono : Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_read_short (file, data, items)) != items)
-	{	printf ("Mono : short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (k = 0 ; k < items ; k++)
-		if (data [k] != k * ((k % 2) ? 1 : -1))
-		{	printf ("Mono : Incorrect sample (#%d : %d => %d).\n", k, k * ((k % 2) ? 1 : -1), data [k]) ;
-			exit (1) ;
-			} ;
-	sf_close (file) ;
-
-	/* Now test Stereo. */
-
-	if (typemajor == SF_FORMAT_SVX)
-	{	printf ("ok\n") ;
-		return ;
-		} ;
-
-	items = 126 ;
-
-	data = (short*) test_buffer ;
-	for (k = 0 ; k < items ; k++)
-		data [k] = k * ((k % 2) ? 1 : -1) ;
-		
-	sfinfo.samplerate  = 44100 ;
-	sfinfo.samples     = 123456789 ; /* Wrong length. Library should correct this on sf_close. */
-	sfinfo.channels    = 2 ;
-	sfinfo.pcmbitwidth = 8 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-	
-	frames = items / sfinfo.channels ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("Stereo : sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if ((k = sf_writef_short (file, data, frames)) != frames)
-	{	printf ("Stereo : sf_writef_short failed with short write (%d => %d).\n", frames, k) ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, items * sizeof (short)) ;
-	
-	if (typemajor != SF_FORMAT_RAW)
-		memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("Stereo : sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Stereo : Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples != frames)
-	{	printf ("Stereo : Incorrect number of samples in file. (%u => %u)\n", frames, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 2)
-	{	printf ("Stereo : Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 8)
-	{	printf ("Stereo : Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_readf_short (file, data, frames)) != frames)
-	{	printf ("Stereo : short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-
-	for (k = 0 ; k < items ; k++)
-		if (data [k] != k * ((k % 2) ? 1 : -1))
-		{	printf ("Stereo : Incorrect sample (#%d : %d => %d).\n", k, k * ((k % 2) ? 1 : -1), data [k]) ;
-			exit (1) ;
-			} ;
-
-	printf ("ok\n") ;
-} /* pcm_test_char */
-
-static	
-void	pcm_test_short (char *str, char *filename, int typemajor, int typeminor)
-{	SNDFILE			*file ;
-	SF_INFO			sfinfo ;
-	unsigned int	k, items, frames ;
-	short			*data ;
-
-	printf ("    pcm_test_short : %s ... ", str) ;
-
-	items = BUFFER_SIZE / sizeof (short) ;
-
-	data = (short*) test_buffer ;
-	for (k = 0 ; k < items ; k++)
-		data [k] = k * ((k % 2) ? 1 : -1) ;
-		
-	sfinfo.samplerate  = 44100 ;
-	sfinfo.samples     = items ;
-	sfinfo.channels    = 1 ;
-	sfinfo.pcmbitwidth = 16 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("Mono : sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if ((k = sf_write_short (file, data, items)) != items)
-	{	printf ("Mono : sf_write_short failed with short write (%d => %d).\n", items, k) ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, items * sizeof (short)) ;
-
-	if (typemajor != SF_FORMAT_RAW)
-		memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("Mono : sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Mono : Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples != items)
-	{	printf ("Mono : Incorrect number of samples in file. (%d => %d)\n", items, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 1)
-	{	printf ("Mono : Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 16)
-	{	printf ("Mono : Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_read_short (file, data, items)) != items)
-	{	printf ("Mono : short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (k = 0 ; k < items ; k++)
-		if (data [k] != k * ((k % 2) ? 1 : -1))
-		{	printf ("Mono : Incorrect sample (#%d : %d => %d).\n", k, k * ((k % 2) ? 1 : -1), data [k]) ;
-			exit (1) ;
-			} ;
-	sf_close (file) ;
-
-	/* Now test Stereo. */
-
-	if (typemajor == SF_FORMAT_SVX)
-	{	printf ("ok\n") ;
-		return ;
-		} ;
-
-	items = BUFFER_SIZE / sizeof (short) ;
-
-	data = (short*) test_buffer ;
-	for (k = 0 ; k < items ; k++)
-		data [k] = k * ((k % 2) ? 1 : -1) ;
-		
-	sfinfo.samplerate  = 44100 ;
-	sfinfo.samples     = items ;
-	sfinfo.channels    = 2 ;
-	sfinfo.pcmbitwidth = 16 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-	
-	frames = items / sfinfo.channels ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("Stereo : sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if ((k = sf_writef_short (file, data, frames)) != frames)
-	{	printf ("Stereo : sf_writef_short failed with short write (%d => %d).\n", frames, k) ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, items * sizeof (short)) ;
-
-	if (typemajor != SF_FORMAT_RAW)
-		memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("Stereo : sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Stereo : Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples != frames)
-	{	printf ("Stereo : Incorrect number of samples in file. (%d => %d)\n", frames, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 2)
-	{	printf ("Stereo : Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 16)
-	{	printf ("Stereo : Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_readf_short (file, data, frames)) != frames)
-	{	printf ("Stereo : short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (k = 0 ; k < items ; k++)
-		if (data [k] != k * ((k % 2) ? 1 : -1))
-		{	printf ("Stereo : Incorrect sample (#%d : %d => %d).\n", k, k * ((k % 2) ? 1 : -1), data [k]) ;
-			exit (1) ;
-			} ;
-	sf_close (file) ;
-
-	printf ("ok\n") ;
-} /* pcm_test_short */
-
-static	
-void	pcm_test_24bit (char *str, char *filename, int typemajor, int typeminor, int long_file_ok)
-{	SNDFILE			*file ;
-	SF_INFO			sfinfo ;
-	unsigned int	k, items, frames ;
-	int				*data ;
-
-	printf ("    pcm_test_24bit : %s ... ", str) ;
-
-	items = BUFFER_SIZE / sizeof (int) ;
-
-	data = (int*) test_buffer ;
-	for (k = 0 ; k < items ; k++)
-		data [k] = k * 256 * ((k % 2) ? 1 : -1) ;
-		
-	sfinfo.samplerate  = 44100 ;
-	sfinfo.samples     = items ;
-	sfinfo.channels    = 1 ;
-	sfinfo.pcmbitwidth = 24 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("Mono : sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sf_write_int (file, data, items) != items)
-	{	printf ("Mono : sf_write_int failed with error : ") ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-		
-	sf_close (file) ;
-	
-	memset (data, 0, items * 3) ;
-
-	if (typemajor != SF_FORMAT_RAW)
-		memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("Mono : sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Mono : Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples < items)
-	{	printf ("Mono : Incorrect number of samples in file (too short). (%d should be %d)\n", sfinfo.samples, items) ;
-		exit (1) ;
-		} ;
-	
-	if (! long_file_ok && sfinfo.samples > items)
-	{	printf ("Mono : Incorrect number of samples in file (too long). (%d should be %d)\n", sfinfo.samples, items) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 1)
-	{	printf ("Mono : Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 24)
-	{	printf ("Mono : Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_read_int (file, data, items)) != items)
-	{	printf ("Mono : short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (k = 0 ; k < items ; k++)
-		if (data [k] != k * 256 * ((k % 2) ? 1 : -1))
-		{	printf ("Mono : Incorrect sample (#%d : %d => %d).\n", k, k * 256 * ((k % 2) ? 1 : -1), data [k]) ;
-			exit (1) ;
-			} ;
-	sf_close (file) ;
-		
-	/* Now test Stereo. */
-
-	if (typemajor == SF_FORMAT_SVX)
-	{	printf ("ok\n") ;
-		return ;
-		} ;
-
-	items = BUFFER_SIZE / sizeof (int) ;
-
-	data = (int*) test_buffer ;
-	for (k = 0 ; k < items ; k++)
-		data [k] = k * 256 * ((k % 2) ? 1 : -1) ;
-		
-	sfinfo.samplerate  = 44100 ;
-	sfinfo.samples     = items ;
-	sfinfo.channels    = 2 ;
-	sfinfo.pcmbitwidth = 24 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-	
-	frames = items / sfinfo.channels ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("Stereo : sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sf_writef_int (file, data, frames) != frames)
-	{	printf ("Stereo : sf_writef_int failed with error : ") ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-		
-	sf_close (file) ;
-	
-	memset (data, 0, items * 3) ;
-
-	if (typemajor != SF_FORMAT_RAW)
-		memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("Stereo : sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Stereo : Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples < frames)
-	{	printf ("Stereo : Incorrect number of samples in file (too short). (%d should be %d)\n", sfinfo.samples, frames) ;
-		exit (1) ;
-		} ;
-	
-	if (! long_file_ok && sfinfo.samples > frames)
-	{	printf ("Stereo : Incorrect number of samples in file (too long). (%d should be %d)\n", sfinfo.samples, frames) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 2)
-	{	printf ("Stereo : Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 24)
-	{	printf ("Stereo : Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_readf_int (file, data, frames)) != frames)
-	{	printf ("Stereo : short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (k = 0 ; k < items ; k++)
-		if (data [k] != k * 256 * ((k % 2) ? 1 : -1))
-		{	printf ("Stereo : Incorrect sample (#%d : %d => %d).\n", k, k * 256 * ((k % 2) ? 1 : -1), data [k]) ;
-			exit (1) ;
-			} ;
-	sf_close (file) ;
-		
-	printf ("ok\n") ;
-} /* pcm_test_24bit */
-
-static	
-void	pcm_test_int (char *str, char *filename, int typemajor, int typeminor)
-{	SNDFILE			*file ;
-	SF_INFO			sfinfo ;
-	unsigned int	k, items, frames ;
-	int				sign, *data ;
-
-	printf ("    pcm_test_int   : %s ... ", str) ;
-
-	items = BUFFER_SIZE / sizeof (int) ;
-
-	data = (int*) test_buffer ;
-	for (sign = 1, k = 0 ; k < items ; k++)
-		data [k] = k * 200000 * ((k % 2) ? 1 : -1) ;
-		
-	sfinfo.samplerate  = 44100 ;
-	sfinfo.samples     = items ;
-	sfinfo.channels    = 1 ;
-	sfinfo.pcmbitwidth = 32 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("Mono : sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sf_write_int (file, data, items) != items)
-	{	printf ("Mono : sf_write_int failed with error : ") ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, items * sizeof (short)) ;
-
-	if (typemajor != SF_FORMAT_RAW)
-		memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("Mono : sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Mono : Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples != items)
-	{	printf ("Mono : Incorrect number of samples in file. (%d => %d)\n", items, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 1)
-	{	printf ("Mono : Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 32)
-	{	printf ("Mono : Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_read_int (file, data, items)) != items)
-	{	printf ("Mono : short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (sign = 1, k = 0 ; k < items ; k++)
-		if (data [k] != k * 200000 * ((k % 2) ? 1 : -1))
-		{	printf ("Mono : Incorrect sample (#%d : %d => %d).\n", k, (k % 2) ? 1 : -1, data [k]) ;
-			exit (1) ;
-			} ;
-	sf_close (file) ;
-
-	/* Now test Stereo. */
-
-	if (typemajor == SF_FORMAT_SVX)
-	{	printf ("ok\n") ;
-		return ;
-		} ;
-
-	items = BUFFER_SIZE / sizeof (int) ;
-
-	data = (int*) test_buffer ;
-	for (sign = 1, k = 0 ; k < items ; k++)
-		data [k] = k * 200000 * ((k % 2) ? 1 : -1) ;
-		
-	sfinfo.samplerate  = 44100 ;
-	sfinfo.samples     = items ;
-	sfinfo.channels    = 2 ;
-	sfinfo.pcmbitwidth = 32 ;
-	sfinfo.format 	   = (typemajor | typeminor) ;
-	
-	frames = items / sfinfo.channels ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("Stereo : sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sf_writef_int (file, data, frames) != frames)
-	{	printf ("Stereo : sf_writef_int failed with error : ") ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, items * sizeof (short)) ;
-
-	if (typemajor != SF_FORMAT_RAW)
-		memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("Stereo : sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | typeminor))
-	{	printf ("Stereo : Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | typeminor), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples != frames)
-	{	printf ("Stereo : Incorrect number of samples in file. (%d => %d)\n", frames, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 2)
-	{	printf ("Stereo : Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 32)
-	{	printf ("Stereo : Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_readf_int (file, data, frames)) != frames)
-	{	printf ("Stereo : short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (sign = 1, k = 0 ; k < items ; k++)
-		if (data [k] != k * 200000 * ((k % 2) ? 1 : -1))
-		{	printf ("Stereo : Incorrect sample (#%d : %d => %d).\n", k, (k % 2) ? 1 : -1, data [k]) ;
-			exit (1) ;
-			} ;
-	sf_close (file) ;
-
-	printf ("ok\n") ;
-} /* pcm_test_int */
-
-static	
-void	pcm_float_test (char *str, char *filename, int	typemajor)
-{	SNDFILE			*file ;
-	SF_INFO			sfinfo ;
-	unsigned int	k, items, frames ;
-	int				sign ;
-	double			*data, error ;
-
-	printf ("    pcm_float_test : %s ... ", str) ;
-
-	items = BUFFER_SIZE / sizeof (double) ;
-
-	data = (double*) test_buffer ;
-	for (sign = 1, k = 0 ; k < items ; k++)
-		data [k] = ((double) k) / 100.0 * (sign *= -1) ;
-		
-	sfinfo.samplerate = 44100 ;
-	sfinfo.samples    = items ;
-	sfinfo.channels   = 1 ;
-	sfinfo.pcmbitwidth   = 32 ;
-	sfinfo.format 	  = (typemajor | SF_FORMAT_FLOAT) ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("Mono : sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sf_write_double (file, data, items, 0) != items)
-	{	printf ("Mono : sf_write_int failed with error : ") ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, items * sizeof (double)) ;
-	memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("Mono : sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | SF_FORMAT_FLOAT))
-	{	printf ("Mono : Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | SF_FORMAT_FLOAT), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples != items)
-	{	printf ("Mono : Incorrect number of samples in file. (%d => %d)\n", items, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 1)
-	{	printf ("Mono : Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 32)
-	{	printf ("Mono : Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_read_double (file, data, items, 0)) != items)
-	{	printf ("Mono : short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (sign = 1, k = 0 ; k < items ; k++)
-	{	error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ;
-		if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5)
-		{	printf ("Mono : Incorrect sample (#%d : %f => %f).\n", k, ((double) k) / 100.0, data [k]) ;
-			exit (1) ;
-			} ;
-		} ;
-	sf_close (file) ;
-
-	/* Now test Stereo. */
-
-	if (typemajor == SF_FORMAT_SVX)
-	{	printf ("ok\n") ;
-		return ;
-		} ;
-
-	items = BUFFER_SIZE / sizeof (double) ;
-
-	data = (double*) test_buffer ;
-	for (sign = 1, k = 0 ; k < items ; k++)
-		data [k] = ((double) k) / 100.0 * (sign *= -1) ;
-		
-	sfinfo.samplerate = 44100 ;
-	sfinfo.samples    = items ;
-	sfinfo.channels   = 2 ;
-	sfinfo.pcmbitwidth   = 32 ;
-	sfinfo.format 	  = (typemajor | SF_FORMAT_FLOAT) ;
-	
-	frames = items / sfinfo.channels ;
-
-	if (! (file = sf_open_write (filename, &sfinfo)))
-	{	printf ("Stereo : sf_open_write failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sf_writef_double (file, data, frames, 0) != frames)
-	{	printf ("Stereo : sf_writef_int failed with error : ") ;
-		sf_perror (file) ;
-		exit (1) ;
-		} ;
-	sf_close (file) ;
-	
-	memset (data, 0, items * sizeof (double)) ;
-	memset (&sfinfo, 0, sizeof (sfinfo)) ;
-	
-	if (! (file = sf_open_read (filename, &sfinfo)))
-	{	printf ("Stereo : sf_open_read failed with error : ") ;
-		sf_perror (NULL) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.format != (typemajor | SF_FORMAT_FLOAT))
-	{	printf ("Stereo : Returned format incorrect (0x%08X => 0x%08X).\n", (typemajor | SF_FORMAT_FLOAT), sfinfo.format) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.samples != frames)
-	{	printf ("Stereo : Incorrect number of samples in file. (%d => %d)\n", frames, sfinfo.samples) ;
-		exit (1) ;
-		} ;
-	
-	if (sfinfo.channels != 2)
-	{	printf ("Stereo : Incorrect number of channels in file.\n") ;
-		exit (1) ;
-		} ;
-
-	if (sfinfo.pcmbitwidth != 32)
-	{	printf ("Stereo : Incorrect bit width (%d).\n", sfinfo.pcmbitwidth) ;
-		exit (1) ;
-		} ;
-
-	if ((k = sf_readf_double (file, data, frames, 0)) != frames)
-	{	printf ("Stereo : short read (%d).\n", k) ;
-		exit (1) ;
-		} ;
-
-	for (sign = 1, k = 0 ; k < items ; k++)
-	{	error = fabs (data [k] - ((double) k) / 100.0 * (sign *= -1)) ;
-		if (fabs (data [k]) > 1e-100 && fabs (error / data [k]) > 1e-5)
-		{	printf ("Stereo : Incorrect sample (#%d : %f => %f).\n", k, ((double) k) / 100.0, data [k]) ;
-			exit (1) ;
-			} ;
-		} ;
-	sf_close (file) ;
-
-	printf ("ok\n") ;
-} /* pcm_float_test */
-