arsd.simpleaudio

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.

TODO: * pre-resampler that loads a clip and prepares it for repeated fast use * controls so you can tell a particular thing to keep looping until you tell it to stop, or stop after the next loop, etc (think a phaser sound as long as you hold the button down) * playFile function that detects automatically. basically: if(args[1].endsWith("ogg")) a.playOgg(args[1]); else if(args[1].endsWith("wav")) a.playWav(args[1]); else if(mp3) a.playMp3(args[1]);

More...

Members

Classes

AudioException
class AudioException

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

AudioPcmOutThread
deprecated class AudioPcmOutThread

Old thread implementation. I decided to deprecate it in favor of AudioOutputThread because RAII semantics make it easier to get right at the usage point. See that to go forward.

AudioPcmOutThreadImplementation
class AudioPcmOutThreadImplementation

Makes an audio thread for you that you can make various sounds on and it will mix them with good enough latency for simple games.

Functions

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

Channel aftertouch.

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

Aftertouch.

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

Controller.

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

Note off.

midiNoteOn
ubyte[] midiNoteOn(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.

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

Pitch bend. FIXME doesn't work right

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

Program change.

Interfaces

SampleController
interface SampleController

Provides an interface to control a sound.

Manifest constants

DEFAULT_VOLUME
enum DEFAULT_VOLUME;

A reasonable default volume for an individual sample. It doesn't need to be large; in fact it needs to not be large so mixing doesn't clip too much.

SampleRateFull
enum SampleRateFull;

Structs

AudioInput
struct AudioInput

Gives PCM input access (such as a microphone).

AudioMixer
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.

AudioOutput
struct AudioOutput

Gives PCM output access (such as the speakers).

AudioOutputThread
struct AudioOutputThread

Wraps AudioPcmOutThreadImplementation with RAII semantics for better error handling and disposal than the old way.

MMClock
struct MMClock

A clock you can use for multimedia applications. It compares time elapsed against a position variable you pass in to figure out how long to wait to get to that point. Very similar to Phobos' StopWatch but with built-in wait capabilities.

MidiInput
struct MidiInput

For reading midi events from hardware, for example, an electronic piano keyboard attached to the computer.

MidiOutput
struct MidiOutput

Gives MIDI output access.

SpeexResampler
struct SpeexResampler
Undocumented in source.

Detailed Description

* play audio high level with options to wait until completion or return immediately * midi mid-level stuff but see arsd.midi!

* some kind of encoder???????

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.

Meta

License

GPL3 unless you compile with -version=without_resampler and don't use the playEmulatedOpl3Midi, in which case it is BSL-1.0.

Suggestion Box / Bug Report