[Haskell-cafe] sound synthesis

jerzy.karczmarczuk at info.unicaen.fr jerzy.karczmarczuk at info.unicaen.fr
Fri May 2 06:25:52 EDT 2008

Thomas Girod: 

> Recently, I read a few articles about Haskell (and FP in general) and 
> music/sound. 
> I remember an article ranting about how lazy evaluation would be great to 
> do signal processing, but it was lacking real world example.

Check (e.g. through Google) what Henning Thielemann wrote about. 

I can offer you something written not in Haskell, but in Clean (the
conversion to Haskell is largely trivial), see e.g. this PADL paper,
I have it on-line: 


> The task is to generate a sine wave and pipe it to /dev/dsp on my linux 
> box. There is probably a nicer way to make some noise, like using SDL 
> audio API bindings, but I didn't take the time to poke around this yet.

> I'm wondering how I could convert a [Word16] to ByteString, and how I 
> could use lazy evaluation to generate an infinite sine that stops with the 
> interupt.

"Infinite sine that stops" is a bit contradictory. In my view the solution
is the following. You generate your infinite whatever. Sine, Karplus-Strong
sound, flute, whatever, you combine all in one infinite stream, and you
don't care at all about stopping. [In Clean I used unboxed, spine-lazy, but
head-strict lists. The format was floating-point]. 

THEN, during the conversion, piping, construction of a .wav table (vector)
you think about the time-limitation of the stream. I played with static
constraints (concrete number of converted samples). If you want to do it
dynamically, then, either you know how to interrupt *any* infinite process
within Haskell, or you have to learn how to do it... Here people more
competent than myself will surely help you. Good luck, and thanks for
your interest in a this fabulous field. 

Jerzy Karczmarczuk

More information about the Haskell-Cafe mailing list