Re: [linux-audio-dev] C++ wrapper for libsndfile

From: Lars Luthman <lars.luthman@email-addr-hidden>
Date: Sat Jul 29 2006 - 14:53:19 EEST

On Sat, 2006-07-29 at 21:31 +1000, Erik de Castro Lopo wrote:
> Hi all,
>
> Thanks to suggestions from people here I now have a relatively
> complete C++ wrapper for libsndfile:
>
> http://www.mega-nerd.com/tmp/sndfile.hh
>
> There is also a pre-release of libsndfile which includes a
> test for this wrapper:
>
> http://www.mega-nerd.com/tmp/libsndfile-1.0.17pre7.tar.gz
>
> C++ users, please comment.

The 4 different overloaded versions of the read, readf, write, and
writef functions will cause ambiguities that will force you to cast them
to their respective types in order to use pointers to them, for example
in functors (e.g. a sigc++ slot), like this:

  mem_fun(sndobj, (sf_count_t (Sndfile::*)(float*,
sf_count_t))&Sndfile::read);

If they were specialisations of the same template functions instead,
with the sample type as template parameter, you'd only have to write
this:

  mem_fun(sndobj, &Sndfile::read<float>);

which is a lot nicer and easier to read.

-- 
Lars Luthman - please encrypt any email sent to me if possible
PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x04C77E2E
Fingerprint: FCA7 C790 19B9 322D EB7A E1B3 4371 4650 04C7 7E2E

Received on Sat Jul 29 16:15:05 2006

This archive was generated by hypermail 2.1.8 : Sat Jul 29 2006 - 16:15:06 EEST