[clean-list] Playing sounds

Jerzy Karczmarczuk karczma@info.unicaen.fr
Fri, 14 Nov 2003 10:13:25 +0100


As you noticed, someone will use Clean for video streaming.
Nice to see the Clean List back to life.

So, just to make some noise, I have a question. About making noise.
Under Windows.

The StdSound module in the last Clean is truncated, the call to WinSoundPlay
is commented out, 'playSoundFile' doesn't do anything. Why?

WinSOundPlay exists of course, this is an inline code. Everything finally goes
to the winmm.dll, PlaySoundA@12.  Ugh. "The buck stops here"...

The games use more involved, a little tagliatelle-style chain of calls to sound
events. I scanned all that, but finally I gave up.

Perhaps somebody could help me?

I would like to play a sound (wave pattern) directly from an internal buffer.
Passing to some Windows obscure demons *just*

* the address of the buffer
* its length
* number of channels (or not, mono is good enough)
* sampling ratio  (items/sec of audio rendering)
* bits/item (8 or 16; or not. 16 by default, let's be serious...)

And *nothing* more. All that belongs to the canonical .wav format. I might at
the beginning try to recreate from some internal highly esoteric DSP procedures
a .wav output and to play it back, but I *need* finally to have it online.
I want to code in a purely functional way a pedagogic sound sythesizer. A low-
level synthesizer, no need to remind me that such things as Haskore exist...
(And don't need to mention the Common Lisp Music; it is all *but* purely
functional).

Does somebody (Mike Wiering, perhaps) has some experience with that? Did
somebody try to work on Clean bindings of the DirectSound stuff? I know that
there are Windows APIs permitting to pass some memory image of a wave pattern
to the 'player', but I am - for the moment - hopelessly ignorant [after all,
I am just a phys/math-oriented theoretician, sacré bleu...] and you might spare
me some cruel suffering.

Perhaps you know of a simple external library, available with sources, which
uses standard Windows APIs for the sound generation, so that I could calque
it, and plug into Clean I/O?

Thank you.


Jerzy Karczmarczuk
Caen, France