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

109 lines
2.5 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"
#include "engine/engine_fwd.h"
2019-02-04 21:34:12 +01:00
#include "engine/enginebase.h"
class QHideEvent;
class QShowEvent;
class QTimerEvent;
2018-02-27 18:06:05 +01:00
class QPaintEvent;
namespace Analyzer {
typedef std::vector<float> Scope;
class Base : public QWidget {
Q_OBJECT
public:
2020-06-15 21:55:05 +02:00
~Base() override { delete fht_; }
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
void changeTimeout(int newTimeout) {
timeout_ = newTimeout;
if (timer_.isActive()) {
timer_.stop();
timer_.start(timeout_, this);
2018-02-27 18:06:05 +01:00
}
}
virtual void framerateChanged() {}
protected:
2021-06-12 20:53:23 +02:00
explicit Base(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;
void paintEvent(QPaintEvent*) override;
void timerEvent(QTimerEvent*) override;
2018-02-27 18:06:05 +01:00
void polishEvent();
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
protected:
QBasicTimer timer_;
int timeout_;
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_;
};
void interpolate(const Scope&, Scope&);
void initSin(Scope&, const uint = 6000);
2019-02-04 21:34:12 +01:00
} // namespace Analyzer
#endif // ANALYZERBASE_H
2018-02-27 18:06:05 +01:00