00001 #ifndef SYNAETHESIA
00002 #define SYNAETHESIA
00003
00004 #include <mythtv/visual.h>
00005 #include "polygon.h"
00006 #include "mainvisual.h"
00007 #include "config.h"
00008
00009 #ifdef SDL_SUPPORT
00010 #include <SDL.h>
00011 #endif
00012
00013 class QImage;
00014
00015 #define LogSize 10
00016 #define Brightness 150
00017 #define NumSamples (1<<LogSize)
00018
00019 #define Flame 0
00020 #define Wave 1
00021 #define Stars 2
00022
00023 class Synaesthesia : public VisualBase
00024 {
00025 public:
00026 Synaesthesia(long int winid);
00027 virtual ~Synaesthesia();
00028
00029 void resize(const QSize &size);
00030 bool process(VisualNode *node);
00031 bool draw(QPainter *p, const QColor &back);
00032 void handleKeyPress(const QString &action) {(void) action;}
00033
00034 private:
00035 void setupPalette(void);
00036 void coreInit(void);
00037 int bitReverser(int i);
00038 void fft(double *x, double *y);
00039 void setStarSize(double lsize);
00040
00041 inline void addPixel(int x, int y, int br1, int br2);
00042 inline void addPixelFast(unsigned char *p, int br1, int br2);
00043 inline unsigned char getPixel(int x, int y, int where);
00044
00045 inline void fadePixelWave(int x, int y, int where, int step);
00046 void fadeWave(void);
00047 inline void fadePixelHeat(int x, int y, int where, int step);
00048 void fadeHeat(void);
00049 void fadeFade(void);
00050 void fade(void);
00051
00052 QSize size;
00053
00054 double cosTable[NumSamples];
00055 double negSinTable[NumSamples];
00056 int bitReverse[NumSamples];
00057 int scaleDown[256];
00058 int maxStarRadius;
00059 int fadeMode;
00060 bool pointsAreDiamonds;
00061 double brightnessTwiddler;
00062 double starSize;
00063
00064 int outWidth;
00065 int outHeight;
00066
00067 Bitmap<unsigned short> outputBmp, lastOutputBmp, lastLastOutputBmp;
00068 QImage *outputImage;
00069
00070 unsigned char palette[768];
00071 double fgRedSlider, fgGreenSlider, bgRedSlider, bgGreenSlider;
00072
00073 double energy_avg;
00074 #ifdef SDL_SUPPORT
00075 SDL_Surface *surface;
00076 #endif
00077 };
00078
00079 #endif // SYNAETHESIA