Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Examples  

JezabelTool Class Reference

Object performing some audio processing function. More...

#include <jezabeltool.h>

Inheritance diagram for JezabelTool::

JezabelPatchTool List of all members.

Public Types

enum  JezabelPortType { portInput, portOutput }
enum  JezabelProperty { Property_RealTime = 0x01 }

Public Methods

 JezabelTool ()
virtual void activate ()
virtual void run (int samples)=0
virtual void seek (JezabelPosition position)
virtual JezabelPosition length ()
virtual void deactivate ()
virtual int blockSize ()
int numPorts ()
JezabelPortType portType (int port)
virtual void setBuffer (int port, JezabelData *buffer)
virtual const char* strerror ()

Protected Methods

void makePort (JezabelPortType)
JezabelDataportBuffer (int n)

Detailed Description

Object performing some audio processing function.

Generally speaking, a JezabelTool is used in the following way:

1) An instance is created using its constructor, like this:


For example, the parameters of a band-pass filter might be gain, center frequency and bandwidth.

Tools that can be controlled by the user in real time will typically have as a parameter a pointer to an object the contains the control values. Since the tool runs in a different thread from the UI, it must assume that these values can change asynchronously.

2) The user queries the tool to determine the number and types of its ports by calling numPorts and portType. A port is either of type portInput or portOutput. Each port represents a conceptually unbounded stream of values of type JezabelData (i.e., single precision IEEE floats).

3) The user assigns data buffers to the ports by calling setBuffer. The same buffer can be used as both input and output of a tool. The result is that the data in the buffer are modified in place.

4) The user calls "activate", to warn that the tool is about to be run. This usually does nothing, but can be used, for example, to open files or devices, or in general to allocate resources that should be held only when the tool is running. The method returns "false" if for some reason the tool can't be activated (for example because resources aren't available).

5) The user repeatedly calls "run", causing the tool to process a given number of samples in its buffers. This returns "false" in case of a run-time error that should halt operation of the tool.

6) The user calls "deactivate". This usually does nothing, but can be used, for example, to close files or devices, or to free any resources allocate by "activate". The process can now be restarted at "activate", or the tool can be destructed. The method returns "false" in case of an error.

Between "activate" and "deactivate", it is also possible to call "seek" to cause the tool to move to a given sample position in the stream, or "length", to determine the length of the stream, in case this is meaningful. In most cases, "seek" does nothing, and "length" returns JezabelLengthMax, indicating an infinite stream.

Finally, the method "strerror" should return a string indicating the the error in the most recent operation, or NULL if no error.

Internals of a tool:

Generally, the constructor of the tool stores the parameter values somewhere, and creates the ports, like this:

BandPassFilter::BandPassFilter(float _freq, float _bandwidth) {
freq = _freq;
bandwidth = _bandwidth;


At a minimum, the tool must also override the "run" method. The "run" method looks like this:

BandPassFilter::run(int samples){

  // get pointers to the input and output bufers
  JezabelData *inp = portBuffer(0);
  JezabelData *out = portBuffer(1);
  // process some samples

  for(i = 0; i < samples; i++, inp++, out++){
     ... compute something ...

Member Enumeration Documentation

enum JezabelTool::JezabelPortType

Port types

enum JezabelTool::JezabelProperty


Constructor & Destructor Documentation

JezabelTool::JezabelTool ( )

Default constructor

Member Function Documentation

void JezabelTool::activate ( ) [inline, virtual]

Warns tool we are about to call "run"

Reimplemented in JezabelPatchTool.

int JezabelTool::blockSize ( ) [inline, virtual]

Return the maximum number of samples that this tool can handle with a call to run(), or zero if there is no maximum.

Reimplemented in JezabelPatchTool.

void JezabelTool::deactivate ( ) [inline, virtual]

Indicate we are done calling run, and will not call run again until activate is called.

Reimplemented in JezabelPatchTool.

JezabelPosition JezabelTool::length ( ) [inline, virtual]

Return the length of the stream for this tool. This only makes sense for some tools, and will return JezabelLengthMax if the is no upper bound on the length.

Reimplemented in JezabelPatchTool.

void JezabelTool::makePort ( JezabelPortType ) [protected]

create a port

int JezabelTool::numPorts ( )

Returns the number of ports for this tool

JezabelData * JezabelTool::portBuffer ( int n ) [protected]

get pointer to the buffer for port "n"

JezabelPortType JezabelTool::portType ( int port )

Returns the type of port "port"

void JezabelTool::run ( int samples ) [pure virtual]

Run the tool on "samples" samples, which must be less than or equal to "max_request".

Reimplemented in JezabelPatchTool.

void JezabelTool::seek ( JezabelPosition position ) [inline, virtual]

Seek to a given position. This only makes sense for some tools, and is ignored by others.

Reimplemented in JezabelPatchTool.

void JezabelTool::setBuffer ( int port,
JezabelData * buffer ) [virtual]

Assign buffer "buffer" to port "port*. Must be called for all ports before calling "activate"

Reimplemented in JezabelPatchTool.

const char * JezabelTool::strerror ( ) [inline, virtual]

Returns string describing error in most recent operation, or null is no error

Reimplemented in JezabelPatchTool.

The documentation for this class was generated from the following file:
Generated at Sun Jan 18 20:51:23 2004 for Jezabel by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001