AudioSystemImpl Class Reference

#include <taptaudio_paimpl.h>

Inheritance diagram for AudioSystemImpl:

Inheritance graph
[legend]
Collaboration diagram for AudioSystemImpl:

Collaboration graph
[legend]
List of all members.

Detailed Description

The portaudio implementation of the audio system.

Definition at line 38 of file taptaudio_paimpl.h.

Public Types

typedef std::map< std::string,
ASSample * > 
REGISTRY
 Type for WAV file registry.

Public Member Functions

 AudioSystemImpl (unsigned inputChannels=1, unsigned outputChannels=2, double sampleRate=44100, AUDIO_FORMAT format=AF_Int16, int deviceIDin=0, int deviceIDout=0)
 Create an AudioSystemImpl.
virtual int callback (const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, Timestamp outTime)
 Portaudio callback.
bool freeSample (ASSample *samp)
virtual ASSample ** getSampleHolder (bool loop=false, float vol=1.0f, unsigned *trackno=0)
 Get a holder (e.g.
bool isRecording ()
ASSampleloadRawSample (const std::string &name, void *data, unsigned long size)
virtual ASSampleloadSample (const std::string &name)
 Load a "known" sample, or a file.
bool loopSample (ASSample *samp, float vol=1.0f, unsigned *trackno=0)
bool mixSample (ASSample *samp, bool record_after, double record_size, bool loop=false, float vol=1.0f, unsigned *trackno=0)
virtual unsigned setVolume (ASSample *, float=1.0f, int=-1)
bool startRec (double max_seconds)
void stop ()
ASSamplestopRec (const std::string &name, bool save=false, bool save_in_thread=false)
virtual unsigned stopSample (ASSample *samp, int trackno=-1, bool lock=true)
void waitstop ()
virtual ~AudioSystemImpl ()
 Virtual destructor, free the portaudio handles and clear the registry (?).

Static Public Member Functions

static void listDevices ()

Static Public Attributes

static SDL_mutex * as_mutex = SDL_CreateMutex()
 Audio System mutex.
static SDL_mutex * registry_mutex = SDL_CreateMutex()
 Registry mutex.

Protected Types

typedef PaTimestamp Timestamp
 The type used for time stamps in this version of portaudio.

Protected Member Functions

virtual void doPlay (void *outputBuffer, unsigned long framesPerBuffer, Timestamp outTime)
 Perform the "play" portion of the callback.
virtual void doRecord (const void *inputBuffer, unsigned long framesPerBuffer)
 Perform the "record" portion of the callback.

Protected Attributes

ASSamplecur_play
 For non-tracked implementations, the currently playing sample.
Recordingcur_rec
 The current recording (e.g. we are recording if this is non-null).
bool fakeMonoMic
 Are we "faking" a Mono input stream by averaging stereo channels.
AUDIO_FORMAT fmt
 The audio format.
unsigned iframe_size
 The size (in bytes) of an input frame.
unsigned inChannels
 Number of input channels.
unsigned oframe_size
 The size (in bytes) of an output frame.
unsigned outChannels
 Number of output channels.
unsigned long play_offset
 The current offset into cur_play.
Recordingrecord_after_play
 The recording we will start as soon as no samples are playing.
REGISTRY registry
 The registy of loaded WAV files.
double sampRate
 The sample rate of the audio stream.
bool stopping
 Are we trying to stop the audio system.
PortAudioStream * stream
 The portaudio strem handle.


Member Typedef Documentation

typedef std::map<std::string, ASSample*> REGISTRY
 

Type for WAV file registry.

Definition at line 43 of file taptaudio_paimpl.h.

typedef PaTimestamp Timestamp [protected]
 

The type used for time stamps in this version of portaudio.

Definition at line 50 of file taptaudio_paimpl.h.


Constructor & Destructor Documentation

~AudioSystemImpl  )  [virtual]
 

Virtual destructor, free the portaudio handles and clear the registry (?).

Definition at line 67 of file taptaudio_paimpl.cpp.

References DODEBUG, registry, and stream.

AudioSystemImpl unsigned  inputChannels = 1,
unsigned  outputChannels = 2,
double  sampleRate = 44100,
AUDIO_FORMAT  format = AF_Int16,
int  deviceIDin = 0,
int  deviceIDout = 0
 

Create an AudioSystemImpl.

Definition at line 87 of file taptaudio_paimpl.cpp.

References AF_Float32, AF_Int16, AF_Int24, AF_Int32, AF_Int8, AF_PackedInt24, AF_UInt8, DODEBUG, fakeMonoMic, fmt, iframe_size, inChannels, oframe_size, outChannels, sampRate, and stream.


Member Function Documentation

int callback const void *  inputBuffer,
void *  outputBuffer,
unsigned long  framesPerBuffer,
Timestamp  outTime
[virtual]
 

Portaudio callback.

Note:
occurs at interrupt level so we CAN NOT ALLOCATE MEMORY

Definition at line 195 of file taptaudio_paimpl.cpp.

References as_mutex, cur_rec, doPlay(), doRecord(), and stopping.

Here is the call graph for this function:

void doPlay void *  outputBuffer,
unsigned long  framesPerBuffer,
Timestamp  outTime
[protected, virtual]
 

Perform the "play" portion of the callback.

Definition at line 226 of file taptaudio_paimpl.cpp.

References cur_play, cur_rec, ASSample::getBytes(), ASSample::getChannels(), PCMSample::mono2stereo(), ASSample::numBytes(), oframe_size, outChannels, play_offset, record_after_play, and ASSample::refs.

Referenced by callback().

Here is the call graph for this function:

void doRecord const void *  inputBuffer,
unsigned long  framesPerBuffer
[protected, virtual]
 

Perform the "record" portion of the callback.

Definition at line 212 of file taptaudio_paimpl.cpp.

References cur_rec, fakeMonoMic, Recording::fill(), Recording::fillSilence(), iframe_size, and Recording::skipfill().

Referenced by callback().

Here is the call graph for this function:

ASSample ** getSampleHolder bool  loop = false,
float  vol = 1.0f,
unsigned *  trackno = 0
[virtual]
 

Get a holder (e.g.

a track reference) in which to load a sample.

Reimplemented in AudioSystemMixer.

Definition at line 351 of file taptaudio_paimpl.cpp.

References cur_play, and play_offset.

Referenced by mixSample().

ASSample * loadSample const std::string &  name  )  [virtual]
 

Load a "known" sample, or a file.

Reimplemented in AudioSystemMixerT.

Definition at line 266 of file taptaudio_paimpl.cpp.

References DODEBUG, fmt, ASSample::getChannels(), ASSample::getFormat(), ASSample::getSamRate(), outChannels, registry, registry_mutex, and sampRate.

Referenced by AudioSystem::loadSample().

Here is the call graph for this function:


Member Data Documentation

SDL_mutex * as_mutex = SDL_CreateMutex() [static]
 

Audio System mutex.

Definition at line 12 of file taptaudio_paimpl.cpp.

Referenced by AudioSystem::AudioSystem(), callback(), freeSample(), mixSample(), AudioSystemMixer::setVolume(), startRec(), stopRec(), AudioSystemMixer::stopSample(), and stopSample().

ASSample* cur_play [protected]
 

For non-tracked implementations, the currently playing sample.

Definition at line 68 of file taptaudio_paimpl.h.

Referenced by doPlay(), getSampleHolder(), and stopSample().

Recording* cur_rec [protected]
 

The current recording (e.g. we are recording if this is non-null).

Definition at line 65 of file taptaudio_paimpl.h.

Referenced by callback(), doPlay(), doRecord(), isRecording(), mixSample(), startRec(), and stopRec().

bool fakeMonoMic [protected]
 

Are we "faking" a Mono input stream by averaging stereo channels.

Definition at line 56 of file taptaudio_paimpl.h.

Referenced by AudioSystemImpl(), and doRecord().

AUDIO_FORMAT fmt [protected]
 

The audio format.

Definition at line 60 of file taptaudio_paimpl.h.

Referenced by AudioSystemImpl(), loadRawSample(), loadSample(), mixSample(), and startRec().

unsigned iframe_size [protected]
 

The size (in bytes) of an input frame.

Definition at line 62 of file taptaudio_paimpl.h.

Referenced by AudioSystemImpl(), doRecord(), mixSample(), and startRec().

unsigned inChannels [protected]
 

Number of input channels.

Definition at line 57 of file taptaudio_paimpl.h.

Referenced by AudioSystemImpl(), mixSample(), and startRec().

unsigned oframe_size [protected]
 

The size (in bytes) of an output frame.

Definition at line 63 of file taptaudio_paimpl.h.

Referenced by AudioSystemImpl(), and doPlay().

unsigned outChannels [protected]
 

Number of output channels.

Definition at line 58 of file taptaudio_paimpl.h.

Referenced by AudioSystemImpl(), doPlay(), loadRawSample(), AudioSystemMixerT::loadSample(), loadSample(), and mixSample().

unsigned long play_offset [protected]
 

The current offset into cur_play.

Definition at line 69 of file taptaudio_paimpl.h.

Referenced by doPlay(), and getSampleHolder().

Recording* record_after_play [protected]
 

The recording we will start as soon as no samples are playing.

Definition at line 66 of file taptaudio_paimpl.h.

Referenced by doPlay(), mixSample(), and startRec().

REGISTRY registry [protected]
 

The registy of loaded WAV files.

Definition at line 47 of file taptaudio_paimpl.h.

Referenced by freeSample(), loadRawSample(), AudioSystemMixerT::loadSample(), loadSample(), stopRec(), and ~AudioSystemImpl().

SDL_mutex * registry_mutex = SDL_CreateMutex() [static]
 

Registry mutex.

Definition at line 13 of file taptaudio_paimpl.cpp.

Referenced by freeSample(), loadRawSample(), AudioSystemMixerT::loadSample(), loadSample(), and stopRec().

double sampRate [protected]
 

The sample rate of the audio stream.

Definition at line 59 of file taptaudio_paimpl.h.

Referenced by AudioSystemImpl(), loadRawSample(), AudioSystemMixerT::loadSample(), loadSample(), mixSample(), and startRec().

bool stopping [protected]
 

Are we trying to stop the audio system.

Definition at line 55 of file taptaudio_paimpl.h.

Referenced by callback(), and stop().

PortAudioStream* stream [protected]
 

The portaudio strem handle.

Definition at line 49 of file taptaudio_paimpl.h.

Referenced by AudioSystemImpl(), and ~AudioSystemImpl().


The documentation for this class was generated from the following files:
Generated on Fri Aug 5 19:43:32 2005 for TaptAudio by  doxygen 1.4.3