JackTrip
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
AudioInterface Class Referenceabstract

Base Class that provides an interface with audio. More...

#include <AudioInterface.h>

Inheritance diagram for AudioInterface:
Inheritance graph
[legend]

Public Types

enum  audioBitResolutionT { BIT8 = 1, BIT16 = 2, BIT24 = 3, BIT32 = 4 }
 Enum for Audio Resolution in bits. More...
 
enum  samplingRateT {
  SR22, SR32, SR44, SR48,
  SR88, SR96, SR192, UNDEF
}
 Sampling Rates supported by JACK. More...
 

Public Member Functions

 AudioInterface (JackTrip *jacktrip, int NumInChans, int NumOutChans, AudioInterface::audioBitResolutionT AudioBitResolution=AudioInterface::BIT16)
 The class constructor. More...
 
virtual ~AudioInterface ()
 The class destructor. More...
 
virtual void setup ()
 Setup the client. This function should be called just before. More...
 
virtual int startProcess () const =0
 Tell the audio server that we are ready to roll. The process-callback will start running. This runs on its own thread. More...
 
virtual int stopProcess () const =0
 Stops the process-callback thread. More...
 
virtual void broadcastCallback (QVarLengthArray< sample_t * > &mon_buffer, unsigned int n_frames)
 Process callback. Subclass should call this callback after obtaining the in_buffer and out_buffer pointers. More...
 
virtual void callback (QVarLengthArray< sample_t * > &in_buffer, QVarLengthArray< sample_t * > &out_buffer, unsigned int n_frames)
 
virtual void appendProcessPluginToNetwork (ProcessPlugin *plugin)
 appendProcessPluginToNetwork(): Append a ProcessPlugin for outgoing audio. The processing order equals order they were appended. This processing is in the JackTrip client before sending to the network. More...
 
virtual void appendProcessPluginFromNetwork (ProcessPlugin *plugin)
 appendProcessPluginFromNetwork(): Same as appendProcessPluginToNetwork() except that these plugins operate on the audio received from the network (typically from a JackTrip server). The complete processing chain then looks like this: audio -> JACK -> JackTrip client -> processPlugin to network -> remote JackTrip server -> JackTrip client -> processPlugin from network -> JACK -> audio More...
 
void initPlugins ()
 initPlugins(): Initialize all ProcessPlugin modules. The audio sampling rate (mSampleRate) must be set at this time. More...
 
virtual void connectDefaultPorts ()=0
 
virtual void setNumInputChannels (int nchannels)
 
virtual void setNumOutputChannels (int nchannels)
 
virtual void setSampleRate (uint32_t sample_rate)
 
virtual void setDeviceID (uint32_t device_id)
 
virtual void setBufferSizeInSamples (uint32_t buf_size)
 
virtual void setClientName (QString ClientName)=0
 Set Client Name to something different that the default (JackTrip) More...
 
virtual void setLoopBack (bool b)
 
virtual void enableBroadcastOutput ()
 
virtual void setAudioTesterP (AudioTester *atp)
 
virtual int getNumInputChannels () const
 Get Number of Input Channels. More...
 
virtual int getNumOutputChannels () const
 Get Number of Output Channels. More...
 
virtual uint32_t getBufferSizeInSamples () const
 
virtual uint32_t getDeviceID () const
 
virtual size_t getSizeInBytesPerChannel () const
 
virtual uint32_t getSampleRate () const
 Get the Jack Server Sampling Rate, in samples/second. More...
 
virtual samplingRateT getSampleRateType () const
 Get the Jack Server Sampling Rate Enum Type samplingRateT. More...
 
virtual int getAudioBitResolution () const
 Get the Audio Bit Resolution, in bits. More...
 

Static Public Member Functions

static void fromSampleToBitConversion (const sample_t *const input, int8_t *output, const AudioInterface::audioBitResolutionT targetBitResolution)
 Convert a 32bit number (sample_t) into one of the bit resolution supported (audioBitResolutionT). More...
 
static void fromBitToSampleConversion (const int8_t *const input, sample_t *output, const AudioInterface::audioBitResolutionT sourceBitResolution)
 Convert a audioBitResolutionT bit resolution number into a 32bit number (sample_t) More...
 
static int getSampleRateFromType (samplingRateT rate_type)
 Helper function to get the sample rate (in Hz) for a JackAudioInterface::samplingRateT. More...
 

Protected Attributes

bool mProcessingAudio
 Set when processing an audio callback buffer pair. More...
 
const uint32_t MAX_AUDIO_BUFFER_SIZE = 8192
 

Detailed Description

Base Class that provides an interface with audio.

Member Enumeration Documentation

◆ audioBitResolutionT

Enum for Audio Resolution in bits.

Enumerator
BIT8 

8 bits

BIT16 

16 bits (default)

BIT24 

24 bits

BIT32 

32 bits

◆ samplingRateT

Sampling Rates supported by JACK.

Enumerator
SR22 

22050 Hz

SR32 

32000 Hz

SR44 

44100 Hz

SR48 

48000 Hz

SR88 

88200 Hz

SR96 

96000 Hz

SR192 

192000 Hz

UNDEF 

Undefined.

Constructor & Destructor Documentation

◆ AudioInterface()

AudioInterface::AudioInterface ( JackTrip jacktrip,
int  NumInChans,
int  NumOutChans,
AudioInterface::audioBitResolutionT  AudioBitResolution = AudioInterface::BIT16 
)

The class constructor.

Parameters
jacktripPointer to the JackTrip class that connects all classes (mediator)
NumInChansNumber of Input Channels
NumOutChansNumber of Output Channels
AudioBitResolutionAudio Sample Resolutions in bits

◆ ~AudioInterface()

AudioInterface::~AudioInterface ( )
virtual

The class destructor.

Member Function Documentation

◆ appendProcessPluginFromNetwork()

void AudioInterface::appendProcessPluginFromNetwork ( ProcessPlugin plugin)
virtual

appendProcessPluginFromNetwork(): Same as appendProcessPluginToNetwork() except that these plugins operate on the audio received from the network (typically from a JackTrip server). The complete processing chain then looks like this: audio -> JACK -> JackTrip client -> processPlugin to network -> remote JackTrip server -> JackTrip client -> processPlugin from network -> JACK -> audio

◆ appendProcessPluginToNetwork()

void AudioInterface::appendProcessPluginToNetwork ( ProcessPlugin plugin)
virtual

appendProcessPluginToNetwork(): Append a ProcessPlugin for outgoing audio. The processing order equals order they were appended. This processing is in the JackTrip client before sending to the network.

Parameters
plugina ProcessPlugin smart pointer. Create the object instance using something like:
std::tr1::shared_ptr<ProcessPluginName> loopback(new ProcessPluginName);

◆ broadcastCallback()

void AudioInterface::broadcastCallback ( QVarLengthArray< sample_t * > &  mon_buffer,
unsigned int  n_frames 
)
virtual

Process callback. Subclass should call this callback after obtaining the in_buffer and out_buffer pointers.

Parameters
in_bufferArray of input audio samplers for each channel. The user is reponsible to check that each channel has n_frames samplers
in_bufferArray of output audio samplers for each channel. The user is reponsible to check that each channel has n_frames samplers
Todo:
cast *mInBuffer[i] to the bit resolution

◆ callback()

void AudioInterface::callback ( QVarLengthArray< sample_t * > &  in_buffer,
QVarLengthArray< sample_t * > &  out_buffer,
unsigned int  n_frames 
)
virtual
Todo:
Implement for more than one process plugin, now it just works propertely with one. do it chaining outputs to inputs in the buffers. May need a tempo buffer

◆ connectDefaultPorts()

virtual void AudioInterface::connectDefaultPorts ( )
pure virtual

Implemented in RtAudioInterface, and JackAudioInterface.

◆ enableBroadcastOutput()

virtual void AudioInterface::enableBroadcastOutput ( )
inlinevirtual

Reimplemented in JackAudioInterface.

◆ fromBitToSampleConversion()

void AudioInterface::fromBitToSampleConversion ( const int8_t *const  input,
sample_t output,
const AudioInterface::audioBitResolutionT  sourceBitResolution 
)
static

Convert a audioBitResolutionT bit resolution number into a 32bit number (sample_t)

The result is stored in an sample_t array of the appropriate size to hold the value. The caller is responsible to allocate enough space to store the result.

◆ fromSampleToBitConversion()

void AudioInterface::fromSampleToBitConversion ( const sample_t *const  input,
int8_t output,
const AudioInterface::audioBitResolutionT  targetBitResolution 
)
static

Convert a 32bit number (sample_t) into one of the bit resolution supported (audioBitResolutionT).

The result is stored in an int_8 array of the appropriate size to hold the value. The caller is responsible to allocate enough space to store the result.

◆ getAudioBitResolution()

virtual int AudioInterface::getAudioBitResolution ( ) const
inlinevirtual

Get the Audio Bit Resolution, in bits.

This is one of the audioBitResolutionT set in construction

◆ getBufferSizeInSamples()

virtual uint32_t AudioInterface::getBufferSizeInSamples ( ) const
inlinevirtual

Reimplemented in JackAudioInterface.

◆ getDeviceID()

virtual uint32_t AudioInterface::getDeviceID ( ) const
inlinevirtual

◆ getNumInputChannels()

virtual int AudioInterface::getNumInputChannels ( ) const
inlinevirtual

Get Number of Input Channels.

◆ getNumOutputChannels()

virtual int AudioInterface::getNumOutputChannels ( ) const
inlinevirtual

Get Number of Output Channels.

◆ getSampleRate()

virtual uint32_t AudioInterface::getSampleRate ( ) const
inlinevirtual

Get the Jack Server Sampling Rate, in samples/second.

Reimplemented in JackAudioInterface.

◆ getSampleRateFromType()

int AudioInterface::getSampleRateFromType ( samplingRateT  rate_type)
static

Helper function to get the sample rate (in Hz) for a JackAudioInterface::samplingRateT.

Parameters
rate_typeJackAudioInterface::samplingRateT enum type
Returns
Sample Rate in Hz

◆ getSampleRateType()

AudioInterface::samplingRateT AudioInterface::getSampleRateType ( ) const
virtual

Get the Jack Server Sampling Rate Enum Type samplingRateT.

Returns
AudioInterface::samplingRateT enum type

◆ getSizeInBytesPerChannel()

size_t AudioInterface::getSizeInBytesPerChannel ( ) const
virtual

Reimplemented in JackAudioInterface.

◆ initPlugins()

void AudioInterface::initPlugins ( )

initPlugins(): Initialize all ProcessPlugin modules. The audio sampling rate (mSampleRate) must be set at this time.

◆ setAudioTesterP()

virtual void AudioInterface::setAudioTesterP ( AudioTester atp)
inlinevirtual

◆ setBufferSizeInSamples()

virtual void AudioInterface::setBufferSizeInSamples ( uint32_t  buf_size)
inlinevirtual

Reimplemented in JackAudioInterface.

◆ setClientName()

virtual void AudioInterface::setClientName ( QString  ClientName)
pure virtual

Set Client Name to something different that the default (JackTrip)

Implemented in JackAudioInterface.

◆ setDeviceID()

virtual void AudioInterface::setDeviceID ( uint32_t  device_id)
inlinevirtual

◆ setLoopBack()

virtual void AudioInterface::setLoopBack ( bool  b)
inlinevirtual

◆ setNumInputChannels()

virtual void AudioInterface::setNumInputChannels ( int  nchannels)
inlinevirtual

◆ setNumOutputChannels()

virtual void AudioInterface::setNumOutputChannels ( int  nchannels)
inlinevirtual

◆ setSampleRate()

virtual void AudioInterface::setSampleRate ( uint32_t  sample_rate)
inlinevirtual

Reimplemented in JackAudioInterface.

◆ setup()

void AudioInterface::setup ( )
virtual

Setup the client. This function should be called just before.

starting the audio processes, it will setup the audio client with the class parameters, like Sampling Rate, Packet Size, Bit Resolution, etc... Sub-classes should also call the parent method to ensure correct inizialization.

Reimplemented in RtAudioInterface, and JackAudioInterface.

◆ startProcess()

virtual int AudioInterface::startProcess ( ) const
pure virtual

Tell the audio server that we are ready to roll. The process-callback will start running. This runs on its own thread.

Returns
0 on success, otherwise a non-zero error code

Implemented in RtAudioInterface, and JackAudioInterface.

◆ stopProcess()

virtual int AudioInterface::stopProcess ( ) const
pure virtual

Stops the process-callback thread.

Returns
0 on success, otherwise a non-zero error code

Implemented in RtAudioInterface, and JackAudioInterface.

Member Data Documentation

◆ MAX_AUDIO_BUFFER_SIZE

const uint32_t AudioInterface::MAX_AUDIO_BUFFER_SIZE = 8192
protected

◆ mProcessingAudio

bool AudioInterface::mProcessingAudio
protected

Set when processing an audio callback buffer pair.


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