lmms
Cross-platform music production software
Loading...
Searching...
No Matches
AudioFileProcessorWaveView.h
Go to the documentation of this file.
1/*
2 * AudioFileProcessorWaveView.h - Wave renderer of the AFP
3 *
4 * Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_AUDIO_FILE_PROCESSOR_WAVE_VIEW_H
26#define LMMS_AUDIO_FILE_PROCESSOR_WAVE_VIEW_H
27
28
29#include "Knob.h"
30
31namespace lmms
32{
33
34class Sample;
35
36namespace gui
37{
38
39class AudioFileProcessorWaveView : public QWidget
40{
41 Q_OBJECT
42protected:
43 virtual void enterEvent(QEvent* e);
44 virtual void leaveEvent(QEvent* e);
45 virtual void mousePressEvent(QMouseEvent* me);
46 virtual void mouseReleaseEvent(QMouseEvent* me);
47 virtual void mouseMoveEvent(QMouseEvent* me);
48 virtual void wheelEvent(QWheelEvent* we);
49 virtual void paintEvent(QPaintEvent* pe);
50
51
52public:
53 enum class Point
54 {
55 Start,
56 End,
57 Loop
58 } ;
59
60 class knob : public Knob
61 {
64
65
66 public:
67 knob(QWidget* parent) :
68 Knob(KnobType::Bright26, parent),
69 m_waveView(0),
71 {
72 }
73
75 {
76 m_waveView = wv;
77 }
78
80 {
82 }
83
84 void slideBy(double v, bool check_bound = true)
85 {
86 slideTo(model()->value() + v, check_bound);
87 }
88
89 void slideTo(double v, bool check_bound = true);
90
91
92 protected:
93 float getValue(const QPoint & p);
94
95
96 private:
97 bool checkBound(double v) const;
98 } ;
99
100
101public slots:
102 void update()
103 {
104 updateGraph();
105 QWidget::update();
106 }
107
108 void isPlaying(lmms::f_cnt_t current_frame);
109
110
111private:
112 static const int s_padding = 2;
113
114 enum class DraggingType
115 {
116 Wave,
117 SlideWave,
118 ZoomWave,
119 SampleStart,
120 SampleEnd,
121 SampleLoop
122 } ;
123
125 QPixmap m_graph;
127 int m_to;
143
144public:
145 AudioFileProcessorWaveView(QWidget* parent, int w, int h, Sample const* buf,
146 knob* start, knob* end, knob* loop);
147
148
149 void updateSampleRange();
150private:
151 void setTo(int to);
152 void setFrom(int from);
153 int range() const;
154 void zoom(const bool out = false);
155 void slide(int px);
156 void slideSamplePointByPx(Point point, int px);
157 void slideSamplePointByFrames(Point point, long frameOffset, bool slideTo = false);
158 void slideSampleByFrames(long frameOffset);
159
161 {
162 slideSamplePointByFrames(point, frames, true);
163 }
164
165 void updateGraph();
166 void reverse();
167 void updateCursor(const QMouseEvent* me = nullptr);
168 bool pointerCloseToStartEndOrLoop(const QMouseEvent* me) const;
169
171
172 static bool isCloseTo(int a, int b)
173 {
174 return qAbs(a - b) < 4;
175 }
176
177} ;
178
179} // namespace gui
180
181} // namespace lmms
182
183#endif // LMMS_AUDIO_FILE_PROCESSOR_WAVE_VIEW_H
Definition Sample.h:37
Definition AudioFileProcessorWaveView.h:61
const AudioFileProcessorWaveView * m_waveView
Definition AudioFileProcessorWaveView.h:62
void slideTo(double v, bool check_bound=true)
Definition AudioFileProcessorWaveView.cpp:531
void setWaveView(const AudioFileProcessorWaveView *wv)
Definition AudioFileProcessorWaveView.h:74
const Knob * m_relatedKnob
Definition AudioFileProcessorWaveView.h:63
bool checkBound(double v) const
Definition AudioFileProcessorWaveView.cpp:550
void setRelatedKnob(const Knob *knob)
Definition AudioFileProcessorWaveView.h:79
float getValue(const QPoint &p)
Definition AudioFileProcessorWaveView.cpp:541
void slideBy(double v, bool check_bound=true)
Definition AudioFileProcessorWaveView.h:84
knob(QWidget *parent)
Definition AudioFileProcessorWaveView.h:67
bool m_animation
Definition AudioFileProcessorWaveView.h:142
DraggingType
Definition AudioFileProcessorWaveView.h:115
void slideSamplePointToFrames(Point point, f_cnt_t frames)
Definition AudioFileProcessorWaveView.h:160
knob * m_startKnob
Definition AudioFileProcessorWaveView.h:131
AudioFileProcessorWaveView(QWidget *parent, int w, int h, Sample const *buf, knob *start, knob *end, knob *loop)
Definition AudioFileProcessorWaveView.cpp:72
virtual void mouseReleaseEvent(QMouseEvent *me)
Definition AudioFileProcessorWaveView.cpp:146
void reverse()
Definition AudioFileProcessorWaveView.cpp:479
void configureKnobRelationsAndWaveViews()
Definition AudioFileProcessorWaveView.cpp:520
void zoom(const bool out=false)
Definition AudioFileProcessorWaveView.cpp:364
virtual void mousePressEvent(QMouseEvent *me)
Definition AudioFileProcessorWaveView.cpp:118
bool pointerCloseToStartEndOrLoop(const QMouseEvent *me) const
Definition AudioFileProcessorWaveView.cpp:512
QPoint m_draggingLastPoint
Definition AudioFileProcessorWaveView.h:138
void setTo(int to)
Definition AudioFileProcessorWaveView.cpp:57
float m_last_amp
Definition AudioFileProcessorWaveView.h:130
int m_loopFrameX
Definition AudioFileProcessorWaveView.h:136
f_cnt_t m_framesPlayed
Definition AudioFileProcessorWaveView.h:141
Sample const * m_sample
Definition AudioFileProcessorWaveView.h:124
int m_startFrameX
Definition AudioFileProcessorWaveView.h:134
virtual void paintEvent(QPaintEvent *pe)
Definition AudioFileProcessorWaveView.cpp:206
virtual void enterEvent(QEvent *e)
Definition AudioFileProcessorWaveView.cpp:108
void slideSamplePointByFrames(Point point, long frameOffset, bool slideTo=false)
Definition AudioFileProcessorWaveView.cpp:421
void setFrom(int from)
Definition AudioFileProcessorWaveView.cpp:62
void isPlaying(lmms::f_cnt_t current_frame)
Definition AudioFileProcessorWaveView.cpp:102
void updateGraph()
Definition AudioFileProcessorWaveView.cpp:315
virtual void mouseMoveEvent(QMouseEvent *me)
Definition AudioFileProcessorWaveView.cpp:155
int m_last_to
Definition AudioFileProcessorWaveView.h:129
QPixmap m_graph
Definition AudioFileProcessorWaveView.h:125
Point
Definition AudioFileProcessorWaveView.h:54
void slide(int px)
Definition AudioFileProcessorWaveView.cpp:398
int range() const
Definition AudioFileProcessorWaveView.cpp:67
static const int s_padding
Definition AudioFileProcessorWaveView.h:112
int m_last_from
Definition AudioFileProcessorWaveView.h:128
int m_endFrameX
Definition AudioFileProcessorWaveView.h:135
knob * m_endKnob
Definition AudioFileProcessorWaveView.h:132
void updateSampleRange()
Definition AudioFileProcessorWaveView.cpp:47
void slideSamplePointByPx(Point point, int px)
Definition AudioFileProcessorWaveView.cpp:413
bool m_reversed
Definition AudioFileProcessorWaveView.h:140
int m_to
Definition AudioFileProcessorWaveView.h:127
int m_from
Definition AudioFileProcessorWaveView.h:126
void slideSampleByFrames(long frameOffset)
Definition AudioFileProcessorWaveView.cpp:456
static bool isCloseTo(int a, int b)
Definition AudioFileProcessorWaveView.h:172
bool m_isDragging
Definition AudioFileProcessorWaveView.h:137
virtual void leaveEvent(QEvent *e)
Definition AudioFileProcessorWaveView.cpp:113
knob * m_loopKnob
Definition AudioFileProcessorWaveView.h:133
void updateCursor(const QMouseEvent *me=nullptr)
Definition AudioFileProcessorWaveView.cpp:494
DraggingType m_draggingType
Definition AudioFileProcessorWaveView.h:139
virtual void wheelEvent(QWheelEvent *we)
Definition AudioFileProcessorWaveView.cpp:200
void update()
Definition AudioFileProcessorWaveView.h:102
T value() const
Definition AutomatableModelView.h:59
Knob(KnobType _knob_num, QWidget *_parent=nullptr, const QString &_name=QString())
Construct a Knob with the given style and no label.
Definition Knob.cpp:41
FloatModel * model()
Definition AutomatableModelView.h:121
Definition AudioPortAudio.cpp:209
KnobType
Definition Knob.h:39
@ Bright26
Definition Knob.h:40
Definition RemotePluginBase.cpp:34
std::uint64_t f_cnt_t
Definition LmmsTypes.h:43