Public Member Functions | Protected Member Functions

JackCpp::BlockingAudioIO Class Reference

This is an class that provides a blocking read/write interface for Jack. More...

#include <jackblockingaudioio.hpp>

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

List of all members.

Public Member Functions

 BlockingAudioIO (std::string name, unsigned int inChans=2, unsigned int outChans=2, unsigned int inBufSize=0, unsigned int outBufSize=0, bool startServer=true) throw (std::runtime_error)
 The Constructor.
void write (unsigned int channel, jack_default_audio_sample_t val)
 Write to an output buffer.
bool tryWrite (unsigned int channel, jack_default_audio_sample_t val)
 Try to write to an output buffer.
jack_default_audio_sample_t read (unsigned int channel)
 Read from an input buffer.
bool tryRead (unsigned int channel, jack_default_audio_sample_t &val)
 Try to read from to an input buffer.
virtual void reserveOutPorts (unsigned int num) throw (std::runtime_error)
 This method is useless at the moment.
virtual void reserveInPorts (unsigned int num) throw (std::runtime_error)
 This method is useless at the moment.
virtual unsigned int addInPort (std::string name) throw (std::runtime_error)
 Add an input port to our client.
virtual unsigned int addOutPort (std::string name) throw (std::runtime_error)
 Add an output port to our client.

Protected Member Functions

virtual int audioCallback (jack_nframes_t nframes, std::vector< jack_default_audio_sample_t * > inBufs, std::vector< jack_default_audio_sample_t * > outBufs)
 This is the callback that processes our buffers.

Detailed Description

This is an class that provides a blocking read/write interface for Jack.

This class has read/write methods that allow users to write audio to and read audio from a Jack client.

Author:
Alex Norman

Constructor & Destructor Documentation

JackCpp::BlockingAudioIO::BlockingAudioIO ( std::string  name,
unsigned int  inChans = 2,
unsigned int  outChans = 2,
unsigned int  inBufSize = 0,
unsigned int  outBufSize = 0,
bool  startServer = true 
) throw (std::runtime_error)

The Constructor.

Parameters:
name string indicating the name of the jack client to create
inChans an unsigned integer indicating the number of default input ports to create
outChans an unsigned integer indicating the number of default output ports to create
inBufSize the size of the buffer that the jack callback fills for us to read with read
outBufSize the size of the buffer that we write to and the jack callback reads from
startServer a boolean indicating whether to start a jack server if one isn't already running
See also:
AudioIO::AudioIO

Member Function Documentation

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

Add an input port to our client.

Unlike AudioIO, this currently cannot be called while the client is running.

Parameters:
name string the name of the port to add
Returns:
the number of total input ports
See also:
AudioIO::addInPort(std::string name)

Reimplemented from JackCpp::AudioIO.

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

Add an output port to our client.

Unlike AudioIO, this currently cannot be called while the client is running.

Parameters:
name string the name of the port to add
Returns:
the number of total output ports
See also:
AudioIO::addOutPort(std::string name)

Reimplemented from JackCpp::AudioIO.

virtual int JackCpp::BlockingAudioIO::audioCallback ( jack_nframes_t  nframes,
std::vector< jack_default_audio_sample_t * >  inBufs,
std::vector< jack_default_audio_sample_t * >  outBufs 
) [protected, virtual]

This is the callback that processes our buffers.

This method takes the buffers we write to with "write" and writes them out to the Jack bus. It also takes audio from the Jack bus and uses that to fill the input buffers that we read from.

Parameters:
nframes the number frames to process
inBufs a vector of audio buffers
outBufs a vector of audio buffers
Returns:
the actual number of frames processed
jack_default_audio_sample_t JackCpp::BlockingAudioIO::read ( unsigned int  channel  ) 

Read from an input buffer.

Reads from input[channel] if it exists. If there is no input to read it sleeps until there is.

Parameters:
channel the input chanel to read from
Returns:
the value read from the input channel [will be zero if the channel does not exist]
See also:
tryRead(unsigned int channel, jack_default_audio_sample_t &val)
bool JackCpp::BlockingAudioIO::tryRead ( unsigned int  channel,
jack_default_audio_sample_t &  val 
)

Try to read from to an input buffer.

Trys to read from input[channel] (if it exists). If it succeeds it returns true. If it fails, because the buffer is empty, it returns false.

Parameters:
channel the output chanel to read from
val the value to read into (basically a return value)
Returns:
true if it can read, false if it cannot
See also:
read(unsigned int channel)
bool JackCpp::BlockingAudioIO::tryWrite ( unsigned int  channel,
jack_default_audio_sample_t  val 
)

Try to write to an output buffer.

Trys to write to output[channel] (if it exists). If it succeeds it returns true. If it fails, because the buffer is full, it returns false.

Parameters:
channel the output chanel to write to
val the value to write to the channel
Returns:
true if it can write, false if it cannot
See also:
write(unsigned int channel, jack_default_audio_sample_t val)
void JackCpp::BlockingAudioIO::write ( unsigned int  channel,
jack_default_audio_sample_t  val 
)

Write to an output buffer.

Writes val to the output[channel] (if it exists). If output[channel] does not exist is silently fails otherwise it sleeps until it can write output[channel]

Parameters:
channel the output chanel to write to
val the value to write to the channel
See also:
tryWrite(unsigned int channel, jack_default_audio_sample_t val)

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