[Haskell-cafe] Re: [Haskell] analogous functions in Sound.File.Sndfile

stefan kersten sk at k-hornz.de
Wed Jul 7 07:06:52 EDT 2010

following up on haskell-cafe ...

On 07.07.10 04:07, Maria Gabriela Valdes wrote:
> Does anybody know what are the analogous functions and data types in the
> haskell library "Sound.File.Sndfile" of  the libsndfile library in C  ?

the decision may be debatable, but where it seemed appropriate the C identifiers
map to identifiers commonly used in haskell.

> data type : SNDFILE


> function: sf_open


> function : sf_read_short

the most lowlevel interface is the hGetBuf method of Sample; you have to
allocate buffer memory yourself. hGetBuffer returns a newly allocated instance
of Buffer; see the packages hsndfile-vector [1] and hsndfile-storablevector [2]
for instances and examples [3]. hGetContents returns the contents of the whole
file at once while hGetContentChunks returns a lazy list of buffers. readFile
and readFileChunks are just wrappers around openFile and hGetContents.

i just noticed though that the lazy versions don't work correctly because they
don't take closing the file handle into account properly. i think they should be
removed from the API, for incremental processing an iteratee interface would
probably be more appropriate.


[1] http://hackage.haskell.org/package/hsndfile-vector
[2] http://hackage.haskell.org/package/hsndfile-storablevector

More information about the Haskell-Cafe mailing list