strawberry-audio-player-win.../src/analyzer/analyzerbase.h

95 lines
2.3 KiB
C
Raw Normal View History

2019-02-04 21:34:12 +01:00
/*
Strawberry Music Player
This file was part of Amarok.
Copyright 2003-2004, Max Howell <max.howell@methylblue.com>
Copyright 2009-2012, David Sansome <me@davidsansome.com>
Copyright 2010, 2012, 2014, John Maguire <john.maguire@gmail.com>
Copyright 2017, Santiago Gil
Strawberry is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Strawberry is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*/
2018-02-27 18:06:05 +01:00
#ifndef ANALYZERBASE_H
#define ANALYZERBASE_H
#include "config.h"
2018-02-27 18:06:05 +01:00
#ifdef __FreeBSD__
2019-02-04 21:34:12 +01:00
# include <sys/types.h>
2018-02-27 18:06:05 +01:00
#endif
#include <vector>
2018-02-27 18:06:05 +01:00
#include <QtGlobal>
#include <QObject>
#include <QWidget>
#include <QBasicTimer>
#include <QString>
#include <QPainter>
#include "analyzer/fht.h"
2019-02-04 21:34:12 +01:00
#include "engine/enginebase.h"
class QHideEvent;
class QShowEvent;
2018-02-27 18:06:05 +01:00
class QPaintEvent;
2022-04-01 22:30:00 +02:00
class QTimerEvent;
2018-02-27 18:06:05 +01:00
2023-04-22 19:45:21 +02:00
class AnalyzerBase : public QWidget {
2018-02-27 18:06:05 +01:00
Q_OBJECT
public:
2023-04-22 19:45:21 +02:00
~AnalyzerBase() override;
2018-02-27 18:06:05 +01:00
int timeout() const { return timeout_; }
2018-02-27 18:06:05 +01:00
void set_engine(EngineBase *engine) { engine_ = engine; }
2018-02-27 18:06:05 +01:00
2022-04-01 22:30:00 +02:00
void ChangeTimeout(const int timeout);
2018-02-27 18:06:05 +01:00
virtual void framerateChanged() {}
protected:
2023-04-22 19:45:21 +02:00
using Scope = std::vector<float>;
explicit AnalyzerBase(QWidget*, const uint scopeSize = 7);
2018-02-27 18:06:05 +01:00
2020-06-15 21:55:05 +02:00
void hideEvent(QHideEvent*) override;
void showEvent(QShowEvent*) override;
2022-04-01 22:30:00 +02:00
void paintEvent(QPaintEvent *e) override;
void timerEvent(QTimerEvent *e) override;
2018-02-27 18:06:05 +01:00
int resizeExponent(int);
2021-06-12 20:53:23 +02:00
int resizeForBands(const int);
2018-02-27 18:06:05 +01:00
virtual void init() {}
virtual void transform(Scope&);
2021-06-12 20:53:23 +02:00
virtual void analyze(QPainter &p, const Scope&, const bool new_frame) = 0;
virtual void demo(QPainter &p);
2018-02-27 18:06:05 +01:00
2023-04-22 19:45:21 +02:00
void interpolate(const Scope&, Scope&);
void initSin(Scope&, const uint = 6000);
2018-02-27 18:06:05 +01:00
protected:
QBasicTimer timer_;
FHT *fht_;
EngineBase *engine_;
Scope lastscope_;
2019-02-04 21:34:12 +01:00
2018-02-27 18:06:05 +01:00
bool new_frame_;
bool is_playing_;
2022-04-01 22:30:00 +02:00
int timeout_;
2018-02-27 18:06:05 +01:00
};
2019-02-04 21:34:12 +01:00
#endif // ANALYZERBASE_H
2018-02-27 18:06:05 +01:00