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

gapefunctionunit.h

00001 // gapefunctionunit.h
00002 // Dave Chisholm dkc@ccrma.stanford.edu 11/21/00
00003 // This file contains definitions for GapeFunctionUnit, and subclasses for sine wave, square wave, triangle wave,
00004 // halfwave and sawtooth functions.
00005 #ifndef _GAPE_FUNCTION_UNIT_H
00006 #define _GAPE_FUNCTION_UNIT_H
00007 
00008 #include "gapeunit.h"
00009 #include "gapesimplecontroller.h"
00010 class WvIn;
00011 
00012 #define GAPE_FUNCTION_UNIT_DEFAULT_FREQ GAPE_SIMPLE_CONTROLLER_DEFAULT_FREQ
00013 #define GAPE_FUNCTION_UNIT_DEFAULT_GAIN GAPE_SIMPLE_CONTROLLER_DEFAULT_GAIN
00014 #define GAPE_FN_BUFFER_LENGTH   2560
00015 #define GAPE_DRAWN_WAVEFORM_BUFFER_LENGTH 64
00016 #define GAPE_FILE_SAMPLE_UNIT_MAX_SIZE 192000
00017 #define GAPE_FUNCTION_UNIT_MAX_HARMONICS 500
00018 
00033 
00034 class GapeFunctionUnit : public GapeUnit {
00035 Q_OBJECT
00036         public:
00037             GapeFunctionUnit(GapeController* c = NULL, int nChannels = 1);
00038         virtual ~GapeFunctionUnit();
00039 
00040         public slots:
00044             virtual void receiveTick(const GapeFloat* values, int numValues);
00045 
00046         protected:
00052             virtual void fillBuffer() = 0;
00053             void normalize();
00054             GapeFloat* sampleData;
00055             int dataLength;
00056             bool initialized;// = false;
00057             double period;// = GapeConsts::sampleRate / frequency;//period in samples
00058             double timeScalar;// = ((double) dataLength) / period;
00059             double oldFrequency;// = frequency;
00060             double currentTime;// = 0.0;//in samples
00061             char errorBuffer[255];
00062 };
00063 
00070 class GapeSineUnit : public GapeFunctionUnit {
00071     Q_OBJECT
00072     public:
00073         GapeSineUnit()
00074         : GapeFunctionUnit() {}
00075 
00076         GapeSineUnit(QWidget* parent)
00077         : GapeFunctionUnit(new GapeSimpleController(parent,"Sine Wave")) {}
00078         //: GapeFunctionUnit(new GapeSimpleController(parent,"GapeSineUnitController",QPixmap("sine.bmp"))) {}
00079         //: GapeFunctionUnit(new GapeSimpleController(parent,"GapeSineUnitController",GapeConsts::sinePic)) {}
00080         virtual ~GapeSineUnit() {}
00081 
00082     protected:
00083         virtual void fillBuffer();
00084 };
00085 
00092 class GapeSquareUnit : public GapeFunctionUnit {
00093     Q_OBJECT
00094     public:
00095         GapeSquareUnit()
00096         : GapeFunctionUnit() {}
00097 
00098         GapeSquareUnit(QWidget* parent)
00099         : GapeFunctionUnit(new GapeSimpleController(parent,"Square Wave")) {}
00100         //: GapeFunctionUnit(new GapeSimpleController(parent,"GapeSquareUnitController"), QPixmap("sine.bmp")) {}
00101         //: GapeFunctionUnit(new GapeSimpleController(parent,"GapeSquareUnit",&GapeConsts::squarePic)) {}
00102         virtual ~GapeSquareUnit() {}
00103 
00104     protected:
00105         virtual void fillBuffer();
00106 };
00107 
00114 class GapeSawtoothUnit : public GapeFunctionUnit {
00115     Q_OBJECT
00116     public:
00117         GapeSawtoothUnit()
00118         : GapeFunctionUnit() {}
00119 
00120         GapeSawtoothUnit(QWidget* parent)
00121         : GapeFunctionUnit(new GapeSimpleController(parent,"Sawtooth Wave")) {}
00122         //: GapeFunctionUnit(new GapeSimpleController(parent,"GapeSawtoothUnit",&GapeConsts::sawtoothPic)) {}
00123         virtual ~GapeSawtoothUnit() {}
00124 
00125     protected:
00126         virtual void fillBuffer();
00127 };
00128 
00135 class GapeTriangleUnit : public GapeFunctionUnit {
00136     Q_OBJECT
00137     public:
00138         GapeTriangleUnit()
00139         : GapeFunctionUnit() {}
00140 
00141         GapeTriangleUnit(QWidget* parent)
00142         : GapeFunctionUnit(new GapeSimpleController(parent,"Triangle Wave")) {}
00143         //: GapeFunctionUnit(new GapeSimpleController(parent,"GapeTriangleUnit",&GapeConsts::trianglePic)) {}
00144         virtual ~GapeTriangleUnit() {}
00145 
00146     protected:
00147         virtual void fillBuffer();
00148 };
00149 
00156 class GapeHalfwaveUnit : public GapeFunctionUnit {
00157     Q_OBJECT
00158     public:
00159         GapeHalfwaveUnit()
00160         : GapeFunctionUnit() {}
00161 
00162         GapeHalfwaveUnit(QWidget* parent)
00163         : GapeFunctionUnit(new GapeSimpleController(parent,"Halfwave ")) {}
00164         //: GapeFunctionUnit(new GapeSimpleController(parent,"GapeHalfwaveUnit",&GapeConsts::halfwavePic)) {}
00165         virtual ~GapeHalfwaveUnit() {}
00166 
00167     protected:
00168         virtual void fillBuffer();
00169 
00170 };
00171 
00178 class GapeDrawnWaveformUnit : public GapeFunctionUnit {
00179     Q_OBJECT
00180     public:
00181         GapeDrawnWaveformUnit(QWidget* parent);
00182 
00183         //: GapeFunctionUnit(new GapeSimpleController(parent,"GapeSineUnitController",QPixmap("sine.bmp"))) {}
00184         //: GapeFunctionUnit(new GapeSimpleController(parent,"GapeSineUnitController",GapeConsts::sinePic)) {}
00185         virtual ~GapeDrawnWaveformUnit() {delete xData;}
00186 
00187     public slots:
00188         void setPoint(double x, double y);
00189 
00190     protected:
00191         virtual void fillBuffer();
00192         double * xData;
00193 };
00194 
00205 class GapeFileSampleUnit : public GapeFunctionUnit {
00206     Q_OBJECT
00207     public:
00208         GapeFileSampleUnit (QWidget* parent, const QString& file);
00209 
00210         //: GapeFunctionUnit(new GapeSimpleController(parent,"GapeSineUnitController",QPixmap("sine.bmp"))) {}
00211         //: GapeFunctionUnit(new GapeSimpleController(parent,"GapeSineUnitController",GapeConsts::sinePic)) {}
00212         virtual ~GapeFileSampleUnit ();
00213 
00214     public slots:
00215             virtual void receiveTick(const GapeFloat* values, int numValues);
00216 
00217     protected:
00218         virtual void fillBuffer();
00219         WvIn* dataReader;
00220         QString* filename;
00221         bool validFile;
00222 };
00223 
00224 
00225 #endif

Generated at Thu Jun 21 13:28:49 2001 for GAPE by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001