#include <JackAudioInterface.h>
Public Member Functions | ||||
JackAudioInterface (JackTrip *jacktrip, int NumInChans, int NumOutChans, AudioInterface::audioBitResolutionT AudioBitResolution=AudioInterface::BIT16, const char *ClientName="JackTrip") | ||||
The class constructor. | ||||
virtual | ~JackAudioInterface () | |||
The class destructor. | ||||
virtual void | setup () | |||
Setup the client. | ||||
virtual void | close () | |||
Close the client and disconnects it from a JACK server. | ||||
virtual uint32_t | getSampleRate () const | |||
Get the Jack Server Sampling Rate, in samples/second. | ||||
virtual samplingRateT | getSampleRateType () const | |||
Get the Jack Server Sampling Rate Enum Type samplingRateT. | ||||
virtual uint32_t | getBufferSizeInSamples () const | |||
Get the Jack Server Buffer Size, in samples. | ||||
virtual uint32_t | getBufferSizeInBytes () const | |||
Get the Jack Server Buffer Size, in bytes. | ||||
virtual size_t | getSizeInBytesPerChannel () const | |||
Get size of each audio per channel, in bytes. | ||||
virtual int | startProcess () const | |||
Tell the JACK server that we are ready to roll. The process-callback will start running. This runs on its own thread. | ||||
virtual int | stopProcess () const | |||
Stops the process-callback thread. | ||||
void | connectDefaultPorts () | |||
Set the pointer to the Input and Output RingBuffer that'll be use to read and write audio. | ||||
virtual void | setClientName (const char *ClientName) | |||
Set Client Name to something different that the default (JackTrip). | ||||
Static Public Member Functions | ||||
static int | getSampleRateFromType (samplingRateT rate_type) | |||
Helper function to get the sample rate (in Hz) for a JackAudioInterface::samplingRateT. | ||||
Private Member Functions | ||||
void | setupClient () | |||
Private method to setup a client of the Jack server.
| ||||
void | createChannels () | |||
Creates input and output channels in the Jack client. | ||||
void | setProcessCallback () | |||
Sets the part of the process callback that sends and receive packets. | ||||
int | processCallback (jack_nframes_t nframes) | |||
JACK process callback. | ||||
Static Private Member Functions | ||||
static void | jackShutdown (void *) | |||
JACK calls this shutdown_callback if the server ever shuts down or decides to disconnect the client. | ||||
static int | wrapperProcessCallback (jack_nframes_t nframes, void *arg) | |||
Wrapper to cast the member processCallback to a static function pointer that can be used with jack_set_process_callback . | ||||
Private Attributes | ||||
int | mNumInChans | |||
Number of Input Channels. | ||||
int | mNumOutChans | |||
Number of Output Channels. | ||||
int | mNumFrames | |||
Buffer block size, in samples. | ||||
AudioInterface::audioBitResolutionT | mBitResolutionMode | |||
Bit resolution (audioBitResolutionT) mode. | ||||
jack_client_t * | mClient | |||
Jack Client. | ||||
const char * | mClientName | |||
Jack Client Name. | ||||
QVarLengthArray< jack_port_t * > | mInPorts | |||
Vector of Input Ports (Channels). | ||||
QVarLengthArray< jack_port_t * > | mOutPorts | |||
Vector of Output Ports (Channels). | ||||
QVarLengthArray< sample_t * > | mInBuffer | |||
Vector of Input buffers/channel read from JACK. | ||||
QVarLengthArray< sample_t * > | mOutBuffer | |||
Vector of Output buffer/channel to write to JACK. | ||||
QVarLengthArray< sample_t * > | mInProcessBuffer | |||
Vector of Input buffers/channel for ProcessPlugin. | ||||
QVarLengthArray< sample_t * > | mOutProcessBuffer | |||
Vector of Output buffers/channel for ProcessPlugin. | ||||
int8_t * | mInputPacket | |||
Packet containing all the channels to read from the RingBuffer. | ||||
int8_t * | mOutputPacket | |||
Packet containing all the channels to send to the RingBuffer. | ||||
size_t | mSizeInBytesPerChannel | |||
Size in bytes per audio channel. | ||||
QVector< ProcessPlugin * > | mProcessPlugins | |||
Vector of ProcesPlugins. | ||||
JackTrip * | mJackTrip | |||
JackTrip mediator class. | ||||
Static Private Attributes | ||||
static QMutex | sJackMutex | |||
Mutex to make thread safe jack functions that are not. |
JackAudioInterface::JackAudioInterface | ( | JackTrip * | jacktrip, | |
int | NumInChans, | |||
int | NumOutChans, | |||
AudioInterface::audioBitResolutionT | AudioBitResolution = AudioInterface::BIT16 , |
|||
const char * | ClientName = "JackTrip" | |||
) |
The class constructor.
jacktrip | Pointer to the JackTrip class that connects all classes (mediator) | |
NumInChans | Number of Input Channels | |
NumOutChans | Number of Output Channels | |
AudioBitResolution | Audio Sample Resolutions in bits | |
ClientName | Client name in Jack |
JackAudioInterface::~JackAudioInterface | ( | ) | [virtual] |
The class destructor.
void JackAudioInterface::setup | ( | ) | [virtual] |
void JackAudioInterface::close | ( | ) | [virtual] |
uint32_t JackAudioInterface::getSampleRate | ( | ) | const [virtual] |
JackAudioInterface::samplingRateT JackAudioInterface::getSampleRateType | ( | ) | const [virtual] |
Get the Jack Server Sampling Rate Enum Type samplingRateT.
Implements AudioInterface.
int JackAudioInterface::getSampleRateFromType | ( | samplingRateT | rate_type | ) | [static] |
Helper function to get the sample rate (in Hz) for a JackAudioInterface::samplingRateT.
rate_type | JackAudioInterface::samplingRateT enum type |
uint32_t JackAudioInterface::getBufferSizeInSamples | ( | ) | const [virtual] |
virtual uint32_t JackAudioInterface::getBufferSizeInBytes | ( | ) | const [inline, virtual] |
Get the Jack Server Buffer Size, in bytes.
size_t JackAudioInterface::getSizeInBytesPerChannel | ( | ) | const [virtual] |
int JackAudioInterface::startProcess | ( | ) | const [virtual] |
Tell the JACK server that we are ready to roll. The process-callback will start running. This runs on its own thread.
Implements AudioInterface.
int JackAudioInterface::stopProcess | ( | ) | const [virtual] |
Stops the process-callback thread.
Implements AudioInterface.
void JackAudioInterface::connectDefaultPorts | ( | ) | [virtual] |
Set the pointer to the Input and Output RingBuffer that'll be use to read and write audio.
These RingBuffers are used to read and write audio samples on each JACK callback.
InRingBuffer | RingBuffer to read samples from | |
OutRingBuffer | RingBuffer to write samples to Append a ProcessPlugin. The order of processing is determined by the order by which appending is done. | |
plugin | a ProcesPlugin smart pointer. Create the object instance using something like:std::tr1::shared_ptr<ProcessPluginName> loopback(new ProcessPluginName); Connect the default ports, capture to sends, and receives to playback |
Implements AudioInterface.
virtual void JackAudioInterface::setClientName | ( | const char * | ClientName | ) | [inline, virtual] |
void JackAudioInterface::setupClient | ( | ) | [private] |
Private method to setup a client of the Jack server.
std::runtime_error | Can't start Jack. |
This method is called by the class constructors. It does the following:
void JackAudioInterface::createChannels | ( | ) | [private] |
Creates input and output channels in the Jack client.
void JackAudioInterface::jackShutdown | ( | void * | ) | [static, private] |
JACK calls this shutdown_callback if the server ever shuts down or decides to disconnect the client.
void JackAudioInterface::setProcessCallback | ( | ) | [private] |
Sets the part of the process callback that sends and receive packets.
Compute the process to receive packets to JACK Compute the process from JACK to send packets Set the process callback of the member function processCallback. This process will be called by the JACK server whenever there is work to be done.
int JackAudioInterface::processCallback | ( | jack_nframes_t | nframes | ) | [private] |
JACK process callback.
This is the function to be called to process audio. This function is of the type JackProcessCallback, which is defined as:
typedef int(* JackProcessCallback)(jack_nframes_t nframes, void *arg)
See http://jackaudio.org/files/docs/html/types_8h.html#4923142208a8e7dacf00ca7a10681d2b for more details
int JackAudioInterface::wrapperProcessCallback | ( | jack_nframes_t | nframes, | |
void * | arg | |||
) | [static, private] |
Wrapper to cast the member processCallback to a static function pointer that can be used with jack_set_process_callback
.
jack_set_process_callback
needs a static member function pointer. A normal member function won't work because a this pointer is passed under the scenes. That's why we need to cast the member funcion processCallback to the static function wrapperProcessCallback. The callback is then set as:
jack_set_process_callback(mClient, JackAudioInterface::wrapperProcessCallback, this)
int JackAudioInterface::mNumInChans [private] |
int JackAudioInterface::mNumOutChans [private] |
int JackAudioInterface::mNumFrames [private] |
Buffer block size, in samples.
jack_client_t* JackAudioInterface::mClient [private] |
Jack Client.
const char* JackAudioInterface::mClientName [private] |
Jack Client Name.
QVarLengthArray<jack_port_t*> JackAudioInterface::mInPorts [private] |
Vector of Input Ports (Channels).
QVarLengthArray<jack_port_t*> JackAudioInterface::mOutPorts [private] |
Vector of Output Ports (Channels).
QVarLengthArray<sample_t*> JackAudioInterface::mInBuffer [private] |
Vector of Input buffers/channel read from JACK.
QVarLengthArray<sample_t*> JackAudioInterface::mOutBuffer [private] |
Vector of Output buffer/channel to write to JACK.
QVarLengthArray<sample_t*> JackAudioInterface::mInProcessBuffer [private] |
Vector of Input buffers/channel for ProcessPlugin.
QVarLengthArray<sample_t*> JackAudioInterface::mOutProcessBuffer [private] |
Vector of Output buffers/channel for ProcessPlugin.
int8_t* JackAudioInterface::mInputPacket [private] |
Packet containing all the channels to read from the RingBuffer.
int8_t* JackAudioInterface::mOutputPacket [private] |
Packet containing all the channels to send to the RingBuffer.
size_t JackAudioInterface::mSizeInBytesPerChannel [private] |
QVector<ProcessPlugin*> JackAudioInterface::mProcessPlugins [private] |
JackTrip* JackAudioInterface::mJackTrip [private] |
QMutex JackAudioInterface::sJackMutex [static, private] |
Mutex to make thread safe jack functions that are not.