LMMS
Loading...
Searching...
No Matches
EqSpectrumView.h
Go to the documentation of this file.
1/* eqspectrumview.h - defination of EqSpectrumView class.
2*
3* Copyright (c) 2014 David French <dave/dot/french3/at/googlemail/dot/com>
4*
5* This file is part of LMMS - https://lmms.io
6*
7* This program is free software; you can redistribute it and/or
8* modify it under the terms of the GNU General Public
9* License as published by the Free Software Foundation; either
10* version 2 of the License, or (at your option) any later version.
11*
12* This program is distributed in the hope that it will be useful,
13* but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this program (see COPYING); if not, write to the
19* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20* Boston, MA 02110-1301 USA.
21*
22*/
23#ifndef EQSPECTRUMVIEW_H
24#define EQSPECTRUMVIEW_H
25
26#include <QPainterPath>
27#include <QWidget>
28
29#include "fft_helpers.h"
30#include "LmmsTypes.h"
31
32namespace lmms
33{
34
35class SampleFrame;
36
37const int MAX_BANDS = 2048;
39{
40public:
41 EqAnalyser();
42 virtual ~EqAnalyser();
43
45 bool getInProgress();
46 void clear();
47
48 void analyze( SampleFrame* buf, const f_cnt_t frames );
49
50 float getEnergy() const;
51 int getSampleRate() const;
52 bool getActive() const;
53
54 void setActive(bool active);
55
56private:
57 fftwf_plan m_fftPlan;
58 fftwf_complex * m_specBuf;
62 float m_energy;
67};
68
69
70namespace gui
71{
72
73class EqSpectrumView : public QWidget
74{
75 Q_OBJECT
76public:
77 explicit EqSpectrumView( EqAnalyser *b, QWidget *_parent = 0 );
78 ~EqSpectrumView() override = default;
79
80 QColor getColor() const;
81 void setColor( const QColor &value );
82
83protected:
84 void paintEvent( QPaintEvent *event ) override;
85
86private slots:
87 void periodicalUpdate();
88
89private:
90 QColor m_color;
92 QPainterPath m_path;
93 float m_peakSum;
95 float m_scale;
98 QList<float> m_bandHeight;
99
100 float bandToFreq ( int index );
101};
102
103
104} // namespace gui
105
106} // namespace lmms
107
108#endif // EQSPECTRUMVIEW_H
Definition EqSpectrumView.h:39
fftwf_plan m_fftPlan
Definition EqSpectrumView.h:57
bool m_active
Definition EqSpectrumView.h:64
void clear()
Definition EqSpectrumView.cpp:174
float m_bands[MAX_BANDS]
Definition EqSpectrumView.h:44
float m_fftWindow[FFT_BUFFER_SIZE]
Definition EqSpectrumView.h:66
EqAnalyser()
Definition EqSpectrumView.cpp:40
virtual ~EqAnalyser()
Definition EqSpectrumView.cpp:70
void analyze(SampleFrame *buf, const f_cnt_t frames)
Definition EqSpectrumView.cpp:79
int m_sampleRate
Definition EqSpectrumView.h:63
bool getInProgress()
Definition EqSpectrumView.cpp:166
float m_buffer[FFT_BUFFER_SIZE *2]
Definition EqSpectrumView.h:60
int getSampleRate() const
Definition EqSpectrumView.cpp:142
bool m_inProgress
Definition EqSpectrumView.h:65
int m_framesFilledUp
Definition EqSpectrumView.h:61
void setActive(bool active)
Definition EqSpectrumView.cpp:158
float m_energy
Definition EqSpectrumView.h:62
fftwf_complex * m_specBuf
Definition EqSpectrumView.h:58
float m_absSpecBuf[FFT_BUFFER_SIZE+1]
Definition EqSpectrumView.h:59
float getEnergy() const
Definition EqSpectrumView.cpp:134
bool getActive() const
Definition EqSpectrumView.cpp:150
Definition SampleFrame.h:41
float bandToFreq(int index)
Definition EqSpectrumView.cpp:291
int m_skipBands
Definition EqSpectrumView.h:96
QColor getColor() const
Definition EqSpectrumView.cpp:275
EqAnalyser * m_analyser
Definition EqSpectrumView.h:91
float m_peakSum
Definition EqSpectrumView.h:93
void setColor(const QColor &value)
Definition EqSpectrumView.cpp:283
bool m_periodicalUpdate
Definition EqSpectrumView.h:97
float m_scale
Definition EqSpectrumView.h:95
~EqSpectrumView() override=default
void paintEvent(QPaintEvent *event) override
Definition EqSpectrumView.cpp:210
QList< float > m_bandHeight
Definition EqSpectrumView.h:98
QColor m_color
Definition EqSpectrumView.h:90
void periodicalUpdate()
Definition EqSpectrumView.cpp:299
float m_pixelsPerUnitWidth
Definition EqSpectrumView.h:94
QPainterPath m_path
Definition EqSpectrumView.h:92
EqSpectrumView(EqAnalyser *b, QWidget *_parent=0)
Definition EqSpectrumView.cpp:187
static PuglViewHint int value
Definition pugl.h:1708
Definition AudioPortAudio.cpp:223
Definition AudioAlsa.cpp:35
const int MAX_BANDS
Definition EqSpectrumView.h:37
std::uint64_t f_cnt_t
Definition LmmsTypes.h:43
constexpr auto FFT_BUFFER_SIZE
Definition fft_helpers.h:40
b
Definition crypt.c:628