Qmmp
visual.h
1 /***************************************************************************
2  * Copyright (C) 2008-2022 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 #ifndef VISUAL_H
21 #define VISUAL_H
22 
23 #include <QMutex>
24 #include <QStringList>
25 #include <QWidget>
26 #include <QHash>
27 #include <stddef.h>
28 #include "qmmp_export.h"
29 
30 #define QMMP_VISUAL_NODE_SIZE 512 //samples
31 
32 class VisualFactory;
33 class VisualBuffer;
34 
38 class QMMP_EXPORT Visual : public QWidget
39 {
40  Q_OBJECT
41 public:
47  Visual(QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags());
51  virtual ~Visual();
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();
96  static void showSettings(VisualFactory *factory, QWidget *parent);
105  static void addAudio(float *pcm, int samples, int channels, qint64 ts, qint64 delay);
109  static void clearBuffer();
110 
111 public slots:
115  virtual void start();
119  virtual void stop();
120 
121 signals:
125  void closedByUser();
126 
127 protected:
132  virtual void closeEvent (QCloseEvent *event) override;
140  bool takeData(float *left, float *right = nullptr);
141 
142 private:
143  static void createVisualization(VisualFactory *factory, QWidget *parent);
144  static QList<VisualFactory*> *m_factories;
145  static QHash <const VisualFactory*, QString> *m_files;
146  static void checkFactories();
147  static QList<Visual*> m_visuals;
148  static QHash<VisualFactory*, Visual*> m_vis_map; //internal visualization
149  static QWidget *m_parentWidget;
150  static QObject *m_receiver;
151  static const char *m_member;
152  static VisualBuffer m_buffer;
153 };
154 
155 #endif
Visual plugin interface (visual factory).
Definition: visualfactory.h:46
The Visual class provides the base interface class of visualizations.
Definition: visual.h:39
static void setEnabled(VisualFactory *factory, bool enable=true)
static QString file(const VisualFactory *factory)
static void addAudio(float *pcm, int samples, int channels, qint64 ts, qint64 delay)
static void add(Visual *visual)
Visual(QWidget *parent, Qt::WindowFlags f=Qt::WindowFlags())
virtual ~Visual()
static void remove(Visual *)
static void showSettings(VisualFactory *factory, QWidget *parent)
virtual void start()
static QList< Visual * > * visuals()
void closedByUser()
virtual void closeEvent(QCloseEvent *event) override
static QList< VisualFactory * > factories()
static void clearBuffer()
static bool isEnabled(const VisualFactory *factory)
static void initialize(QWidget *parent, QObject *receiver=nullptr, const char *member=nullptr)
virtual void stop()
bool takeData(float *left, float *right=nullptr)