MythTV  master
synaesthesia.h
Go to the documentation of this file.
1 #ifndef SYNAETHESIA
2 #define SYNAETHESIA
3 
4 // C++
5 #include <array>
6 
7 // MythTV
8 #include <libmyth/visual.h>
9 
10 // MythMusic
11 #include "mainvisual.h"
12 #include "polygon.h"
13 
14 class QImage;
15 
16 static constexpr size_t LogSize { 10 };
17 static constexpr size_t NumSamples { 1<<LogSize };
18 static constexpr uint8_t Brightness { 150 };
19 
20 using samp_dbl_array = std::array<double,NumSamples>;
21 using samp_int_array = std::array<int,NumSamples>;
22 
23 enum Mode {
24  Flame = 0,
25  Wave = 1,
26  Stars = 2
27 };
28 
29 class Synaesthesia : public VisualBase
30 {
31 public:
32  Synaesthesia(void);
33  ~Synaesthesia() override;
34 
35  void resize(const QSize &size) override; // VisualBase
36  bool process(VisualNode *node) override; // VisualBase
37  bool draw(QPainter *p, const QColor &back) override; // VisualBase
38  void handleKeyPress(const QString &action) override // VisualBase
39  {(void) action;}
40 
41 private:
42  void setupPalette(void);
43  void coreInit(void);
44  static int bitReverser(int i);
45  void fft(double *x, double *y);
46  void setStarSize(double lsize);
47 
48  inline void addPixel(int x, int y, int br1, int br2) const;
49  static inline void addPixelFast(unsigned char *p, int br1, int br2);
50  inline unsigned char getPixel(int x, int y, int where) const;
51 
52  inline void fadePixelWave(int x, int y, int where, int step);
53  void fadeWave(void);
54  inline void fadePixelHeat(int x, int y, int where, int step);
55  void fadeHeat(void);
56  void fadeFade(void) const;
57  void fade(void);
58 
59  QSize m_size {0,0};
60 
64  std::array<int,256> m_scaleDown {};
65  int m_maxStarRadius {1};
67  bool m_pointsAreDiamonds {true};
68  double m_brightnessTwiddler {0.3};
69  double m_starSize {0.5};
70 
71  int m_outWidth {0};
72  int m_outHeight {0};
73 
77  QImage *m_outputImage {nullptr};
78 
79  std::array<uint8_t,768> m_palette {};
80  double m_fgRedSlider {0.0};
81  double m_fgGreenSlider {0.5};
82  double m_bgRedSlider {0.75};
83  double m_bgGreenSlider {0.4};
84 
85  double m_energyAvg {80.0};
86 };
87 
88 #endif // SYNAETHESIA
Flame
@ Flame
Definition: synaesthesia.h:24
Synaesthesia::m_fgRedSlider
double m_fgRedSlider
Definition: synaesthesia.h:80
samp_dbl_array
std::array< double, NumSamples > samp_dbl_array
Definition: synaesthesia.h:20
Synaesthesia::m_outWidth
int m_outWidth
Definition: synaesthesia.h:71
Wave
@ Wave
Definition: synaesthesia.h:25
Synaesthesia::bitReverser
static int bitReverser(int i)
Definition: synaesthesia.cpp:154
Brightness
Definition: channelsettings.cpp:483
Synaesthesia::coreInit
void coreInit(void)
Definition: synaesthesia.cpp:210
Synaesthesia::m_lastOutputBmp
Bitmap< unsigned short > m_lastOutputBmp
Definition: synaesthesia.h:75
back
static guint32 * back
Definition: goom_core.cpp:25
VisualNode
Definition: videovisual.h:25
Synaesthesia::setStarSize
void setStarSize(double lsize)
Definition: synaesthesia.cpp:191
NumSamples
static constexpr size_t NumSamples
Definition: synaesthesia.h:17
Mode
Mode
Definition: synaesthesia.h:23
Synaesthesia::resize
void resize(const QSize &size) override
Definition: synaesthesia.cpp:104
Synaesthesia::draw
bool draw(QPainter *p, const QColor &back) override
Definition: synaesthesia.cpp:587
VisualBase
Definition: visualize.h:62
Synaesthesia::Synaesthesia
Synaesthesia(void)
Definition: synaesthesia.cpp:29
Synaesthesia::m_starSize
double m_starSize
Definition: synaesthesia.h:69
Synaesthesia::m_pointsAreDiamonds
bool m_pointsAreDiamonds
Definition: synaesthesia.h:67
polygon.h
Bitmap< unsigned short >
Synaesthesia
Definition: synaesthesia.h:29
Synaesthesia::m_bgGreenSlider
double m_bgGreenSlider
Definition: synaesthesia.h:83
Synaesthesia::fadeFade
void fadeFade(void) const
Definition: synaesthesia.cpp:261
Synaesthesia::~Synaesthesia
~Synaesthesia() override
Definition: synaesthesia.cpp:38
Synaesthesia::m_outHeight
int m_outHeight
Definition: synaesthesia.h:72
Synaesthesia::m_bgRedSlider
double m_bgRedSlider
Definition: synaesthesia.h:82
Synaesthesia::addPixelFast
static void addPixelFast(unsigned char *p, int br1, int br2)
Definition: synaesthesia.cpp:241
Synaesthesia::fade
void fade(void)
Definition: synaesthesia.cpp:431
Synaesthesia::m_palette
std::array< uint8_t, 768 > m_palette
Definition: synaesthesia.h:79
Synaesthesia::handleKeyPress
void handleKeyPress(const QString &action) override
Definition: synaesthesia.h:38
hardwareprofile.config.p
p
Definition: config.py:33
Synaesthesia::m_outputImage
QImage * m_outputImage
Definition: synaesthesia.h:77
samp_int_array
std::array< int, NumSamples > samp_int_array
Definition: synaesthesia.h:21
Synaesthesia::m_maxStarRadius
int m_maxStarRadius
Definition: synaesthesia.h:65
Synaesthesia::m_outputBmp
Bitmap< unsigned short > m_outputBmp
Definition: synaesthesia.h:74
Synaesthesia::m_size
QSize m_size
Definition: synaesthesia.h:59
Synaesthesia::m_negSinTable
samp_dbl_array m_negSinTable
Definition: synaesthesia.h:62
Synaesthesia::m_cosTable
samp_dbl_array m_cosTable
Definition: synaesthesia.h:61
Synaesthesia::setupPalette
void setupPalette(void)
Definition: synaesthesia.cpp:48
Synaesthesia::getPixel
unsigned char getPixel(int x, int y, int where) const
Definition: synaesthesia.cpp:253
Stars
@ Stars
Definition: synaesthesia.h:26
Synaesthesia::m_bitReverse
samp_int_array m_bitReverse
Definition: synaesthesia.h:63
LogSize
static constexpr size_t LogSize
Definition: synaesthesia.h:16
Synaesthesia::addPixel
void addPixel(int x, int y, int br1, int br2) const
Definition: synaesthesia.cpp:224
Synaesthesia::process
bool process(VisualNode *node) override
Definition: synaesthesia.cpp:442
mainvisual.h
Synaesthesia::m_energyAvg
double m_energyAvg
Definition: synaesthesia.h:85
build_compdb.action
action
Definition: build_compdb.py:9
Synaesthesia::fadeWave
void fadeWave(void)
Definition: synaesthesia.cpp:301
Synaesthesia::fadeHeat
void fadeHeat(void)
Definition: synaesthesia.cpp:377
Synaesthesia::m_brightnessTwiddler
double m_brightnessTwiddler
Definition: synaesthesia.h:68
Synaesthesia::m_scaleDown
std::array< int, 256 > m_scaleDown
Definition: synaesthesia.h:64
Synaesthesia::fadePixelHeat
void fadePixelHeat(int x, int y, int where, int step)
Definition: synaesthesia.cpp:356
Synaesthesia::fadePixelWave
void fadePixelWave(int x, int y, int where, int step)
Definition: synaesthesia.cpp:279
Synaesthesia::m_fadeMode
int m_fadeMode
Definition: synaesthesia.h:66
Synaesthesia::m_fgGreenSlider
double m_fgGreenSlider
Definition: synaesthesia.h:81
Synaesthesia::m_lastLastOutputBmp
Bitmap< unsigned short > m_lastLastOutputBmp
Definition: synaesthesia.h:76
Synaesthesia::fft
void fft(double *x, double *y)
Definition: synaesthesia.cpp:166
visual.h