LMMS
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#include "SampleThumbnail.h"
31
32
33namespace lmms
34{
35
36class Sample;
37
38namespace gui
39{
40
41class AudioFileProcessorWaveView : public QWidget
42{
43 Q_OBJECT
44protected:
45 virtual void enterEvent(QEvent* e);
46 virtual void leaveEvent(QEvent* e);
47 virtual void mousePressEvent(QMouseEvent* me);
48 virtual void mouseReleaseEvent(QMouseEvent* me);
49 virtual void mouseMoveEvent(QMouseEvent* me);
50 virtual void wheelEvent(QWheelEvent* we);
51 virtual void paintEvent(QPaintEvent* pe);
52
53
54public:
55 enum class Point
56 {
60 } ;
61
62 class knob : public Knob
63 {
66
67
68 public:
69 knob(QWidget* parent) :
71 m_waveView(0),
73 {
74 }
75
77 {
78 m_waveView = wv;
79 }
80
82 {
84 }
85
86 void slideBy(double v, bool check_bound = true)
87 {
88 slideTo(model()->value() + v, check_bound);
89 }
90
91 void slideTo(double v, bool check_bound = true);
92
93
94 protected:
95 float getValue(const QPoint & p);
96
97
98 private:
99 bool checkBound(double v) const;
100 } ;
101
102
103public slots:
104 void update()
105 {
106 updateGraph();
107 QWidget::update();
108 }
109
110 void isPlaying(lmms::f_cnt_t current_frame);
111
112
113private:
114 static const int s_padding = 2;
115
125
127 QPixmap m_graph;
129 int m_to;
146
148
149public:
150 AudioFileProcessorWaveView(QWidget* parent, int w, int h, Sample const* buf,
151 knob* start, knob* end, knob* loop);
152
153
154 void updateSampleRange();
155private:
156 void setTo(int to);
157 void setFrom(int from);
158 int range() const;
159 void zoom(const bool out = false);
160 void slide(int px);
161 void slideSamplePointByPx(Point point, int px);
162 void slideSamplePointByFrames(Point point, long frameOffset, bool slideTo = false);
163 void slideSampleByFrames(long frameOffset);
164
166 {
167 slideSamplePointByFrames(point, frames, true);
168 }
169
170 void updateGraph();
171 void reverse();
172 void updateCursor(const QMouseEvent* me = nullptr);
173 bool pointerCloseToStartEndOrLoop(const QMouseEvent* me) const;
174
176
177 static bool isCloseTo(int a, int b)
178 {
179 return qAbs(a - b) < 4;
180 }
181
182} ;
183
184} // namespace gui
185
186} // namespace lmms
187
188#endif // LMMS_AUDIO_FILE_PROCESSOR_WAVE_VIEW_H
uint8_t a
Definition Spc_Cpu.h:141
goto loop
Definition Spc_Cpu.h:155
Definition Sample.h:37
Definition SampleThumbnail.h:55
Definition AudioFileProcessorWaveView.h:63
const AudioFileProcessorWaveView * m_waveView
Definition AudioFileProcessorWaveView.h:64
void slideTo(double v, bool check_bound=true)
Definition AudioFileProcessorWaveView.cpp:529
void setWaveView(const AudioFileProcessorWaveView *wv)
Definition AudioFileProcessorWaveView.h:76
const Knob * m_relatedKnob
Definition AudioFileProcessorWaveView.h:65
bool checkBound(double v) const
Definition AudioFileProcessorWaveView.cpp:548
void setRelatedKnob(const Knob *knob)
Definition AudioFileProcessorWaveView.h:81
float getValue(const QPoint &p)
Definition AudioFileProcessorWaveView.cpp:539
void slideBy(double v, bool check_bound=true)
Definition AudioFileProcessorWaveView.h:86
knob(QWidget *parent)
Definition AudioFileProcessorWaveView.h:69
bool m_animation
Definition AudioFileProcessorWaveView.h:144
DraggingType
Definition AudioFileProcessorWaveView.h:117
@ SampleLoop
Definition AudioFileProcessorWaveView.h:123
@ SampleStart
Definition AudioFileProcessorWaveView.h:121
@ SlideWave
Definition AudioFileProcessorWaveView.h:119
@ ZoomWave
Definition AudioFileProcessorWaveView.h:120
@ Wave
Definition AudioFileProcessorWaveView.h:118
@ SampleEnd
Definition AudioFileProcessorWaveView.h:122
void slideSamplePointToFrames(Point point, f_cnt_t frames)
Definition AudioFileProcessorWaveView.h:165
knob * m_startKnob
Definition AudioFileProcessorWaveView.h:133
SampleThumbnail m_sampleThumbnail
Definition AudioFileProcessorWaveView.h:145
AudioFileProcessorWaveView(QWidget *parent, int w, int h, Sample const *buf, knob *start, knob *end, knob *loop)
Definition AudioFileProcessorWaveView.cpp:70
virtual void mouseReleaseEvent(QMouseEvent *me)
Definition AudioFileProcessorWaveView.cpp:145
friend class AudioFileProcessorView
Definition AudioFileProcessorWaveView.h:147
void reverse()
Definition AudioFileProcessorWaveView.cpp:477
void configureKnobRelationsAndWaveViews()
Definition AudioFileProcessorWaveView.cpp:518
void zoom(const bool out=false)
Definition AudioFileProcessorWaveView.cpp:362
virtual void mousePressEvent(QMouseEvent *me)
Definition AudioFileProcessorWaveView.cpp:117
bool pointerCloseToStartEndOrLoop(const QMouseEvent *me) const
Definition AudioFileProcessorWaveView.cpp:510
QPoint m_draggingLastPoint
Definition AudioFileProcessorWaveView.h:140
void setTo(int to)
Definition AudioFileProcessorWaveView.cpp:55
float m_last_amp
Definition AudioFileProcessorWaveView.h:132
int m_loopFrameX
Definition AudioFileProcessorWaveView.h:138
f_cnt_t m_framesPlayed
Definition AudioFileProcessorWaveView.h:143
Sample const * m_sample
Definition AudioFileProcessorWaveView.h:126
int m_startFrameX
Definition AudioFileProcessorWaveView.h:136
virtual void paintEvent(QPaintEvent *pe)
Definition AudioFileProcessorWaveView.cpp:205
virtual void enterEvent(QEvent *e)
Definition AudioFileProcessorWaveView.cpp:107
void slideSamplePointByFrames(Point point, long frameOffset, bool slideTo=false)
Definition AudioFileProcessorWaveView.cpp:419
void setFrom(int from)
Definition AudioFileProcessorWaveView.cpp:60
void isPlaying(lmms::f_cnt_t current_frame)
Definition AudioFileProcessorWaveView.cpp:101
void updateGraph()
Definition AudioFileProcessorWaveView.cpp:314
virtual void mouseMoveEvent(QMouseEvent *me)
Definition AudioFileProcessorWaveView.cpp:154
int m_last_to
Definition AudioFileProcessorWaveView.h:131
QPixmap m_graph
Definition AudioFileProcessorWaveView.h:127
Point
Definition AudioFileProcessorWaveView.h:56
@ End
Definition AudioFileProcessorWaveView.h:58
@ Loop
Definition AudioFileProcessorWaveView.h:59
@ Start
Definition AudioFileProcessorWaveView.h:57
int range() const
Definition AudioFileProcessorWaveView.cpp:65
static const int s_padding
Definition AudioFileProcessorWaveView.h:114
int m_last_from
Definition AudioFileProcessorWaveView.h:130
int m_endFrameX
Definition AudioFileProcessorWaveView.h:137
knob * m_endKnob
Definition AudioFileProcessorWaveView.h:134
void updateSampleRange()
Definition AudioFileProcessorWaveView.cpp:45
void slideSamplePointByPx(Point point, int px)
Definition AudioFileProcessorWaveView.cpp:411
bool m_reversed
Definition AudioFileProcessorWaveView.h:142
int m_to
Definition AudioFileProcessorWaveView.h:129
int m_from
Definition AudioFileProcessorWaveView.h:128
void slideSampleByFrames(long frameOffset)
Definition AudioFileProcessorWaveView.cpp:454
static bool isCloseTo(int a, int b)
Definition AudioFileProcessorWaveView.h:177
bool m_isDragging
Definition AudioFileProcessorWaveView.h:139
virtual void leaveEvent(QEvent *e)
Definition AudioFileProcessorWaveView.cpp:112
knob * m_loopKnob
Definition AudioFileProcessorWaveView.h:135
void updateCursor(const QMouseEvent *me=nullptr)
Definition AudioFileProcessorWaveView.cpp:492
DraggingType m_draggingType
Definition AudioFileProcessorWaveView.h:141
virtual void wheelEvent(QWheelEvent *we)
Definition AudioFileProcessorWaveView.cpp:199
void update()
Definition AudioFileProcessorWaveView.h:104
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:40
FloatModel * model()
Definition AutomatableModelView.h:121
* e
Definition inflate.c:1404
UINT_D64 w
Definition inflate.c:942
unsigned v[N_MAX]
Definition inflate.c:1584
static uintptr_t parent
Definition pugl.h:1644
virtual ASIOError start()=0
float out
Definition lilv_test.c:1461
Definition AudioPortAudio.cpp:223
KnobType
Definition Knob.h:39
@ Bright26
Definition Knob.h:40
Definition AudioAlsa.cpp:35
std::uint64_t f_cnt_t
Definition LmmsTypes.h:43
uch * p
Definition crypt.c:594
uch h[RAND_HEAD_LEN]
Definition crypt.c:459
b
Definition crypt.c:628
#define slide
Definition unzpriv.h:2067