Main Page | Class Hierarchy | Class List | File List | Class Members | Related Pages

DeviceAudioRt Class Reference

an rtAudio based stereo audio mixer/playback device More...

#include <proAudioRt.h>

Inheritance diagram for DeviceAudioRt:

DeviceAudio List of all members.

Public Member Functions

virtual unsigned int sampleFromMemory (const AudioSample &sample, float volume=1.0f)
virtual bool sampleDestroy (unsigned int sample)
virtual const AudioSamplesample (unsigned int handle) const
virtual unsigned int soundPlay (unsigned int sample, float volumeL=1.0f, float volumeR=1.0f, float disparity=0.0f, float pitch=1.0f)
virtual unsigned int soundLoop (unsigned int sample, float volumeL=1.0f, float volumeR=1.0f, float disparity=0.0f, float pitch=1.0f)
virtual bool soundUpdate (unsigned int sound, float volumeL, float volumeR, float disparity=0.0f, float pitch=1.0f)
virtual bool soundStop (unsigned int sound)
virtual void soundStop ()
virtual unsigned soundActive () const

Static Public Member Functions

static DeviceAudiocreate (unsigned int nTracks=8, unsigned int frequency=22050, unsigned int chunkSize=1024)

Protected Member Functions

 DeviceAudioRt (unsigned int nTracks, unsigned int frequency, unsigned int chunkSize)
virtual ~DeviceAudioRt ()
int mixOutputFloat (signed short *outputBuffer, unsigned int nFrames)

Static Protected Member Functions

static int cbMix (void *outputBuffer, void *inputBuffer, unsigned int nFrames, double streamTime, RtAudioStreamStatus status, void *data)

Protected Attributes

std::map< unsigned int, AudioSample * > mm_sample
unsigned int m_sampleCounter
_AudioTrack * ma_sound
unsigned int m_nSound
RtAudio m_dac

Detailed Description

an rtAudio based stereo audio mixer/playback device

DeviceAudioRt offers some advanced features such as dynamic pitch, independent volume control for both channels, and user-defined time shifts between the channels.


Constructor & Destructor Documentation

DeviceAudioRt::DeviceAudioRt unsigned int  nTracks,
unsigned int  frequency,
unsigned int  chunkSize
[protected]
 

constructor. Use the create() method instead

virtual DeviceAudioRt::~DeviceAudioRt  )  [protected, virtual]
 

destructor. Use the destroy() method instead


Member Function Documentation

static int DeviceAudioRt::cbMix void *  outputBuffer,
void *  inputBuffer,
unsigned int  nFrames,
double  streamTime,
RtAudioStreamStatus  status,
void *  data
[inline, static, protected]
 

mixer callback

static DeviceAudio* DeviceAudioRt::create unsigned int  nTracks = 8,
unsigned int  frequency = 22050,
unsigned int  chunkSize = 1024
[static]
 

creates audio device

Use this method instead of a constructor.

Parameters:
nTracks (optional) the maximum number of sounds that are played parallely. Computation time is linearly correlated to this factor.
frequency (optional) sample frequency of the playback in Hz. 22050 corresponds to FM radio 44100 is CD quality. Computation time is linearly correlated to this factor.
chunkSize (optional) the number of bytes that are sent to the sound card at once. Low numbers lead to smaller latencies but need more computation time (thread switches). If a too small number is chosen, the sounds might not be played continuously. The default value 512 guarantees a good latency below 40 ms at 22050 Hz sample frequency.
Returns:
a pointer to an audio device object in case of success Note that the parameters are only handled when calling for the first time. Afterwards always the same object is returned until an explicit destroy() is called.

int DeviceAudioRt::mixOutputFloat signed short *  outputBuffer,
unsigned int  nFrames
[protected]
 

mixes tracks to a single output stream

virtual const AudioSample* DeviceAudioRt::sample unsigned int  handle  )  const [virtual]
 

allows read access to a sample identified by its handle

Reimplemented from DeviceAudio.

virtual bool DeviceAudioRt::sampleDestroy unsigned int  sample  )  [virtual]
 

deletes a previously created sound sample resource identified by its handle

Implements DeviceAudio.

virtual unsigned int DeviceAudioRt::sampleFromMemory const AudioSample sample,
float  volume = 1.0f
[virtual]
 

converts a sound sample to internal audio format, returns handle

Implements DeviceAudio.

virtual unsigned DeviceAudioRt::soundActive  )  const [virtual]
 

returns number of currently active sounds

Implements DeviceAudio.

virtual unsigned int DeviceAudioRt::soundLoop unsigned int  sample,
float  volumeL = 1.0f,
float  volumeR = 1.0f,
float  disparity = 0.0f,
float  pitch = 1.0f
[virtual]
 

plays a specified sample continuously and sets its parameters

Parameters:
sample a sample handle returned by a previous load() call
volumeL (optional) left volume
volumeR (optional) right volume
disparity (optional) time difference between left and right channel in seconds. Use negative values to specify a delay for the left channel, positive for the right.
pitch (optional) pitch factor for playback. 0.5 corresponds to one octave below, 2.0 to one above the original sample.
Returns:
a handle to the currently played sound or 0 in case of error

Implements DeviceAudio.

virtual unsigned int DeviceAudioRt::soundPlay unsigned int  sample,
float  volumeL = 1.0f,
float  volumeR = 1.0f,
float  disparity = 0.0f,
float  pitch = 1.0f
[virtual]
 

plays a specified sample once and sets its parameters

Parameters:
sample a sample handle returned by a previous load() call
volumeL (optional) left volume
volumeR (optional) right volume
disparity (optional) time difference between left and right channel in seconds. Use negative values to specify a delay for the left channel, positive for the right.
pitch (optional) pitch factor for playback. 0.5 corresponds to one octave below, 2.0 to one above the original sample.
Returns:
a handle to the currently played sound or 0 in case of error

Implements DeviceAudio.

virtual void DeviceAudioRt::soundStop  )  [virtual]
 

stops all sounds immediately

Implements DeviceAudio.

virtual bool DeviceAudioRt::soundStop unsigned int  sound  )  [virtual]
 

stops a specified sound immediately

Implements DeviceAudio.

virtual bool DeviceAudioRt::soundUpdate unsigned int  sound,
float  volumeL,
float  volumeR,
float  disparity = 0.0f,
float  pitch = 1.0f
[virtual]
 

updates parameters of a specified sound

Parameters:
sound handle of a currently active sound
volumeL left volume
volumeR right volume
disparity (optional) time difference between left and right channel in seconds. Use negative values to specify a delay for the left channel, positive for the right.
pitch (optional) pitch factor for playback. 0.5 corresponds to one octave below, 2.0 to one above the original sample.
Returns:
true in case the parameters have been updated successfully

Implements DeviceAudio.


Member Data Documentation

RtAudio DeviceAudioRt::m_dac [protected]
 

audio manager

unsigned int DeviceAudioRt::m_nSound [protected]
 

stores number of parallel sounds

unsigned int DeviceAudioRt::m_sampleCounter [protected]
 

stores maximum sample id

_AudioTrack* DeviceAudioRt::ma_sound [protected]
 

stores sounds to be mixed

std::map<unsigned int, AudioSample*> DeviceAudioRt::mm_sample [protected]
 

stores loaded sound samples


The documentation for this class was generated from the following file:
© 2009-02-04 by Gerald Franz, www.viremo.de impressum