LMMS
Loading...
Searching...
No Matches
SaWaterfallView.h
Go to the documentation of this file.
1/* SaWaterfallView.h - declaration of SaWaterfallView class.
2 *
3 * Copyright (c) 2019 Martin Pavelek <he29/dot/HS/at/gmail/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 SAWATERFALLVIEW_H
24#define SAWATERFALLVIEW_H
25
26#include <string>
27#include <utility>
28#include <vector>
29#include <QWidget>
30
31
32
33namespace lmms
34{
35class SaControls;
36class SaProcessor;
37}
38
39namespace lmms::gui
40{
41
43
44
45// Widget that displays a spectrum waterfall (spectrogram) and time labels.
46class SaWaterfallView : public QWidget
47{
48 Q_OBJECT
49public:
50 explicit SaWaterfallView(SaControls *controls, SaProcessor *processor, QWidget *_parent = 0);
51 ~SaWaterfallView() override = default;
52
53 QSize sizeHint() const override {return QSize(400, 350);}
54
55 // Check if waterfall should be displayed and adjust window size if needed.
56 void updateVisibility();
57
58protected:
59 void paintEvent(QPaintEvent *event) override;
60 void mouseMoveEvent(QMouseEvent *event) override;
61 void mousePressEvent(QMouseEvent *event) override;
62 void resizeEvent(QResizeEvent *event) override;
63
64private slots:
65 void periodicUpdate();
66
67private:
71
72 // Methods and data used to make time labels
75 float samplesPerLine();
76 float secondsPerLine();
77 float timeToYPixel(float time, int height);
78 float yPixelToTime(float position, int height);
79 std::vector<std::pair<float, std::string>> makeTimeTics();
80 std::vector<std::pair<float, std::string>> m_timeTics; // 0..n (s)
81
82 // current cursor location and a method to draw it
83 QPointF m_cursor;
84 void drawCursor(QPainter &painter);
85
86 // current boundaries for drawing
87 unsigned int m_displayTop;
88 unsigned int m_displayBottom;
89 unsigned int m_displayLeft;
90 unsigned int m_displayRight;
91 unsigned int m_displayWidth;
92 unsigned int m_displayHeight;
93
94 #ifdef SA_DEBUG
95 float m_execution_avg;
96 #endif
97};
98
99
100} // namespace lmms::gui
101
102#endif // SAWATERFALLVIEW_H
Definition SaControls.h:48
Receives audio data, runs FFT analysis and stores the result.
Definition SaProcessor.h:50
Definition EffectControlDialog.h:42
unsigned int m_displayBottom
Definition SaWaterfallView.h:88
float timeToYPixel(float time, int height)
Definition SaWaterfallView.cpp:196
void periodicUpdate()
Definition SaWaterfallView.cpp:247
float samplesPerLine()
Definition SaWaterfallView.cpp:184
float m_oldHeight
Definition SaWaterfallView.h:74
QPointF m_cursor
Definition SaWaterfallView.h:83
float yPixelToTime(float position, int height)
Definition SaWaterfallView.cpp:205
void updateVisibility()
Definition SaWaterfallView.cpp:255
unsigned int m_displayRight
Definition SaWaterfallView.h:90
SaWaterfallView(SaControls *controls, SaProcessor *processor, QWidget *_parent=0)
Definition SaWaterfallView.cpp:48
void resizeEvent(QResizeEvent *event) override
Definition SaWaterfallView.cpp:340
unsigned int m_displayHeight
Definition SaWaterfallView.h:92
void drawCursor(QPainter &painter)
Definition SaWaterfallView.cpp:283
const EffectControlDialog * m_controlDialog
Definition SaWaterfallView.h:70
void paintEvent(QPaintEvent *event) override
Definition SaWaterfallView.cpp:82
const SaControls * m_controls
Definition SaWaterfallView.h:68
void mouseMoveEvent(QMouseEvent *event) override
Definition SaWaterfallView.cpp:328
unsigned int m_displayLeft
Definition SaWaterfallView.h:89
QSize sizeHint() const override
Definition SaWaterfallView.h:53
SaProcessor * m_processor
Definition SaWaterfallView.h:69
float secondsPerLine()
Definition SaWaterfallView.cpp:189
float m_oldSecondsPerLine
Definition SaWaterfallView.h:73
unsigned int m_displayTop
Definition SaWaterfallView.h:87
unsigned int m_displayWidth
Definition SaWaterfallView.h:91
void mousePressEvent(QMouseEvent *event) override
Definition SaWaterfallView.cpp:333
std::vector< std::pair< float, std::string > > makeTimeTics()
Definition SaWaterfallView.cpp:215
std::vector< std::pair< float, std::string > > m_timeTics
Definition SaWaterfallView.h:80
~SaWaterfallView() override=default
static int int height
Definition pugl.h:1594
Definition AudioPortAudio.cpp:223
Definition AudioAlsa.cpp:35
QPoint position(const QDropEvent *de)
position is a backwards-compatible adapter for QDropEvent::position and pos functions.
Definition DeprecationHelper.h:47