gtkIOStream  1.6.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JackClient Class Referenceabstract

#include <JackClient.H>

Inheritance diagram for JackClient:
[legend]
Collaboration diagram for JackClient:
[legend]

Public Member Functions

 JackClient (void)
 
 JackClient (string clientName_)
 
virtual ~JackClient ()
 Destructor. More...
 
virtual int connect (string clientName_)
 
virtual int connect (const string &clientName_, const string &serverName)
 
virtual int getBlockSize ()
 
int setBlockSize (int size)
 
virtual int startClient ()
 
virtual int startClient (int inCnt, int outCnt, bool doConnect=true)
 
- Public Member Functions inherited from JackBase
 JackBase ()
 
 JackBase (string clientName_)
 
 JackBase (string clientName_, string serverName)
 
virtual ~JackBase ()
 Destructor. More...
 
virtual int stopClient (void)
 
virtual int disconnect (void)
 
int getSampleRate (void) const
 
virtual int createPorts (string inName, int inCnt, string outName, int outCnt)
 
virtual int destroyPorts ()
 
void getPhysicalPorts (vector< jack_port_t * > &inPorts, vector< jack_port_t * > &outPorts)
 
void getPhysicalPortCount (int &in, int &out)
 
bool connected ()
 
virtual void print (ostream &os)
 
string getClientName ()
 
virtual void setClientName (string cn)
 
string portNameFromPort (jack_port_id_t p)
 
string portNameFromPort (jack_port_t *p)
 
string clientNameFromPort (jack_port_id_t p)
 
string clientNameFromPort (jack_port_t *p)
 
string clientNameFromPortName (string fullPortName)
 
string clientNameFromPortNames (string fullPortName, string shortPortName)
 
string shortPortNameFromPortName (const string fullPortName)
 
bool operator== (const string &cn)
 
int getInputPortSize ()
 
jack_port_t * getInputPort (int i)
 
jack_port_t * getOutputPort (int i)
 
void addInputPort (jack_port_t *inP)
 
void addOutputPort (jack_port_t *outP)
 
int populatInOutPorts (const string &inName, vector< string > &inPorts, const string &outName, vector< string > &outPorts)
 
int connectPorts (const string inName, const string outName)
 
virtual int disconnectPorts (const string &inName, const string &outName)
 
void setClient (jack_client_t *c)
 

Protected Member Functions

virtual int processAudio (jack_nframes_t nframes)=0
 
virtual int bufferSizeChange (jack_nframes_t nframes)
 
- Protected Member Functions inherited from JackBase
virtual void determineLatencies ()
 
int getPortListAndCount (JackPortFlags flags, vector< jack_port_t * > *ports, const char *portNamePattern, const char *typeNamePattern)
 
int getPortListAndCount (JackPortFlags flags, vector< string > *ports, const char *portNamePattern, const char *typeNamePattern)
 
virtual void reSyncPorts (void)
 
virtual void reSyncConnections (void)
 

Static Private Member Functions

static int processAudioStatic (jack_nframes_t nframes, void *arg)
 
static int bufferSizeChangeStatic (jack_nframes_t nframes, void *arg)
 

Additional Inherited Members

- Public Attributes inherited from JackBase
bool connect1To1
 When true, then connections are made in a 1 to 1 manner. When False, then connections are made in an all to all manner. More...
 
- Protected Attributes inherited from JackBase
jack_client_t * client
 The jack client. More...
 
string clientName
 The name of this client. More...
 
jack_options_t jackOptions
 Options for jack. More...
 
jack_status_t status
 The status of jack. More...
 
int physicalInputPortCnt
 The number of physical input ports. More...
 
int physicalOutputPortCnt
 The number of physical input ports. More...
 
vector< jack_port_t * > inputPorts
 The input ports. More...
 
vector< jack_port_t * > outputPorts
 The output ports. More...
 
vector< jack_nframes_t > inputLatencies
 The input latencies, one for each port. More...
 
vector< jack_nframes_t > outputLatencies
 The output latencies, one for each port. More...
 

Detailed Description

Class to connect to a jack server as a client, see : http://jackaudio.org/

This client auto-connects the output and input ports to the first available ports.

See JackClientTest.C for an example, however usage is like so :

class TestJackClient : public JackClient {
int processAudio(jack_nframes_t nframes) {
jack_default_audio_sample_t *out = ( jack_default_audio_sample_t* ) jack_port_get_buffer ( outputPorts[0], nframes );
// load the output audio samples here
// do something with the audio samples here
jack_default_audio_sample_t *in = ( jack_default_audio_sample_t* ) jack_port_get_buffer ( inputPorts[0], nframes );
// do something with the input audio samples here
return 0;
}
};
TestJackClient jackClient; // init the jack client
// at each step check that res isn't indicating an error...
int res=jackClient.connect("jack test client"); // connect the client to the Jack system indicating the callback
res=jackClient.createPorts("in ", 1, "out ", 1); // create the ports for the jack patching system.
res=jackClient.startClient(1, 1, true); // Start the client running with one input and one output port, which is auto-connected to the system ports
// at this point, the processAudio is called each time audio samples are available by the jack system.
// don't exit the program until you have finished processing all the audio you want to !
Examples:
JackClientTest.C.

Definition at line 56 of file JackClient.H.

Constructor & Destructor Documentation

JackClient::JackClient ( void  )
inline

Constructor.

Definition at line 98 of file JackClient.H.

JackClient::JackClient ( string  clientName_)
inline

Constructor. Connecting the client to the default server.

Parameters
clientName_The client name, which will initiate a server connection.

Definition at line 103 of file JackClient.H.

virtual JackClient::~JackClient ( )
inlinevirtual

Destructor.

Definition at line 106 of file JackClient.H.

Here is the call graph for this function:

Member Function Documentation

virtual int JackClient::bufferSizeChange ( jack_nframes_t  nframes)
inlineprotectedvirtual

The Jack client callback - to be implemented by your inheriting class if you need to do things when the buffer size changes

Parameters
nframesThe number of frames to process when processAudio is called.
Returns
0 on success, a different number on error.

Definition at line 90 of file JackClient.H.

Here is the caller graph for this function:

static int JackClient::bufferSizeChangeStatic ( jack_nframes_t  nframes,
void *  arg 
)
inlinestaticprivate

This is the callback triggered when the buffer size changes. Callback to pass to the jack server using JackClient::connect. You must overload bufferSizeChange as that is where the processing is done in your class.

See also
bufferSizeChange
Parameters
nframesThe number of frames to process
argthe user data

< The Jack client callback

Definition at line 75 of file JackClient.H.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int JackClient::connect ( string  clientName_)
inlinevirtual

Connect to the server This starts the server and sets up the process callback/arg to use.

Parameters
clientName_The name of the client to use
Returns
NO_ERROR on success

Reimplemented from JackBase.

Examples:
JackClientTest.C.

Definition at line 115 of file JackClient.H.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int JackClient::connect ( const string &  clientName_,
const string &  serverName 
)
inlinevirtual

Connect to the server This starts the server and sets up the process callback/arg to use.

Parameters
clientName_The name of the client to use
serverNameThe name of the server to use
Returns
NO_ERROR on success

Reimplemented from JackBase.

Definition at line 125 of file JackClient.H.

Here is the call graph for this function:

virtual int JackClient::getBlockSize ( )
inlinevirtual

Get the server buffer size (block size)

Returns
the current buffer size
Examples:
JackClientTest.C.

Definition at line 140 of file JackClient.H.

Here is the caller graph for this function:

virtual int JackClient::processAudio ( jack_nframes_t  nframes)
protectedpure virtual

The Jack client callback - to be implemented by your inheriting class

Parameters
nframesThe number of frames to process.
Returns
0 to keep processing, a different number on error.

Implemented in TestJackClient, WSOLAJack, CrossoverAudio, and MixerTestAudio.

Here is the caller graph for this function:

static int JackClient::processAudioStatic ( jack_nframes_t  nframes,
void *  arg 
)
inlinestaticprivate

This is the process audio callback which is called each time audio is acquired and required by the audio system for input and output. Callback to pass to the jack server using JackClient::connect. You must overload processAudio as that is where the processing is done in your class.

See also
processAudio
Parameters
nframesThe number of frames to process
argthe user data

< The Jack client callback

Definition at line 64 of file JackClient.H.

Here is the call graph for this function:

Here is the caller graph for this function:

int JackClient::setBlockSize ( int  size)
inline

Set the server buffer size (block size)

Returns
0 on success

Definition at line 148 of file JackClient.H.

Here is the caller graph for this function:

virtual int JackClient::startClient ( )
inlinevirtual

Start the client running. Activate jack but don't connect any ports.

Returns
0 if ok or error on failure
Examples:
JackClientTest.C.

Definition at line 159 of file JackClient.H.

Here is the caller graph for this function:

virtual int JackClient::startClient ( int  inCnt,
int  outCnt,
bool  doConnect = true 
)
inlinevirtual

Start the client running. If the doConnect is true, then an attempt is made to auto connect the ports to the system ports. If auto connection fails, the client is still running.

Parameters
inCntThe number of input ports to connect to
outCntThe number of output ports to connect to
doConnectAuto-connect inputs and outputs to the system ports.
Returns
0 if ok or, JACK_HAS_NO_CAPTURE_PORTS_ERROR, JACK_HAS_NO_PLAYBACK_PORTS_ERROR

Reimplemented in CrossoverAudio.

Definition at line 173 of file JackClient.H.

Here is the call graph for this function:


The documentation for this class was generated from the following file:
gtkIOStream: JackClient Class Reference
GTK+ IOStream  Beta
GTK+ << C++ IOStream operators for GTK+. Now with extra abilities ... like ORBing, numerical computation, audio clients and more...