SoDaRadio-5.0.3-master:8901fb5
Public Types | Public Member Functions | Protected Attributes | List of all members
SoDa::AudioIfc Class Referenceabstract

Generic Audio Interface Class. More...

#include <AudioIfc.hxx>

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

Public Types

enum  DataFormat {
  FLOAT, DFLOAT, INT32, INT16,
  INT8
}
 

Public Member Functions

 AudioIfc (unsigned int _sample_rate, DataFormat _fmt, unsigned int _sample_count_hint, const std::string &name="AudioIfc")
 
virtual int send (void *buf, unsigned int len)=0
 send – send a buffer to the audio output More...
 
virtual bool sendBufferReady (unsigned int len)=0
 sendBufferReady – is there enough space in the audio device send buffer for a call from send? More...
 
virtual int recv (void *buf, unsigned int len, bool block=true)=0
 recv – get a buffer of data from the audio input More...
 
virtual bool recvBufferReady (unsigned int len)=0
 recvBufferReady – is there enough space in the audio device recv buffer for a call from recv? More...
 
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 void sleepOut ()=0
 stop the output stream so that we don't encounter a buffer underflow while the reciever is muted. More...
 
virtual void wakeOut ()=0
 start the output stream More...
 
virtual void sleepIn ()=0
 stop the input stream so that we don't encounter a buffer overflow while the transmitter is inactive. More...
 
virtual void wakeIn ()=0
 start the input stream 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...
 

Protected Attributes

unsigned int sample_rate
 
DataFormat format
 
unsigned int sample_count_hint
 
float in_gain
 
float out_gain
 
int datatype_size
 

Detailed Description

Generic Audio Interface Class.

This is a pure virtual class that is the interface spec for whatever actual audio interface is provided. The spec is suitable for implementations using ALSA (

See also
AudioALSA), Port Audio (
AudioPA), and an IP link. The network interface has not yet been implemented.

Definition at line 44 of file AudioIfc.hxx.

Member Enumeration Documentation

◆ DataFormat

Enumerator
FLOAT 
DFLOAT 
INT32 
INT16 
INT8 

Definition at line 46 of file AudioIfc.hxx.

Constructor & Destructor Documentation

◆ AudioIfc()

SoDa::AudioIfc::AudioIfc ( unsigned int  _sample_rate,
DataFormat  _fmt,
unsigned int  _sample_count_hint,
const std::string &  name = "AudioIfc" 
)
inline

Member Function Documentation

◆ currentCaptureState()

virtual std::string SoDa::AudioIfc::currentCaptureState ( )
inlinevirtual

Definition at line 166 of file AudioIfc.hxx.

Referenced by SoDa::AudioALSA::wakeIn().

◆ currentPlaybackState()

virtual std::string SoDa::AudioIfc::currentPlaybackState ( )
inlinevirtual

Definition at line 165 of file AudioIfc.hxx.

Referenced by SoDa::BaseBandRX::run(), and SoDa::AudioALSA::wakeIn().

◆ getInGain()

virtual float SoDa::AudioIfc::getInGain ( )
inlinevirtual

get the gain for the input device.

Returns
input gain

Definition at line 141 of file AudioIfc.hxx.

References in_gain, sleepIn(), sleepOut(), wakeIn(), and wakeOut().

◆ getOutGain()

virtual float SoDa::AudioIfc::getOutGain ( )
inlinevirtual

get the gain for the output device.

Returns
the gain;

Definition at line 135 of file AudioIfc.hxx.

References out_gain.

◆ recv()

virtual int SoDa::AudioIfc::recv ( void *  buf,
unsigned int  len,
bool  block = true 
)
pure virtual

recv – 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 send
blockblock on this call if no data is available (ignored)
Returns
number of elements transferred to the audio output

Implemented in SoDa::AudioALSA, and SoDa::AudioPA.

Referenced by AudioIfc(), main(), and SoDa::BaseBandTX::run().

◆ recvBufferReady()

virtual bool SoDa::AudioIfc::recvBufferReady ( unsigned int  len)
pure virtual

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.

Implemented in SoDa::AudioALSA, and SoDa::AudioPA.

Referenced by AudioIfc(), main(), and SoDa::BaseBandTX::run().

◆ send()

virtual int SoDa::AudioIfc::send ( void *  buf,
unsigned int  len 
)
pure virtual

send – 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

Implemented in SoDa::AudioALSA, and SoDa::AudioPA.

Referenced by AudioIfc(), main(), and SoDa::BaseBandRX::run().

◆ sendBufferReady()

virtual bool SoDa::AudioIfc::sendBufferReady ( unsigned int  len)
pure virtual

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.

Implemented in SoDa::AudioALSA, and SoDa::AudioPA.

Referenced by AudioIfc(), main(), and SoDa::BaseBandRX::run().

◆ setInGain()

virtual bool SoDa::AudioIfc::setInGain ( float  gain)
inlinevirtual

set the gain for the input device.

Parameters
gain– range from 0 to 1.0
Returns
true if gain was set, false otherwise.

Definition at line 126 of file AudioIfc.hxx.

References in_gain.

◆ setOutGain()

virtual bool SoDa::AudioIfc::setOutGain ( float  gain)
inlinevirtual

set the gain for the output device.

Parameters
gain– range from 0 to 1.0
Returns
true if gain was set, false otherwise.

Definition at line 116 of file AudioIfc.hxx.

References out_gain.

Referenced by main().

◆ sleepIn()

virtual void SoDa::AudioIfc::sleepIn ( )
pure virtual

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

This should also flush all incoming buffers. (Virtual audio devices can get ahead of the processing by a good bit.)

Implemented in SoDa::AudioALSA, and SoDa::AudioPA.

Referenced by getInGain(), and main().

◆ sleepOut()

virtual void SoDa::AudioIfc::sleepOut ( )
pure virtual

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

Implemented in SoDa::AudioALSA, and SoDa::AudioPA.

Referenced by SoDa::BaseBandRX::execSetCommand(), and getInGain().

◆ wakeIn()

virtual void SoDa::AudioIfc::wakeIn ( )
pure virtual

start the input stream

Implemented in SoDa::AudioALSA, and SoDa::AudioPA.

Referenced by getInGain(), main(), and SoDa::BaseBandTX::run().

◆ wakeOut()

virtual void SoDa::AudioIfc::wakeOut ( )
pure virtual

start the output stream

Implemented in SoDa::AudioALSA, and SoDa::AudioPA.

Referenced by SoDa::BaseBandRX::execSetCommand(), getInGain(), and SoDa::BaseBandRX::run().

Member Data Documentation

◆ datatype_size

int SoDa::AudioIfc::datatype_size
protected

Definition at line 176 of file AudioIfc.hxx.

Referenced by AudioIfc().

◆ format

DataFormat SoDa::AudioIfc::format
protected

Definition at line 170 of file AudioIfc.hxx.

Referenced by AudioIfc().

◆ in_gain

float SoDa::AudioIfc::in_gain
protected

Definition at line 173 of file AudioIfc.hxx.

Referenced by getInGain(), and setInGain().

◆ out_gain

float SoDa::AudioIfc::out_gain
protected

Definition at line 174 of file AudioIfc.hxx.

Referenced by getOutGain(), and setOutGain().

◆ sample_count_hint

unsigned int SoDa::AudioIfc::sample_count_hint
protected

Definition at line 171 of file AudioIfc.hxx.

Referenced by AudioIfc().

◆ sample_rate

unsigned int SoDa::AudioIfc::sample_rate
protected

Definition at line 169 of file AudioIfc.hxx.

Referenced by AudioIfc().


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