TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
visual.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2008-2024 by Ilya Kotov *
3  * forkotov02@ya.ru *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef VISUAL_H
22 #define VISUAL_H
23 
24 #include <QHash>
25 #include <QWidget>
26 #include "qmmp_export.h"
27 
28 #define QMMP_VISUAL_INTERVAL 40
29 #define QMMP_VISUAL_NODE_SIZE 512 //samples
30 
31 class VisualFactory;
32 class VisualBuffer;
33 
37 class QMMP_EXPORT Visual : public QWidget
38 {
39  Q_OBJECT
40 public:
46  explicit Visual(QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags());
50  virtual ~Visual();
51 
55  static QList<VisualFactory*> factories();
60  static QString file(const VisualFactory *factory);
66  static void setEnabled(VisualFactory *factory, bool enable = true);
71  static bool isEnabled(const VisualFactory *factory);
75  static void add(Visual*visual);
79  static void remove(Visual*);
86  static void initialize(QWidget *parent, QObject *receiver = nullptr, const char *member = nullptr);
90  static QList<Visual *> *visuals();
99  static void addAudio(float *pcm, int samples, int channels, qint64 ts, qint64 delay);
103  static void clearBuffer();
104 
105 public slots:
109  virtual void start();
113  virtual void stop();
117  void updateVisual();
121  void changeFullScreen(bool state);
122 
123 signals:
127  void closedByUser();
131  void fullscreenByUser(QWidget *widget, bool state);
132 
133 protected:
138  virtual void showEvent(QShowEvent *event) override;
143  virtual void hideEvent(QHideEvent *event) override;
148  virtual void closeEvent(QCloseEvent *event) override final;
156  bool takeData(float *left, float *right = nullptr);
160  virtual void process(float *left, float *right) = 0;
164  virtual void process(bool state);
168  void clear();
169 
170 protected:
171  QTimer *m_timer = nullptr;
172  bool m_running = false;
173  int m_rows = 0, m_cols = 0;
174  int *m_intern_vis_data = nullptr;
175  QAction *m_screenAction = nullptr;
176 
177 private:
178  static void checkFactories();
179  static void createVisualization(VisualFactory *factory, QWidget *parent);
180 
181  static QList<VisualFactory*> *m_factories;
182  static QHash<const VisualFactory*, QString> *m_files;
183  static QList<Visual*> m_visuals;
184  static QHash<VisualFactory*, Visual*> m_vis_map; //internal visualization
185  static QWidget *m_parentClass;
186  static QObject *m_receiver;
187  static const char *m_member;
189 
190 };
191 
192 #endif
static QWidget * m_parentClass
Definition: visual.h:185
static QHash< const VisualFactory *, QString > * m_files
Definition: visual.h:182
static VisualBuffer m_buffer
Definition: visual.h:188
static const char * m_member
Definition: visual.h:187
static QList< VisualFactory * > * m_factories
Definition: visual.h:181
static QList< Visual * > m_visuals
Definition: visual.h:183
The Visual class provides the base interface class of visualizations.
Definition: visual.h:37
#define QMMP_EXPORT
Definition: qmmp_export.h:29
static QHash< VisualFactory *, Visual * > m_vis_map
Definition: visual.h:184
Visual plugin interface (visual factory).
Definition: visualfactory.h:42
static QObject * m_receiver
Definition: visual.h:186
state
Definition: http_parser.c:279