libsndfile/libsndfile
FreeA C library for reading and writing sound files containing sampled audio data.
FreeFree tier
About libsndfile/libsndfile
libsndfile is a C library for reading and writing files containing sampled audio data. It supports a wide range of audio formats including WAV, AIFF, FLAC, Ogg/Vorbis, Opus, MP3, and many others via optional libraries. The library is C99-compliant and can be built using either the traditional GNU Autotools or modern CMake build systems. It is cross-platform, running on Linux, macOS, Windows, BSD, and Android. Originally developed by Erik de Castro Lopo, the project is now maintained by the libsndfile team on GitHub.
Key Features
Reads and writes sampled audio data in multiple formats (WAV, AIFF, FLAC, Ogg/Vorbis, Opus, MP3, etc.)
C99-compliant source code compatible with GCC, Clang, and Visual Studio
Dual build systems: GNU Autotools and CMake (3.1.3+)
Cross-platform (Linux, macOS, Windows, BSD, Android)
Optional library packages for extended format support (Ogg, Vorbis, FLAC, Opus, MP3, ALSA, Sndio)
Includes utility program `sndfile-play` for playback (Linux/BSD with ALSA/Sndio)
Pros & Cons
Pros
- Extensive format support via optional libraries
- Open source (GNU LGPL/BSD-like license) with active maintenance
- Well-documented API and example code
- Portable across major operating systems
- Supports both static and dynamic linking
- CMake integration for modern IDE workflows (e.g., Visual Studio, Xcode)
Cons
- Requires C compiler and build toolchain to integrate (not a precompiled binary library out-of-box on all platforms)
- No native AI or machine learning capabilities; purely a low-level audio I/O library
- Some advanced formats (e.g., MP3, Opus) require separate external libraries at compile time
Best For
Reading and writing audio files in C/C++ applicationsAudio file format conversion and transcodingAudio data processing and analysis pipelinesEmbedding audio I/O capabilities in software synthesizers, editors, or sound tools
FAQ
What audio formats does libsndfile support?
libsndfile supports a wide range of formats including WAV, AIFF, FLAC, Ogg/Vorbis, Opus, MP3, and many others. Support for some formats (FLAC, Ogg, Vorbis, Opus, MP3) is enabled by installing optional development packages.
How do I build libsndfile?
Two build systems are available: GNU Autotools (run `autoreconf -vif && ./configure --enable-werror && make && make check`) and CMake (version 3.1.3+). See the README for detailed instructions for Linux, macOS, and Windows.