This is an class that provides a blocking read/write interface for Jack. More...
#include <jackblockingaudioio.hpp>
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. |
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.
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.
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 |
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.
name | string the name of the port to add |
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.
name | string the name of the port to add |
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.
nframes | the number frames to process | |
inBufs | a vector of audio buffers | |
outBufs | a vector of audio buffers |
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.
channel | the input chanel to read from |
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.
channel | the output chanel to read from | |
val | the value to read into (basically a return value) |
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.
channel | the output chanel to write to | |
val | the value to write to the channel |
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]
channel | the output chanel to write to | |
val | the value to write to the channel |