History -+- Features -+- Similar or Related Projects -+- News
Development -+- Programming Interface -+- Bug Reporting -+- Download
FAQ -+- Mailing Lists -+- Change Log -+- Licensing Information

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 Gnu Lesser General Public License.

The library was written to compile and run on a Linux system but should compile and run on just about any Unix (including MacOSX). It can also be compiled and run on Win32 systems using the Microsoft compiler and MacOS (OS9 and earlier) using the Metrowerks compiler. There are directions for compiling libsndfile on these platforms in the Win32 and MacOS directories of the source code distribution.

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.

It has been compiled and tested (at one time or another) on the following systems:

- i586-pc-linux-gnu (Linux on PC hardware)
- powerpc-unknown-linux-gnu (Linux on Apple Mac hardware)
- powerpc-apple-darwin7.0 (Mac OS X 10.3)
- sparc-sun-solaris2.8 (using gcc)
- mips-sgi-irix5.3 (using gcc)
- QNX 6.0
- i386-unknown-openbsd2.9
- Win32 (Microsoft Visual C++)

At the moment, each new release is being tested on i386 Linux, PowerPC Linux, MacOSX on PowerPC and Win32.

# Features

libsndfile has the following main features :

- Ability to read and write a large number of file formats.
- A simple, elegant and easy to use Applications Programming Interface.
- Usable on Unix, Win32, MacOS and others.
- On the fly format conversion, including endian-ness swapping, type conversion and bitwidth scaling.
- Optional normalisation when reading floating point data from files containing integer data.
- Ability to open files in read/write mode.
- The ability to write the file header without closing the file (only on files open for write or read/write).
- Ability to query the library about all supported formats and retrieve text strings describing each format.

libsndfile has a comprehensive test suite so that each release is as bug free as possible. When new bugs are found, new tests are added to the test suite to ensure that these bugs don't creep back into the code. When new features are added, tests are added to the test suite to make sure that these features continue to work correctly even when they are old features.

The following table lists the file formats and encodings that libsndfile can read and write. The file formats are arranged across the top and encodings along the left edge.

| Micro- soft WAV | SGI / Apple AIFF / AIFC | Sun / DEC / NeXT AU / SND | Header- less RAW | Paris Audio File PAF | Commo- dore Amiga IFF / SVX | Sphere Nist WAV | IRCAM SF | Creative VOC | Sound forge W64 | GNU Octave 2.0 MAT4 | GNU Octave 2.1 MAT5 | Portable Voice Format PVF | Fasttracker 2 XI | HMM Tool Kit HTK | Apple CAF
Unsigned 8 bit PCM | R/W | R/W |  | R/W |  |  |  |  | R/W | R/W |  | R/W |  |  |  |
Signed 8 bit PCM |  | R/W | R/W | R/W | R/W | R/W | R/W |  |  |  |  |  | R/W |  |  | R/W
Signed 16 bit PCM | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |  | R/W | R/W
Signed 24 bit PCM | R/W | R/W | R/W | R/W | R/W |  | R/W | R/W |  | R/W |  |  |  |  |  | R/W
Signed 32 bit PCM | R/W | R/W | R/W | R/W |  |  | R/W | R/W |  | R/W | R/W | R/W | R/W |  |  | R/W
32 bit float | R/W | R/W | R/W | R/W |  |  |  | R/W |  | R/W | R/W | R/W |  |  |  | R/W
64 bit double | R/W | R/W | R/W | R/W |  |  |  |  |  | R/W | R/W | R/W |  |  |  | R/W
u-law encoding | R/W | R/W | R/W | R/W |  |  | R/W | R/W | R/W | R/W |  |  |  |  |  | R/W
A-law encoding | R/W | R/W | R/W | R/W |  |  | R/W | R/W | R/W | R/W |  |  |  |  |  | R/W
IMA ADPCM | R/W |  |  |  |  |  |  |  |  | R/W |  |  |  |  |  |
MS ADPCM | R/W |  |  |  |  |  |  |  |  | R/W |  |  |  |  |  |
GSM 6.10 | R/W | R/W |  | R/W |  |  |  |  |  | R/W |  |  |  |  |  |
G721 ADPCM 32kbps | R/W |  | R/W |  |  |  |  |  |  |  |  |  |  |  |  |
G723 ADPCM 24kbps |  |  | R/W |  |  |  |  |  |  |  |  |  |  |  |  |
G723 ADPCM 40kbps |  |  | R/W |  |  |  |  |  |  |  |  |  |  |  |  |
12 bit DWVW |  | R/W |  | R/W |  |  |  |  |  |  |  |  |  |  |  |
16 bit DWVW |  | R/W |  | R/W |  |  |  |  |  |  |  |  |  |  |  |
24 bit DWVW |  | R/W |  | R/W |  |  |  |  |  |  |  |  |  |  |  |
Ok Dialogic ADPCM |  |  |  | R/W |  |  |  |  |  |  |  |  |  |  |  |
8 bit DPCM |  |  |  |  |  |  |  |  |  |  |  |  |  | R/W |  |
16 bit DPCM |  |  |  |  |  |  |  |  |  |  |  |  |  | R/W |  |

Some of the file formats I am also interested in adding are:

- Kurzweil K2000 sampler files.
- Ogg Vorbis.
- Ogg Speex.
- FLAC.

I have decided that I will not be adding support for MPEG Layer 3 due to the patent issues surrounding this file format.

Other file formats may also be added on request.

# History

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 wavplay program. That contributed code 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.

Here is the release history for libsndfile :

- Version 0.0.8 (Feb 15 1999) First official release.
- Version 0.0.28 (Apr 26 2002) Final release of version 0 of libsndfile.
- Version 1.0.0rc1 (Jun 24 2002) Release candidate 1 of version 1 of libsndfile.
- Version 1.0.0rc6 (Aug 14 2002) MacOS 9 fixes.
- Version 1.0.0 (Aug 16 2002) First 1.0.X release.
- Version 1.0.1 (Sep 14 2002) Added MAT4 and MAT5 file formats.
- Version 1.0.2 (Nov 24 2002) Added VOX ADPCM format.
- Version 1.0.3 (Dec 09 2002) Fixes for Linux on ia64 CPUs.
- Version 1.0.4 (Feb 02 2003) New file formats and functionality.
- Version 1.0.5 (May 03 2003) One new file format and new functionality.
- Version 1.0.6 (Feb 08 2004) Large file fix for Linux/Solaris, new functionality and Win32 improvements.
- Version 1.0.7 (Feb 24 2004) Fix build problems on MacOSX and fix ia64/MIPS etc clip mode detction.
- Version 1.0.8 (Mar 14 2004) Minor bug fixes.
- Version 1.0.9 (Mar 30 2004) Add AVR format. Improve handling of some WAV files.
- Version 1.0.10 (Jun 15 2004) Minor bug fixes. Fix support for Win32 MinGW compiler.
- Version 1.0.11 (Nov 15 2004) Add SD2 file support, reading of loop data in WAV and AIFF. Minor bug fixes.
- Version 1.0.12 (Sep 30 2005) Add FLAC and CAF file support, virtual I/O interface. Minor bug fixes and cleanups.
- Version 1.0.13 (Jan 21 2006) Add read/write of instrument chunks. Minor bug fixes.
- Version 1.0.14 (Feb 19 2006) Minor bug fixes. Start shipping windows binary/source ZIP.
- Version 1.0.15 (Mar 16 2006) Minor bug fixes.
- Version 1.0.16 (Apr 30 2006) Add support for RIFX. Other minor feature enhancements and bug fixes.
- Version 1.0.17 (Aug 31 2006) Add C++ wrapper sndfile.hh. Minor bug fixes and cleanups.

# Similar or Related Projects

- SoX is a program for converting between sound file formats.
- Wavplay 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.
- Audiofile (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 in) the libaudiofile library which ships with SGI's IRIX OS.
- sndlib.tar.gz is another library written by Bill Schottstaedt of CCRMA.

# Licensing

libsndfile is released under the terms of the GNU Lesser General Public License. You may read the license here or read a simple explanation of the ideas behind the GPL and the LGPL here.

You can use libsndfile with Free Software, Open Source, proprietary, shareware or other closed source applications as long as libsndfile is used as a dynamically loaded library and you abide by a small number of other conditions (read the LGPL for more info). With applications released under the GNU GPL you can also use libsndfile statically linked to your application.

I would like to see libsndfile used as widely as possible but I would prefer it if you released software that uses libsndfile as Free Software or Open Source. However, if you put in a great deal of effort building a huge application which simply uses libsndfile for file I/O, then I have no problem with you releasing that as closed source and charging as much money as you want for it as long as you abide by the license.

What I don't like to see is things like Steve Dekorte's SoundConverter for Mac OSX. Mr Dekorte has grabbed a number of Free Software packages and wrapped them in a rather amateurish, buggy GUI and released the result as shareware. He charges US$10 for the full version when his contribution to the whole is, by his own admission, less than 10%.

# Download

Here is the latest version. It is available in the following formats (I am no longer distributing RPMs).

- Source code as a .tar.gz : libsndfile-1.0.17.tar.gz and (GPG signature).
- Windows .zip file including precompiled binaries and all source code : libsndfile-1_0_17.zip and (GPG signature).

Compiling libsndfile is relatively easy. The INSTALL file in the top level directory gives instructions on compiling and installing libsndfile on Unix-like systems (including MacOSX). For Win32 there are instructions in the doc/ directory of the tarball. These instructions are mirrored here.

Pre-release versions of libsndfile are available here and are announced on the libsndfile-devel mailing list.

The latest version of this document can be found here.

Author : Erik de Castro Lopo

This page has been accessed times.