Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

GapeFunctionUnit Class Reference

This is a simple abstract superclass fore GapeUnits which generate functions (ie sine wave). More...

#include <gapefunctionunit.h>

Inheritance diagram for GapeFunctionUnit::

GapeUnit GapeDrawnWaveformUnit GapeFileSampleUnit GapeHalfwaveUnit GapeSawtoothUnit GapeSineUnit GapeSquareUnit GapeTriangleUnit List of all members.

Public Slots

virtual void receiveTick (const GapeFloat *values, int numValues)
 If a function unit recieves a NULL tick it will emit a mono tick with the next sample in their waveform, otherwise it will add the next sample (scaled by the current gain) to as many channels of as it receives.


Public Methods

 GapeFunctionUnit (GapeController *c=NULL, int nChannels=1)
virtual ~GapeFunctionUnit ()

Protected Methods

virtual void fillBuffer ()=0
 Pure virtual function which fills the FunctionUnit's internal buffer with data representing one period of a waveform. More...

void normalize ()

Protected Attributes

GapeFloatsampleData
int dataLength
bool initialized
double period
double timeScalar
double oldFrequency
double currentTime
char errorBuffer [255]

Detailed Description

This is a simple abstract superclass fore GapeUnits which generate functions (ie sine wave).

The can function as either sources, in which case they recieve a NULL tick in receiveTick and emit a tick with the next sample in their waveform (the number of channels is determined by the parameter in the constructor, or by using set/getNumChannels) Or the can act as filters, in which case they will add the next sample in their waveform (scaled by the current gain) to the signal. The function unit will add its waveform to as many channels of incoming audio as it's numChannels is set to - for instance, if a sine unit is set to one channel, and it receives a stereo sample, it will only add a sine wave to the first channel. Subclasses must implement the fillBuffer function, which simply creates a buffer of data corresponding to one period of the waveform. This class takes care of all the things like interpolation for different frequencies and sample rates, cleaning up the buffer upon destruction, etc.

Author:
Dave Chisholm , Randal Leistikow
Since:
Beta 1.0
Version:
Last Modified Beta 1.0

Definition at line 34 of file gapefunctionunit.h.


Member Function Documentation

void GapeFunctionUnit::fillBuffer ( ) [protected, pure virtual]
 

Pure virtual function which fills the FunctionUnit's internal buffer with data representing one period of a waveform.

You must allocate storage for this buffer (which is designated by the sampleData pointer) and also set the length of the data (in samples) in the variable dataLength. Deallocation of the data is taken care of by the destructor.

Reimplemented in GapeSineUnit, GapeSquareUnit, GapeSawtoothUnit, GapeTriangleUnit, GapeHalfwaveUnit, GapeDrawnWaveformUnit, and GapeFileSampleUnit.

Referenced by receiveTick().


The documentation for this class was generated from the following files:
Generated at Thu Jun 21 13:28:52 2001 for GAPE by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001