SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
SoDa::AudioIfc Class Referenceabstract

Generic Audio Interface Class. More...

#include <AudioIfc.hxx>

Inheritance diagram for SoDa::AudioIfc:
SoDa::AudioQt

Public Member Functions

virtual int send (void *buf, unsigned int len, bool when_ready=false)=0
 send – send a buffer to the audio output
virtual bool sendBufferReady (unsigned int len)=0
 sendBufferReady – is there enough space in the audio device send buffer for a call from send?
virtual int recv (std::vector< float > &buf, bool when_ready=false)=0
 recv – get a buffer of data from the audio input
virtual bool recvBufferReady (unsigned int len)=0
 recvBufferReady – is there enough space in the audio device recv buffer for a call from recv?
virtual bool setOutGain (float gain)
 set the gain for the output device.
virtual bool setInGain (float gain)
 set the gain for the input device.
virtual float getOutGain ()
 get the gain for the output device.
virtual float getInGain ()
 get the gain for the input device.
virtual void sleepOut ()=0
 stop the output stream so that we don't encounter a buffer underflow while the reciever is muted.
virtual void wakeOut ()=0
 start the output stream
virtual void sleepIn ()=0
 stop the input stream so that we don't encounter a buffer overflow while the transmitter is inactive.
virtual void wakeIn ()=0
 start the input stream
virtual std::string currentPlaybackState ()
virtual std::string currentCaptureState ()

Protected Member Functions

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

Protected Attributes

unsigned int sample_rate
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, PA, or Qt via IP link.

Formerly, SoDaRadio used PortAudio, but this proved problematic. As of some version prior to 7.0, RX audio is passed through the unix domain socket interface to the Qt GUI, and TX audio is captured from an AudioALSA object.

Definition at line 51 of file AudioIfc.hxx.

Constructor & Destructor Documentation

◆ AudioIfc()

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

Definition at line 59 of file AudioIfc.hxx.

References datatype_size, sample_count_hint, and sample_rate.

Member Function Documentation

◆ currentCaptureState()

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

Reimplemented in SoDa::AudioQt.

Definition at line 161 of file AudioIfc.hxx.

◆ currentPlaybackState()

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

Reimplemented in SoDa::AudioQt.

Definition at line 160 of file AudioIfc.hxx.

◆ getInGain()

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

get the gain for the input device.

Returns
input gain

Definition at line 136 of file AudioIfc.hxx.

References in_gain.

◆ getOutGain()

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

get the gain for the output device.

Returns
the gain;

Definition at line 130 of file AudioIfc.hxx.

References out_gain.

◆ recv()

virtual int SoDa::AudioIfc::recv ( std::vector< float > & buf,
bool when_ready = false )
pure virtual

recv – get a buffer of data from the audio input

Parameters
bufvector of float samples from the audio input device
when_readyif true, test with recvBufferReady and return 0 if not ready otherwise perform the recv regardless.
Returns
number of elements transferred to the audio output

Implemented in SoDa::AudioQt.

◆ 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::AudioQt.

◆ send()

virtual int SoDa::AudioIfc::send ( void * buf,
unsigned int len,
bool when_ready = false )
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
when_readyif true, test with sendBufferReady and return 0 if not ready otherwise perform the send regardless.
Returns
number of elements transferred to the audio output, -1 if we got an underflow.

Implemented in SoDa::AudioQt.

◆ 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::AudioQt.

◆ 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 121 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 111 of file AudioIfc.hxx.

References out_gain.

◆ 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::AudioQt.

◆ 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::AudioQt.

◆ wakeIn()

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

start the input stream

Implemented in SoDa::AudioQt.

◆ wakeOut()

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

start the output stream

Implemented in SoDa::AudioQt.

Member Data Documentation

◆ datatype_size

int SoDa::AudioIfc::datatype_size
protected

Definition at line 170 of file AudioIfc.hxx.

Referenced by AudioIfc().

◆ in_gain

float SoDa::AudioIfc::in_gain
protected

Definition at line 167 of file AudioIfc.hxx.

Referenced by getInGain(), and setInGain().

◆ out_gain

float SoDa::AudioIfc::out_gain
protected

Definition at line 168 of file AudioIfc.hxx.

Referenced by getOutGain(), and setOutGain().

◆ sample_count_hint

unsigned int SoDa::AudioIfc::sample_count_hint
protected

Definition at line 165 of file AudioIfc.hxx.

Referenced by AudioIfc().

◆ sample_rate

unsigned int SoDa::AudioIfc::sample_rate
protected

Definition at line 164 of file AudioIfc.hxx.

Referenced by AudioIfc().


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