[LAD] Writing a library?

Erik de Castro Lopo mle+la at mega-nerd.com
Wed Jul 23 03:51:54 UTC 2008

Darren Landrum wrote:

> I've been looking around for a library to read and write SFZ files, 
> which is an open sampler format released by Cakewalk:
> http://www.cakewalk.com/DevXchange/sfz.asp
> Finding none, I thought I might try my hand at writing a library for 
> this myself, as there is no embedded wave information like with Gig 
> files. SFZ is simply a text file to be parsed.

Back in the early 1990s I started out writing a library to read WAV
files. I soon realised that I also wanted to read AIFF and AU files.
It then occured to me that rather than write three libraries I should
write one library that abstracts away the three different formats and
provide a single API to read/write all three (and possibly more) file
types. That library became libsndfile:


Since there is already a library to read Gig files and I believe
another to read Sound Fonts (swami?) maybe you should look towards
unifying the reading of all these formats rather similar through one

> Now, I know about writing a good header file, and its associated class, 
> and all that, but I have no knowledge of how to write it as a dynamic 
> library. Google searches on every possible permutation have been 
> worthless to me as well.

I use autoconf/automake/libtool for this because for me thats the
easiest way to create a cross-platfrom build system.

For a relatively simple usage of these tools have a look at


I leant these tools by hacking other peoples projects because the
documentation was so poor. Currently the documentation for these
tools is good *reference* docs, but still pretty overwhelming if
you're new to them/

> I would prefer to write it in C++,

Feel free to write the internals in whatever language you like,
but please consider providing a pure C API.

Writing wrappers for languages like Python, Perl, Ruby etc is far
easier if the API is a C API than if it is C++.

Erik de Castro Lopo
"If I were on life-support, I'd rather have it run by a Gameboy
than a Windows box."
-- Cliff Wells in comp.lang.python

More information about the Linux-audio-dev mailing list