-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathEffectView.cpp
291 lines (220 loc) · 7.57 KB
/
EffectView.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
/*
* EffectView.cpp - view-component for an effect
*
* Copyright (c) 2006-2007 Danny McRae <khjklujn/at/users.sourceforge.net>
* Copyright (c) 2007-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of LMMS - https://lmms.io
*
* This program 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 2 of the License, or (at your option) any later version.
*
* This program 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 this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
*/
#include <QLabel>
#include <QPushButton>
#include <QMdiArea>
#include <QMdiSubWindow>
#include <QPainter>
#include <QWhatsThis>
#include "EffectView.h"
#include "DummyEffect.h"
#include "CaptionMenu.h"
#include "embed.h"
#include "GuiApplication.h"
#include "gui_templates.h"
#include "Knob.h"
#include "LedCheckbox.h"
#include "MainWindow.h"
#include "TempoSyncKnob.h"
#include "ToolTip.h"
EffectView::EffectView( Effect * _model, QWidget * _parent ) :
PluginView( _model, _parent ),
m_bg( embed::getIconPixmap( "effect_plugin" ) ),
m_subWindow( NULL ),
m_controlView( NULL )
{
setFixedSize( 210, 60 );
// Disable effects that are of type "DummyEffect"
bool isEnabled = !dynamic_cast<DummyEffect *>( effect() );
m_bypass = new LedCheckBox( this, "", isEnabled ? LedCheckBox::Green : LedCheckBox::Red );
m_bypass->move( 3, 3 );
m_bypass->setEnabled( isEnabled );
m_bypass->setWhatsThis( tr( "Toggles the effect on or off." ) );
ToolTip::add( m_bypass, tr( "On/Off" ) );
m_wetDry = new Knob( knobBright_26, this );
m_wetDry->setLabel( tr( "W/D" ) );
m_wetDry->move( 27, 5 );
m_wetDry->setEnabled( isEnabled );
m_wetDry->setHintText( tr( "Wet Level:" ), "" );
m_wetDry->setWhatsThis( tr( "The Wet/Dry knob sets the ratio between "
"the input signal and the effect signal that "
"forms the output." ) );
m_autoQuit = new TempoSyncKnob( knobBright_26, this );
m_autoQuit->setLabel( tr( "DECAY" ) );
m_autoQuit->move( 60, 5 );
m_autoQuit->setEnabled( isEnabled );
m_autoQuit->setHintText( tr( "Time:" ), "ms" );
m_autoQuit->setWhatsThis( tr(
"The Decay knob controls how many buffers of silence must pass before the "
"plugin stops processing. Smaller values will reduce the CPU overhead but "
"run the risk of clipping the tail on delay and reverb effects." ) );
m_gate = new Knob( knobBright_26, this );
m_gate->setLabel( tr( "GATE" ) );
m_gate->move( 93, 5 );
m_gate->setEnabled( isEnabled );
m_gate->setHintText( tr( "Gate:" ), "" );
m_gate->setWhatsThis( tr(
"The Gate knob controls the signal level that is considered to be 'silence' "
"while deciding when to stop processing signals." ) );
setModel( _model );
if( effect()->controls()->controlCount() > 0 )
{
QPushButton * ctls_btn = new QPushButton( tr( "Controls" ),
this );
QFont f = ctls_btn->font();
ctls_btn->setFont( pointSize<8>( f ) );
ctls_btn->setGeometry( 140, 14, 50, 20 );
connect( ctls_btn, SIGNAL( clicked() ),
this, SLOT( editControls() ) );
m_controlView = effect()->controls()->createView();
if( m_controlView )
{
m_subWindow = gui->mainWindow()->addWindowedWidget( m_controlView );
m_subWindow->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
m_subWindow->setFixedSize( m_subWindow->size() );
Qt::WindowFlags flags = m_subWindow->windowFlags();
flags &= ~Qt::WindowMaximizeButtonHint;
m_subWindow->setWindowFlags( flags );
connect( m_controlView, SIGNAL( closed() ),
this, SLOT( closeEffects() ) );
m_subWindow->hide();
}
}
setWhatsThis( tr(
"Effect plugins function as a chained series of effects where the signal will "
"be processed from top to bottom.\n\n"
"The On/Off switch allows you to bypass a given plugin at any point in "
"time.\n\n"
"The Wet/Dry knob controls the balance between the input signal and the "
"effected signal that is the resulting output from the effect. The input "
"for the stage is the output from the previous stage. So, the 'dry' signal "
"for effects lower in the chain contains all of the previous effects.\n\n"
"The Decay knob controls how long the signal will continue to be processed "
"after the notes have been released. The effect will stop processing signals "
"when the volume has dropped below a given threshold for a given length of "
"time. This knob sets the 'given length of time'. Longer times will require "
"more CPU, so this number should be set low for most effects. It needs to be "
"bumped up for effects that produce lengthy periods of silence, e.g. "
"delays.\n\n"
"The Gate knob controls the 'given threshold' for the effect's auto shutdown. "
"The clock for the 'given length of time' will begin as soon as the processed "
"signal level drops below the level specified with this knob.\n\n"
"The Controls button opens a dialog for editing the effect's parameters.\n\n"
"Right clicking will bring up a context menu where you can change the order "
"in which the effects are processed or delete an effect altogether." ) );
//move above vst effect view creation
//setModel( _model );
}
EffectView::~EffectView()
{
#ifdef LMMS_BUILD_LINUX
delete m_subWindow;
#else
if( m_subWindow )
{
// otherwise on win32 build VST GUI can get lost
m_subWindow->hide();
}
#endif
}
void EffectView::editControls()
{
if( m_subWindow )
{
if( !m_subWindow->isVisible() )
{
m_subWindow->show();
m_subWindow->raise();
effect()->controls()->setViewVisible( true );
}
else
{
m_subWindow->hide();
effect()->controls()->setViewVisible( false );
}
}
}
void EffectView::moveUp()
{
emit moveUp( this );
}
void EffectView::moveDown()
{
emit moveDown( this );
}
void EffectView::deletePlugin()
{
emit deletePlugin( this );
}
void EffectView::displayHelp()
{
QWhatsThis::showText( mapToGlobal( rect().bottomRight() ),
whatsThis() );
}
void EffectView::closeEffects()
{
if( m_subWindow )
{
m_subWindow->hide();
}
effect()->controls()->setViewVisible( false );
}
void EffectView::contextMenuEvent( QContextMenuEvent * )
{
QPointer<CaptionMenu> contextMenu = new CaptionMenu( model()->displayName(), this );
contextMenu->addAction( embed::getIconPixmap( "arp_up" ),
tr( "Move &up" ),
this, SLOT( moveUp() ) );
contextMenu->addAction( embed::getIconPixmap( "arp_down" ),
tr( "Move &down" ),
this, SLOT( moveDown() ) );
contextMenu->addSeparator();
contextMenu->addAction( embed::getIconPixmap( "cancel" ),
tr( "&Remove this plugin" ),
this, SLOT( deletePlugin() ) );
contextMenu->addSeparator();
contextMenu->addHelpAction();
contextMenu->exec( QCursor::pos() );
delete contextMenu;
}
void EffectView::paintEvent( QPaintEvent * )
{
QPainter p( this );
p.drawPixmap( 0, 0, m_bg );
QFont f = pointSizeF( font(), 7.5f );
f.setBold( true );
p.setFont( f );
p.setPen( palette().shadow().color() );
p.drawText( 6, 55, model()->displayName() );
p.setPen( palette().text().color() );
p.drawText( 5, 54, model()->displayName() );
}
void EffectView::modelChanged()
{
m_bypass->setModel( &effect()->m_enabledModel );
m_wetDry->setModel( &effect()->m_wetDryModel );
m_autoQuit->setModel( &effect()->m_autoQuitModel );
m_gate->setModel( &effect()->m_gateModel );
}