Anyone interested in simpleaudio.d too?

Adam D. Ruppe destructionator at gmail.com
Mon Apr 11 21:30:13 PDT 2011


I just dug up my old wav.d and quickly added wav.play() support
to it for both Windows and Linux. Now, this is sucky D1 code,
but hey, it works, and it's short. If there's interest, I can
port to D2 and add some range support to it and see about fleshing
it out.

http://arsdnet.net/dcode/wav.d

Again, this is D1, so be sure to use an appropriate compiler. It's
dependency free (even on Linux - the only calls it makes are to the
kernel for open, write, close, and ioctl. It uses the OSS /dev/dsp
method.

BTW, yes, I know OSS is deprecated. Fuck that noise, ALSA is a piece
of shit and who the hell even knows what's going on anymore beyond it.
Seems like every time I turn around there's another half assed new
Linux audio stack. What the damn son.

OSS is technically superior and *infinitely* easier to use. If I
decide to post my MIDI code, you'll see what I mean - it uses ALSA
and takes like 100 lines to do the simplest thing. The Windows
version of midi, using the *low level* functions was about ten lines
long...

Besides OSS works on just about any unix, so it's more cross platform
too. So yeah, I'm sticking to it for any kind of simple audio module.)



The wav class is just a collection of data. Everything is stored
as a short[] and you simply add data. There's a few functions in
there for some simple sounds, then the bottom half of the file
has a main() function and some helpers to play a little melody. (If
you've played Final Fantasy 6, you might recognize it. Nothing fancy,
but more interesting to my ears than random noise.)


Then you can call wav.save("file.wav") to write it to disk or
wav.play() to put it out the speakers.

Note: turn your volume down before trying it. It worked for me but
it might be buggy.



Anyway, any interest in this little thing being fleshed out? It seems
to me that simple audio is something a lot of libraries neglect, and
it really isn't hard to add.

I figure it will offer the same style of stuff I've been talking
about for images - some generic sound related algorithms and a
few ranges off the files, converted to lazy style to mesh with the
rest of the lib. I'm open to ideas and suggestions for what would be
useful.


More information about the Digitalmars-d mailing list