The purpose of this module is to provide audio functions for things like playback, capture, and volume on both Windows (via the mmsystem calls)and Linux (through ALSA).

It is only aimed at the basics, and will be filled in as I want a particular feature. I don't generally need super configurability and see it as a minus, since I don't generally care either, so I'm going to be going for defaults that just work. If you need more though, you can hack the source or maybe just use it for the operating system bindings.

For example, I'm starting this because I want to write a volume control program for my linux box, so that's what is going first. That will consist of a listening callback for volume changes and being able to get/set the volume.




class AudioException

Thrown on audio failures. Subclass this to provide OS-specific exceptions


ubyte[] midiChannelAftertouch(ref ubyte[] where, ubyte channel, byte amount)

Channel aftertouch.

ubyte[] midiNoteAftertouch(ref ubyte[] where, ubyte channel, byte note, byte pressure)


ubyte[] midiNoteController(ref ubyte[] where, ubyte channel, byte controllerNumber, byte controllerValue)


ubyte[] midiNoteOff(ref ubyte[] where, ubyte channel, byte note, byte velocity)

Note off.

ubyte[] midiNoteOn(ref ubyte[] where, ubyte channel, byte note, byte velocity)

Puts a note on at the beginning of the passed slice, advancing it by the amount of the message size. Returns the message slice.

ubyte[] midiNotePitchBend(ref ubyte[] where, ubyte channel, short change)

Pitch bend. FIXME doesn't work right

ubyte[] midiProgramChange(ref ubyte[] where, ubyte channel, byte program)

Program change.


struct AudioInput

Gives PCM input access (such as a microphone).

struct AudioMixer

Interfaces with the default sound card. You should only have a single instance of this and it should be stack allocated, so its destructor cleans up after it.

struct AudioOutput

Gives PCM output access (such as the speakers).

struct MidiOutput

Gives MIDI output access.

Detailed Description

HOW IT WORKS: You make a callback which feeds data to the device. Make an AudioOutput struct then feed your callback to it. Then play.

Then call loop? Or that could be in play?

Methods: setCallback play pause

TODO: * play audio high level with options to wait until completion or return immediately * midi mid-level stuff * audio callback stuff (it tells us when to fill the buffer)

* Windows support for waveOut and waveIn. Maybe mixer too, but that's lowest priority.

* I'll also write .mid and .wav functions at least eventually. Maybe in separate modules but probably here since they aren't that complex.

I will probably NOT do OSS anymore, since my computer doesn't even work with it now. Ditto for Macintosh, as I don't have one and don't really care about them.