Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions

JackCpp::AudioIO Class Reference

This is an abstract class that provides a jack callback method. More...

#include <jackaudioio.hpp>

Inheritance diagram for JackCpp::AudioIO:
JackCpp::BlockingAudioIO

List of all members.

Public Types

enum  jack_state_t { notActive, active, closed }
 

An enum indicating the state of our jack client.


typedef std::vector
< jack_default_audio_sample_t * > 
audioBufVector
 A typedef so so that we don't always have to write std::vector<jack_default_audio_sample_t *>

Public Member Functions

 AudioIO (std::string name, unsigned int inPorts=0, unsigned int outPorts=2, bool startServer=true) throw (std::runtime_error)
 The Constructor.
virtual ~AudioIO ()
 The Destructor.
bool portExists (std::string name)
 See if a port with the name "name" exists for our client.
virtual void reserveOutPorts (unsigned int num) throw (std::runtime_error)
 Reserve output ports.
virtual void reserveInPorts (unsigned int num) throw (std::runtime_error)
 Reserve input ports.
void start () throw (std::runtime_error)
 Start the jack client.
void stop () throw (std::runtime_error)
 Stop the jack client.
void close () throw (std::runtime_error)
 Close the jack client.
unsigned int inPorts ()
 Get the number of jack input ports.
unsigned int outPorts ()
 Get the number of jack output ports.
virtual unsigned int addInPort (std::string name) throw (std::runtime_error)
 Add a jack input port to our client.
virtual unsigned int addOutPort (std::string name) throw (std::runtime_error)
 Add a jack output port to our client.
void connectTo (unsigned int index, std::string sourcePortName) throw (std::range_error, std::runtime_error)
 Connect our output to a jack client's source port.
void connectFrom (unsigned int index, std::string destPortName) throw (std::range_error, std::runtime_error)
 Connect our input to a jack client's destination port.
void connectToPhysical (unsigned int index, unsigned physical_index) throw (std::range_error, std::runtime_error)
 Connect our output port to a physical output port.
void connectFromPhysical (unsigned int index, unsigned physical_index) throw (std::range_error, std::runtime_error)
 Connect our input port to a physical input port.
void disconnectInPort (unsigned int index) throw (std::range_error, std::runtime_error)
 Disconnect input port from all connections.
void disconnectOutPort (unsigned int index) throw (std::range_error, std::runtime_error)
 Disconnect output port from all connections.
unsigned int numConnectionsInPort (unsigned int index) throw (std::range_error)
 Get the number of connections to our input port.
unsigned int numConnectionsOutPort (unsigned int index) throw (std::range_error)
 Get the number of connections to our output port.
unsigned int numPhysicalSourcePorts ()
 Get the number of physical audio input ports These are ports that can send audio to your client.
unsigned int numPhysicalDestinationPorts ()
 Get the number of physical audio output ports These are ports that your client can send audio to.
std::string getInputPortName (unsigned int index) throw (std::range_error)
 Get the name of our client's input port.
std::string getOutputPortName (unsigned int index) throw (std::range_error)
 Get the name of our client's output port.
virtual void jackShutdownCallback ()
 This method is called when Jack shuts down. Override if you want to do something when jack shuts down.
float getCpuLoad ()
 The current CPU load estimated by JACK.
jack_nframes_t getSampleRate ()
 Get the sample rate.
jack_nframes_t getBufferSize ()
 Get the jack buffer size.
bool isRealTime ()
 Check to see if the client is running in real time mode.
std::string getName ()
 Get the name of our client.
jack_state_t getState ()
 Get the state of our Jack client.
jack_nframes_t getFrameTime ()
 Get an estimate of the current time in frames.
jack_nframes_t getFramesSinceCycleStart ()
 Get the time in frames since the JACK server began the current process cycle.

Static Public Member Functions

static int jackProcessCallback (jack_nframes_t nframes, void *arg)
 The callback that jack actually gets [static].

Protected Member Functions

virtual int audioCallback (jack_nframes_t nframes, audioBufVector inBufs, audioBufVector outBufs)=0
 The method that the user must overload in order to actually process jack data.
jack_client_t * client ()
 Gives users a pointer to the client created and used by this class.

Detailed Description

This is an abstract class that provides a jack callback method.

This abstract class wraps the Jack Audio IO functionality needed for basic audio input and output. In order to create your own jack client you simply make your own class that inherits from this class and overloads audioCallback. In that method you can get audio in from jack and write it out to jack.

Author:
Alex Norman

Constructor & Destructor Documentation

JackCpp::AudioIO::AudioIO ( std::string  name,
unsigned int  inPorts = 0,
unsigned int  outPorts = 2,
bool  startServer = true 
) throw (std::runtime_error)

The Constructor.

Parameters:
name string indicating the name of the jack client to create
inPorts an unsigned integer indicating the number of default input ports to create
outPorts an unsigned integer indicating the number of default output ports to create
startServer a boolean indicating whether to start a jack server if one isn't already running
See also:
audioCallback

Member Function Documentation

virtual unsigned int JackCpp::AudioIO::addInPort ( std::string  name  )  throw (std::runtime_error) [virtual]

Add a jack input port to our client.

Parameters:
name string the name of the port to add
Returns:
the number of total input ports

Reimplemented in JackCpp::BlockingAudioIO.

virtual unsigned int JackCpp::AudioIO::addOutPort ( std::string  name  )  throw (std::runtime_error) [virtual]

Add a jack output port to our client.

Parameters:
name string the name of the port to add
Returns:
the number of total output ports

Reimplemented in JackCpp::BlockingAudioIO.

virtual int JackCpp::AudioIO::audioCallback ( jack_nframes_t  nframes,
audioBufVector  inBufs,
audioBufVector  outBufs 
) [protected, pure virtual]

The method that the user must overload in order to actually process jack data.

Parameters:
nframes the number frames to process
inBufs a vector of audio buffers
outBufs a vector of audio buffers
Returns:
0 on success, non zero on error, which will cause jack to remove the client from the process graph
jack_client_t* JackCpp::AudioIO::client (  )  [protected]

Gives users a pointer to the client created and used by this class.

Returns:
a pointer to the jack client used by this class.
void JackCpp::AudioIO::connectFrom ( unsigned int  index,
std::string  destPortName 
) throw (std::range_error, std::runtime_error)

Connect our input to a jack client's destination port.

Parameters:
index the index of our input port to connect to
destPortName the client:port name to connect from
void JackCpp::AudioIO::connectFromPhysical ( unsigned int  index,
unsigned  physical_index 
) throw (std::range_error, std::runtime_error)

Connect our input port to a physical input port.

Parameters:
index the index of our input port to connect to
physical_index the physical input port index to connect from
void JackCpp::AudioIO::connectTo ( unsigned int  index,
std::string  sourcePortName 
) throw (std::range_error, std::runtime_error)

Connect our output to a jack client's source port.

Parameters:
index the index of our output port to connect from.
sourcePortName the client:port name to connect to
void JackCpp::AudioIO::connectToPhysical ( unsigned int  index,
unsigned  physical_index 
) throw (std::range_error, std::runtime_error)

Connect our output port to a physical output port.

Parameters:
index the index of our output port to connect from
physical_index the physical output port index to connect to
float JackCpp::AudioIO::getCpuLoad (  ) 

The current CPU load estimated by JACK.

This is a running average of the time it takes to execute a full process cycle for all clients as a percentage of the real time available per cycle determined by the buffer size and sample rate.

jack_nframes_t JackCpp::AudioIO::getFramesSinceCycleStart (  )  [inline]

Get the time in frames since the JACK server began the current process cycle.

Returns:
the time in frames that has passed since the JACK server began the current process cycle
jack_nframes_t JackCpp::AudioIO::getFrameTime (  )  [inline]

Get an estimate of the current time in frames.

This is a running counter, no significance should be attached to its value, but it can be compared to a previously returned value.

Returns:
an estimate of the current time in frames.
std::string JackCpp::AudioIO::getName (  )  [inline]

Get the name of our client.

This might not be exactly the same as the name we provided to the constructor

Returns:
a string indicating the name of our client.
static int JackCpp::AudioIO::jackProcessCallback ( jack_nframes_t  nframes,
void *  arg 
) [static]

The callback that jack actually gets [static].

This is a static method that the C jack callback calls, users should not need to override this method.

Parameters:
nframes the number frames to process
arg a pointer to our AudioIO object
Returns:
the actual number of frames processed
See also:
audioCallback
virtual void JackCpp::AudioIO::reserveInPorts ( unsigned int  num  )  throw (std::runtime_error) [virtual]

Reserve input ports.

This method must be called before the client is started. This reserves a number of ports so that they can be safely created while the client is running. The number indicates the maximum number of ports that can be created while the client is running. This number includes those ports that a have already been created, so if you've already created x ports and you reserve y ports total, you can only create y - x ports while the client is running.

Parameters:
num an integer indicating the number of input ports to reserve

Reimplemented in JackCpp::BlockingAudioIO.

virtual void JackCpp::AudioIO::reserveOutPorts ( unsigned int  num  )  throw (std::runtime_error) [virtual]

Reserve output ports.

This method must be called before the client is started. This reserves a number of ports so that they can be safely created while the client is running. The number indicates the maximum number of ports that can be created while the client is running. This number includes those ports that a have already been created, so if you've already created x ports and you reserve y ports total, you can only create y - x ports while the client is running.

Parameters:
num an integer indicating the number of output ports to reserve

Reimplemented in JackCpp::BlockingAudioIO.


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