#include <Audio.h>
Inheritance diagram for Audio
Public Types | |||||||||||
typedef int | Volume | ||||||||||
typedef int | Velocity | ||||||||||
typedef int | Frequency | ||||||||||
enum | Result { SUCCESS = 0, FAILURE, NOT_AVAILABLE } | ||||||||||
enum | { MAX_VOLUME = 128, MIN_VOLUME = 0, MAX_VELOCITY, MIN_VELOCITY, MAX_FREQUENCY, MIN_FREQUENCY, PAN_LEFT = -127, PAN_CENTER = 0, PAN_RIGHT = 128, VOICE_UNALLOCATED = -1 } | ||||||||||
Public Methods | |||||||||||
virtual | ~Audio () | ||||||||||
virtual Result | Record (Sample& sample) | ||||||||||
Record to memory buffer -- not all sound devices can record
| |||||||||||
virtual Result | Play (Sample& sample) = 0 | ||||||||||
Play the given sample. | |||||||||||
virtual Result | PlayNoWait (Sample& sample, int& NewChanelID, int& NewVoice) = 0 | ||||||||||
Play the sample and return without waiting for it to finish. | |||||||||||
virtual Result | WaitForVoiceToFinish (int voice, int ChannelID) = 0 | ||||||||||
do as it says. | |||||||||||
virtual int | AllocateVoice (const Sample& sample, int voice = VOICE_UNALLOCATED) = 0 | ||||||||||
Allocates a voice for a sound which will be mixed into the buffer. More... | |||||||||||
virtual Result | DeleteVoice (int voice) = 0 | ||||||||||
Remove the given voice from the Audio manager. | |||||||||||
virtual Result | DeleteVoice (Sample& sample) | ||||||||||
virtual int | VoicesAllocated () const = 0 | ||||||||||
Return the number of current voices allocated. | |||||||||||
virtual Channel* | AllocateChannel () = 0 | ||||||||||
Create a new Channel. | |||||||||||
virtual void | DeleteChannel (Channel *& channel) = 0 | ||||||||||
Delete the given Channel. | |||||||||||
virtual Result | SetLocation (int x, int y, int z, int channel) = 0 | ||||||||||
virtual Result | SetX (int x, int channel) = 0 | ||||||||||
virtual Result | SetY (int y, int channel) = 0 | ||||||||||
virtual Result | SetZ (int z, int channel) = 0 | ||||||||||
virtual Result | GetLocation (int& x, int& y, int& z, int channel) = 0 | ||||||||||
virtual Result | GetX (int& x, int channel) = 0 | ||||||||||
virtual Result | GetY (int& y, int channel) = 0 | ||||||||||
virtual Result | GetZ (int& z, int channel) = 0 | ||||||||||
virtual Result | SetVolume (Volume volume, int channel) = 0 | ||||||||||
volume. | |||||||||||
virtual Volume | GetVolume (int channel) = 0 | ||||||||||
virtual Result | SetVelocity (Velocity velocity, int channel) = 0 | ||||||||||
velocity -- how hard the key was pressed -- is this useful? | |||||||||||
virtual Velocity | GetVelocity (int channel) = 0 | ||||||||||
virtual Result | SetFrequency (Frequency frequency, int channel) = 0 | ||||||||||
frequency. | |||||||||||
virtual Frequency | GetFrequency (int channel) = 0 | ||||||||||
virtual Result | SetPosition (unsigned long position, int channel) = 0 | ||||||||||
position. | |||||||||||
virtual unsigned long | GetPosition (int channel) = 0 | ||||||||||
virtual Result | SetVoice (int voice, int channel) = 0 | ||||||||||
Set the voice for the given channel. | |||||||||||
virtual int | GetVoice (int channel) = 0 | ||||||||||
get the voice that has been assigned to the channel. | |||||||||||
virtual int | NextChannel () = 0 | ||||||||||
return the channel id for the next channel. | |||||||||||
virtual void | Start (int channel) = 0 | ||||||||||
Start the channel playing. | |||||||||||
virtual void | Stop (int channel) = 0 | ||||||||||
Stop the channel from making any noise. | |||||||||||
virtual long | GetPlaybackRate () = 0 | ||||||||||
virtual void | SetTimeout (long milliseconds) = 0 | ||||||||||
virtual void | StartTimeout () = 0 | ||||||||||
virtual void | StopTimeout () = 0 | ||||||||||
virtual void | WaitForTimeout () = 0 | ||||||||||
virtual bool | IsStreamable () const | ||||||||||
virtual Result | StreamBuffer (const unsigned char* buffer, unsigned long length, int bits = 16, int channels = 2) | ||||||||||
void | Wait (long milliseconds) | ||||||||||
| |||||||||||
Static Public Methods | |||||||||||
Audio* | Create (int id = -1, int rate = 44100, int bits = 16, bool stereo = true, bool threaded = true) | ||||||||||
A factory method for creating the concrete instances.
| |||||||||||
Audio* | CreateStreamable (int rate = 44100, int bits = 16, bool stereo = true, bool threaded = true) | ||||||||||
A factory method for creating the concrete instances of Audio that can stream data.
| |||||||||||
void | RegisterDefaultDrivers (int rate, int bits, bool stereo, bool threaded) | ||||||||||
const char* | GetDescription (int id) |
To create a concrete instance of this class use:
Audio* a = Audio::Create();The concrete instance may be an interface to a wavetable sound card using /dev/sequencer or it may be an interface to a software mixing implementation.
This class has been modeled on the abilities of wavetable sound cards. ie soundcards that mix samples in hardware. Inspiration was taken from the opensound /dev/sequencer api.
Since software can be modified easily, unlike hardware, it is possible to interface the software mixing soundcards using the same api as the wavetable soundcards. The reverse is not always true.
|
Allocates a voice for a sound which will be mixed into the buffer. It returns number corresponding to it's place in the array of samples (voices.) this should make a copy of the sample structure or at least not rely on the reference to Sample given always being valid it will assign the voice to the number "voice" or if voice is -1 then it will get the next free voice number and return it. Reimplemented in AudioToFile, and Sequencer. |