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

gapeaudioplot.h

00001 //gapeaudioplot.h
00002 //11/27/00
00003 //Dave Chisholm dkc@ccrma.stanford.edu
00004 
00005 #ifndef _GAPE_AUDIO_PLOT_H_
00006 #define _GAPE_AUDIO_PLOT_H_
00007 
00008 #include "gapecontroller.h"
00009 #include <qcolor.h>
00010 #include <qwt_plot.h>
00011 class QSize;
00012 class QCheckBox;
00013 class GapeZoomableSlider;
00014 class   QLCDNumber;
00015 class QGridLayout;
00016 
00017 // Constant Definition
00018 #define  AUDIOPLOT_MAX_NUM_SAMPLES        4096
00019 #define  AUDIOPLOT_MIN_NUM_SAMPLES        128
00020 #define  AUDIOPLOT_DEFAULT_NUM_SAMPLES    2048
00021 #define  AUDIOPLOT_IVAR_SCALAR            1.0
00022 #define  AUDIOPLOT_DEFAULT_MIN_RANGE_VAL  (-1.0)
00023 #define  AUDIOPLOT_DEFAULT_MAX_RANGE_VAL  1.0
00024 #define  AUDIOPLOT_DEFAULT_BG_COLOR       Qt::black
00025 #define  AUDIOPLOT_DEFAULT_CURVE_COLOR    Qt::green
00026 #define  AUDIOPLOT_DEFAULT_REFRESH_FREQUENCY 1
00027 #define AUDIOPLOT_HEIGHT 75
00028 #define AUDIOPLOT_WIDTH 200
00029 
00042 class GapeAudioPlot : public GapeController {
00043     Q_OBJECT
00044     public:
00045 
00056         GapeAudioPlot( QWidget *parent = NULL, const char* title  = "", const char* hlabel = "", const char* vlabel = "",
00057                         int nSamples = AUDIOPLOT_DEFAULT_NUM_SAMPLES,   double independentScalar = AUDIOPLOT_IVAR_SCALAR, int rFrequency = AUDIOPLOT_DEFAULT_REFRESH_FREQUENCY);
00058 
00062     ~GapeAudioPlot() {}
00063 
00068         void setBackgroundColor( const QColor& color ) {
00069             plotDisplay->setPlotBackground( color );
00070         }
00071 
00076         void setCurveColor( const QColor& color ) {
00077             plotDisplay->setCurvePen(curveHandle, QPen(color));
00078         }
00079 
00084     void resize(const QSize& size) {
00085         plotDisplay->resize( size );
00086             plotDisplay->move( 0, 0 );
00087         }
00088 
00094       void setAxisTitle(int axis, const char *t) {
00095             plotDisplay->setAxisTitle(axis, t);
00096       }
00097 
00098 
00099     //  void plot(const double* samples, int nSamples = 1);
00100 
00101 
00102   public slots:
00103 
00111     virtual void receiveTick(const GapeFloat* values, int numValues);
00112 
00117     void setRefreshFrequency(int rf) {
00118             refreshFrequency = rf;
00119         }
00120 
00125     virtual void setRangeAutoscale(bool autoScaleOn) {
00126             if (autoScaleOn) {
00127                 plotDisplay->setAxisAutoScale( QwtPlot::yLeft );
00128             } else {
00129                 plotDisplay->setAxisScale( QwtPlot::yLeft, AUDIOPLOT_DEFAULT_MIN_RANGE_VAL, AUDIOPLOT_DEFAULT_MAX_RANGE_VAL );
00130             }
00131             emit emitSetRangeAutoScale(autoScaleOn);
00132         }
00133 
00134         signals:
00141         void emitSetRangeAutoScale(bool t);
00142 
00143 
00144     protected:
00149     virtual void updateDisplay() {
00150             plotDisplay->replot();
00151         }
00152         QwtPlot*           plotDisplay;
00153 
00154     private:
00155         //QSize preferredSize;
00156         //QCheckBox*                     autoScale;
00157       int                numSamples;
00158       double             sampleIndices[AUDIOPLOT_MAX_NUM_SAMPLES];
00159       double             samples[AUDIOPLOT_MAX_NUM_SAMPLES];
00160       long               curveHandle;
00161       int                plotDisplayCounter, refreshFrequency;
00162 };
00163 
00171 class GapeTimeDomainPlot : public GapeAudioPlot {
00172     Q_OBJECT
00173     public:
00174 
00185         GapeTimeDomainPlot( QWidget *parent = NULL, const char* title  = "Time Domain", const char* hlabel = "Samples", const char* vlabel = "Amplitiude",
00186                             int nSamples = AUDIOPLOT_DEFAULT_NUM_SAMPLES,   double independentScalar = AUDIOPLOT_IVAR_SCALAR, int rFrequency = AUDIOPLOT_DEFAULT_REFRESH_FREQUENCY);
00190       ~GapeTimeDomainPlot() {}
00191 
00192     signals:
00199         void emitNumSamples(int ns);
00200 
00201     private:
00202         QCheckBox* autoScaleBox;
00203         GapeZoomableSlider* numSamplesSlider;
00204         QLCDNumber* numSamplesLCD;
00205         QGridLayout* layout;
00206         QCheckBox* muteBox;
00207 };
00208 
00209 
00217 class GapeFreqDomainPlot : public GapeAudioPlot {
00218     Q_OBJECT
00219     public:
00229         GapeFreqDomainPlot( QWidget *parent = NULL, const char* title  = "Freq Domain", const char* hlabel = "Frequency",
00230                             const char* vlabel = "Magnitude",   int rFrequency = AUDIOPLOT_DEFAULT_REFRESH_FREQUENCY);
00234       ~GapeFreqDomainPlot() {}
00235 
00236     public slots:
00241         void takeLogOfSpectrum(bool t)  {
00242             if(t) { // box checked
00243                 setAxisTitle( QwtPlot::yLeft, "Log Magnitude" );
00244                 //plotDisplay->setAxisScale( QwtPlot::yLeft, -90, 0);//ugly I don't have time ot fix this
00245                 emit emitTakeLogOfSpectrum(true);
00246                 //emit emitSetRangeAutoScale(false);
00247             } else {
00248                 setAxisTitle( QwtPlot::yLeft, "Magnitude" );
00249                 //setRangeAutoscale(false);
00250                 emit emitTakeLogOfSpectrum(false);
00251             }
00252         }
00253 
00254         virtual void setRangeAutoscale(bool autoScaleOn) {
00255             if (autoScaleOn) {
00256                 plotDisplay->setAxisAutoScale( QwtPlot::yLeft );
00257             } else {
00258                 plotDisplay->setAxisScale( QwtPlot::yLeft, 0, AUDIOPLOT_DEFAULT_MAX_RANGE_VAL );
00259             }
00260             emit emitSetRangeAutoScale(autoScaleOn);
00261         }
00262 
00263 
00264     signals:
00271         void emitNumSamples(int ns);
00272 
00278         void emitTakeLogOfSpectrum(bool t);
00279 
00280     private:
00281         QCheckBox* autoScaleBox;
00282         QCheckBox* logSpecBox;
00283         GapeZoomableSlider* numSamplesSlider;
00284         QLCDNumber* numSamplesLCD;
00285         QCheckBox* muteBox;
00286         QGridLayout* layout;
00287 };
00288 
00289 #endif
00290 
00291 
00292 

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