00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef VISUALIZE_H
00013 #define VISUALIZE_H
00014
00015 #include <mythtv/visual.h>
00016 #include "mainvisual.h"
00017 #include "metadata.h"
00018 #include "constants.h"
00019 #include "config.h"
00020
00021 #include <complex>
00022 extern "C" {
00023 #ifdef FFTW3_SUPPORT
00024 #include <fftw3.h>
00025 #define myth_fftw_float double
00026 #define fftw_real myth_fftw_float
00027 #define myth_fftw_complex std::complex<myth_fftw_float>
00028 #if (myth_fftw_float == double)
00029 #define myth_fftw_complex_cast fftw_complex
00030 #elif (myth_fftw_float == float)
00031 #define myth_fftw_complex_cast fftwf_complex
00032 #elif (myth_fftw_float == long double)
00033 #define myth_fftw_complex_cast fftwl_complex
00034 #endif
00035 #elif FFTW2_SUPPORT
00036 #include <rfftw.h>
00037 #include <fftw.h>
00038 #endif
00039 }
00040
00041 #ifdef OPENGL_SUPPORT
00042 #include <qgl.h>
00043 #endif
00044
00045 class Spectrum : public VisualBase
00046 {
00047
00048
00049
00050
00051 public:
00052 Spectrum();
00053 virtual ~Spectrum();
00054
00055 virtual void resize(const QSize &size);
00056 bool process(VisualNode *node);
00057 virtual bool draw(QPainter *p, const QColor &back = Qt::black);
00058 void handleKeyPress(const QString &action) {(void) action;}
00059
00060 protected:
00061 inline double clamp(double cur, double max, double min);
00062
00063 QColor startColor, targetColor;
00064 QMemArray<QRect> rects;
00065 QMemArray<double> magnitudes;
00066 QSize size;
00067 LogScale scale;
00068 double scaleFactor, falloff;
00069 int analyzerBarWidth;
00070
00071 #ifdef FFTW3_SUPPORT
00072 fftw_plan lplan, rplan;
00073 myth_fftw_float *lin, *rin;
00074 myth_fftw_complex *lout, *rout;
00075 #elif FFTW2_SUPPORT
00076 rfftw_plan plan;
00077 fftw_real *lin, *rin, *lout, *rout;
00078 #endif
00079 };
00080
00081 class AlbumArt : public VisualBase
00082 {
00083 public:
00084 AlbumArt(MainVisual *parent);
00085 virtual ~AlbumArt();
00086
00087 void resize(const QSize &size);
00088 bool process(VisualNode *node = 0);
00089 bool draw(QPainter *p, const QColor &back = Qt::black);
00090 void handleKeyPress(const QString &action);
00091
00092 private:
00093 bool needsUpdate(void);
00094 void findFrontCover(void);
00095
00096 QSize m_size, m_cursize;
00097 QString m_filename;
00098 ImageType m_currImageType;
00099 MainVisual *m_pParent;
00100 QImage m_image;
00101 };
00102
00103 class Blank : public VisualBase
00104 {
00105
00106 public:
00107 Blank();
00108 virtual ~Blank();
00109
00110 void resize(const QSize &size);
00111 bool process(VisualNode *node = 0);
00112 bool draw(QPainter *p, const QColor &back = Qt::black);
00113 void handleKeyPress(const QString &action) {(void) action;}
00114
00115 private:
00116 QSize size;
00117 };
00118
00119 class Squares : public Spectrum
00120 {
00121 public:
00122 Squares();
00123 virtual ~Squares();
00124
00125 void resize (const QSize &newsize);
00126 bool draw(QPainter *p, const QColor &back = Qt::black);
00127 void handleKeyPress(const QString &action) {(void) action;}
00128
00129 private:
00130 void drawRect(QPainter *p, QRect *rect, int i, int c, int w, int h);
00131 QSize size;
00132 MainVisual *pParent;
00133 int fake_height;
00134 int number_of_squares;
00135 };
00136
00137 #ifdef OPENGL_SUPPORT
00138
00139 class Gears : public QGLWidget, public VisualBase
00140 {
00141
00142
00143 public:
00144 Gears(QWidget *parent = 0, const char * = 0);
00145 virtual ~Gears();
00146
00147 void resize(const QSize &size);
00148 bool process(VisualNode *node);
00149 bool draw(QPainter *p, const QColor &back);
00150 void handleKeyPress(const QString &action) {(void) action;}
00151
00152 protected:
00153 void initializeGL();
00154 void resizeGL( int, int );
00155 void paintGL();
00156 void drawTheGears();
00157
00158 private:
00159 QColor startColor, targetColor;
00160 QMemArray<QRect> rects;
00161 QMemArray<double> magnitudes;
00162 QSize size;
00163 LogScale scale;
00164 double scaleFactor, falloff;
00165 int analyzerBarWidth;
00166 GLfloat angle, view_roty;
00167
00168 #ifdef FFTW3_SUPPORT
00169 fftw_plan lplan, rplan;
00170 myth_fftw_float *lin, *rin;
00171 myth_fftw_complex *lout, *rout;
00172 #elif FFTW2_SUPPORT
00173 rfftw_plan plan;
00174 fftw_real *lin, *rin, *lout, *rout;
00175 #endif
00176 };
00177
00178
00179 #endif // opengl_support
00180
00181 #endif // __visualize_h