SoDaRadio-5.0.3-master:8901fb5
Public Member Functions | List of all members
SoDa::AudioPA Class Reference

the PortAudio interface class More...

#include <AudioPA.hxx>

Inheritance diagram for SoDa::AudioPA:
SoDa::AudioIfc SoDa::SoDaBase

Public Member Functions

 AudioPA (unsigned int _sample_rate, AudioIfc::DataFormat _fmt, unsigned int _sample_count_hint=1024)
 constructor More...
 
 ~AudioPA ()
 
int send (void *buf, unsigned int len)
 sendBuf – send a buffer to the audio output More...
 
bool sendBufferReady (unsigned int len)
 sendBufferReady – is there enough space in the audio device send buffer for a call from send? More...
 
int recv (void *buf, unsigned int len, bool block=true)
 recvBuf – get a buffer of data from the audio input More...
 
bool recvBufferReady (unsigned int len)
 recvBufferReady – is there enough space in the audio device recv buffer for a call from recv? More...
 
void sleepOut ()
 stop the output stream so that we don't encounter a buffer underflow while the reciever is muted. More...
 
void wakeOut ()
 start the output stream More...
 
void sleepIn ()
 stop the input stream so that we don't encounter a buffer overflow while the transmitter is inactive. More...
 
void wakeIn ()
 start the input stream More...
 
- Public Member Functions inherited from SoDa::AudioIfc
 AudioIfc (unsigned int _sample_rate, DataFormat _fmt, unsigned int _sample_count_hint, const std::string &name="AudioIfc")
 
virtual bool setOutGain (float gain)
 set the gain for the output device. More...
 
virtual bool setInGain (float gain)
 set the gain for the input device. More...
 
virtual float getOutGain ()
 get the gain for the output device. More...
 
virtual float getInGain ()
 get the gain for the input device. More...
 
virtual std::string currentPlaybackState ()
 
virtual std::string currentCaptureState ()
 
- Public Member Functions inherited from SoDa::SoDaBase
 SoDaBase (const std::string &oname)
 The constructor – pass a name for the object. More...
 
std::string & getObjName ()
 get the name of this object More...
 
SoDaBasefindSoDaObject (const std::string &oname)
 find a SoDa Object by name. More...
 
double getTime ()
 Get a time stamp in nS resolution that monotonically increases and that is very inexpensive (typically < 100nS). More...
 

Additional Inherited Members

- Public Types inherited from SoDa::AudioIfc
enum  DataFormat {
  FLOAT, DFLOAT, INT32, INT16,
  INT8
}
 
- Protected Attributes inherited from SoDa::AudioIfc
unsigned int sample_rate
 
DataFormat format
 
unsigned int sample_count_hint
 
float in_gain
 
float out_gain
 
int datatype_size
 

Detailed Description

the PortAudio interface class

AudioPA implements the interface specified by AudioIfc. It should be interchangable with other audio interface handlers.

The PortAudio stuff is nice, but the library is very noisy – it spews out lots of "informational" messages on the console. While the PA implementation of the Audio class might look simpler, it is not clear that it performs as well or is as clean as the ALSA PCM implementation, despite the fact that the latter is quite likely implemented on top of the former... sigh.

Definition at line 60 of file AudioPA.hxx.

Constructor & Destructor Documentation

◆ AudioPA()

SoDa::AudioPA::AudioPA ( unsigned int  _sample_rate,
AudioIfc::DataFormat  _fmt,
unsigned int  _sample_count_hint = 1024 
)

constructor

Parameters
_sample_ratein Hz – 48000 is a good choice
_fmt– the format of the data (FLOAT, DFLOAT, INT32, INT16, INT8)
_sample_count_hint– the size of the buffers passed to and from the audio device (in samples)

Definition at line 107 of file AudioPA.cxx.

◆ ~AudioPA()

SoDa::AudioPA::~AudioPA ( )
inline

Definition at line 70 of file AudioPA.hxx.

Member Function Documentation

◆ recv()

int SoDa::AudioPA::recv ( void *  buf,
unsigned int  len,
bool  block = true 
)
inlinevirtual

recvBuf – get a buffer of data from the audio input

Parameters
bufbuffer of type described by the DataFormat selected at init
lennumber of elements in the buffer to get
blockblock on this call if data is not ready (assumed true).
Returns
number of elements transferred from the audio input

Implements SoDa::AudioIfc.

Definition at line 93 of file AudioPA.hxx.

References PORTAUDIO_DEF.

◆ recvBufferReady()

bool SoDa::AudioPA::recvBufferReady ( unsigned int  len)
inlinevirtual

recvBufferReady – is there enough space in the audio device recv buffer for a call from recv?

Parameters
lenthe number of samples that we wish to get
Returns
true if there is sufficient space.

Implements SoDa::AudioIfc.

Definition at line 100 of file AudioPA.hxx.

References PORTAUDIO_DEF.

◆ send()

int SoDa::AudioPA::send ( void *  buf,
unsigned int  len 
)
inlinevirtual

sendBuf – send a buffer to the audio output

Parameters
bufbuffer of type described by the DataFormat selected at init
lennumber of elements in the buffer to send
Returns
number of elements transferred to the audio output

Implements SoDa::AudioIfc.

Definition at line 77 of file AudioPA.hxx.

References PORTAUDIO_DEF.

◆ sendBufferReady()

bool SoDa::AudioPA::sendBufferReady ( unsigned int  len)
inlinevirtual

sendBufferReady – is there enough space in the audio device send buffer for a call from send?

Parameters
lenthe number of samples that we wish to send
Returns
true if there is sufficient space.

Implements SoDa::AudioIfc.

Definition at line 84 of file AudioPA.hxx.

References PORTAUDIO_DEF.

◆ sleepIn()

void SoDa::AudioPA::sleepIn ( )
inlinevirtual

stop the input stream so that we don't encounter a buffer overflow while the transmitter is inactive.

Implements SoDa::AudioIfc.

Definition at line 126 of file AudioPA.hxx.

◆ sleepOut()

void SoDa::AudioPA::sleepOut ( )
inlinevirtual

stop the output stream so that we don't encounter a buffer underflow while the reciever is muted.

Implements SoDa::AudioIfc.

Definition at line 106 of file AudioPA.hxx.

◆ wakeIn()

void SoDa::AudioPA::wakeIn ( )
inlinevirtual

start the input stream

Implements SoDa::AudioIfc.

Definition at line 135 of file AudioPA.hxx.

References SoDa::SoDaBase::getObjName(), and PORTAUDIO_DEF.

◆ wakeOut()

void SoDa::AudioPA::wakeOut ( )
inlinevirtual

start the output stream

Implements SoDa::AudioIfc.

Definition at line 115 of file AudioPA.hxx.


The documentation for this class was generated from the following files: