[Haskell-cafe] Re: Haskell-Cafe Digest, Vol 63, Issue 23

John Lato jwlato at gmail.com
Fri Nov 14 10:49:57 EST 2008


You could use HSoundFile, but I wouldn't recommend it for this
specific case.  I'm not extremely familiar with the Haskell OpenAL
bindings, but IIRC they take buffers (pointers).   Since HSoundFile
marshals data to [Double], you'd then have to convert it back to
CWord16 array.  Seems wasteful and slow to me.

Here are 3 possible approaches:

1.  Look through HSoundFile (or similar) to learn how they work and
write your own code.

2.  Look at the Codecs or Wave packages, which might be coerced into
doing what you want (there is also hsndfile, a binding to libsndfile,
however I think that normalizes data like HSoundFile does, although
you could likely avoid the marshaling problem.

3.  I have a revised HSoundFile, which I think could be much more
suitable for this sort of work.  If you'd like the code for that, let
me know and I'd be happy to pass it along.  I'm hoping to do a release
next week, but there's a lot of tidying to be done in the current
state.

How many people care about reading/writing audio files?  I've been
re-working the HSoundFile API, experimenting with different designs,
comparing packages, etc., and I could do a write-up if anyone is
interested.

John Lato

>
> Message: 19
> Date: Fri, 14 Nov 2008 08:11:59 +0100
> From: Marc Weber <marco-oweber at gmx.de>
> Subject: Re: [Haskell-cafe] openal & alut troubles
> To: haskell-cafe at haskell.org
> Message-ID: <20081114071159.GB18112 at gmx.de>
> Content-Type: text/plain; charset=utf-8
>
> On Fri, Nov 14, 2008 at 02:33:05AM +0000, Stephen wrote:
>>    ah, damn I feel stupid.  I hadn't it installed.  I just tried to, and,
>>    after verifying with the internet, it seems that ALUT isn't supported on
>>    macs anymore anyway.  Which leads me to the following question: does
>>    anyone have any example code for saving/loading wav files, say, using
>>    openal (minus alut) with haskell?     I'm not too sure how to go about
>>    doing it myself (though the people on this thread
>>    [1]http://groups.google.com/group/fa.haskell/browse_thread/thread/33b57c945274e353/a5d6094ff448a956?#a5d6094ff448a956
>>    seem to indicate that it would be a relatively easy task).
>
> Wave files are realitively easy to write .. However you can also try the
> encoder from hackage (catergory sound) called HSoundFile.. (I've never
> used it before) Also using the haskell wiki search from haskell.org
> reveals: http://haskell.org/haskellwiki/Sound_data_structures
>
> good luck
>
> Marc


More information about the Haskell-Cafe mailing list