comparison widgets/PluginParameterDialog.cpp @ 140:b9235b62fe31

* add window size/increment/shape settings to plugin parameter dialog, though they aren't yet connected up
author Chris Cannam
date Mon, 11 Sep 2006 16:40:18 +0000
parents 71992cee2ece
children bcb6d71be63c
comparison
equal deleted inserted replaced
139:5ec6b60658d8 140:b9235b62fe31
14 */ 14 */
15 15
16 #include "PluginParameterDialog.h" 16 #include "PluginParameterDialog.h"
17 17
18 #include "PluginParameterBox.h" 18 #include "PluginParameterBox.h"
19 #include "WindowTypeSelector.h"
19 20
20 #include "vamp-sdk/Plugin.h" 21 #include "vamp-sdk/Plugin.h"
21 22
22 #include <QGridLayout> 23 #include <QGridLayout>
23 #include <QLabel> 24 #include <QLabel>
30 PluginParameterDialog::PluginParameterDialog(Vamp::PluginBase *plugin, 31 PluginParameterDialog::PluginParameterDialog(Vamp::PluginBase *plugin,
31 int sourceChannels, 32 int sourceChannels,
32 int targetChannels, 33 int targetChannels,
33 int defaultChannel, 34 int defaultChannel,
34 QString output, 35 QString output,
36 bool showWindowSize,
37 bool showFrequencyDomainOptions,
35 QWidget *parent) : 38 QWidget *parent) :
36 QDialog(parent), 39 QDialog(parent),
37 m_plugin(plugin), 40 m_plugin(plugin),
38 m_channel(defaultChannel), 41 m_channel(defaultChannel),
39 m_parameterBox(0) 42 m_parameterBox(0)
177 channelLayout->addWidget(channelCombo); 180 channelLayout->addWidget(channelCombo);
178 } 181 }
179 } 182 }
180 } 183 }
181 184
185 if (showWindowSize) {
186
187 Vamp::Plugin *fePlugin = dynamic_cast<Vamp::Plugin *>(plugin);
188 int size = 1024;
189 int increment = 1024;
190 if (fePlugin) {
191 size = fePlugin->getPreferredBlockSize();
192 if (size == 0) size = 1024;
193 increment = fePlugin->getPreferredStepSize();
194 if (increment == 0) increment = size;
195 }
196
197 QGroupBox *windowBox = new QGroupBox;
198 windowBox->setTitle(tr("Processing"));
199 grid->addWidget(windowBox, 3, 0);
200
201 QGridLayout *windowLayout = new QGridLayout;
202 windowBox->setLayout(windowLayout);
203
204 if (showFrequencyDomainOptions) {
205 windowLayout->addWidget(new QLabel(tr("Window size:")), 0, 0);
206 } else {
207 windowLayout->addWidget(new QLabel(tr("Audio frames per block:")), 0, 0);
208 }
209
210 QComboBox *blockSizeCombo = new QComboBox;
211 blockSizeCombo->setEditable(true);
212 //!!! integer validator
213 for (int i = 0; i < 12; ++i) {
214 int val = pow(2, i + 3);
215 blockSizeCombo->addItem(QString("%1").arg(val));
216 if (val == size) blockSizeCombo->setCurrentIndex(i);
217 }
218 windowLayout->addWidget(blockSizeCombo, 0, 1);
219
220 if (showFrequencyDomainOptions) {
221
222 windowLayout->addWidget(new QLabel(tr("Window increment:")), 1, 0);
223
224 QComboBox *incrementCombo = new QComboBox;
225 incrementCombo->setEditable(true);
226 //!!! integer validator
227 for (int i = 0; i < 12; ++i) {
228 int val = pow(2, i + 3);
229 incrementCombo->addItem(QString("%1").arg(val));
230 if (val == increment) blockSizeCombo->setCurrentIndex(i);
231 }
232 windowLayout->addWidget(incrementCombo, 1, 1);
233
234 windowLayout->addWidget(new QLabel(tr("Window shape:")), 2, 0);
235 WindowTypeSelector *windowTypeSelector = new WindowTypeSelector;
236 windowLayout->addWidget(windowTypeSelector, 2, 1);
237 }
238 }
239
240 //!!! We lack a comfortable way of passing around the channel and
241 //blocksize data
242
182 QHBoxLayout *hbox = new QHBoxLayout; 243 QHBoxLayout *hbox = new QHBoxLayout;
183 grid->addLayout(hbox, 3, 0); 244 grid->addLayout(hbox, 4, 0);
184 245
185 QPushButton *ok = new QPushButton(tr("OK")); 246 QPushButton *ok = new QPushButton(tr("OK"));
186 QPushButton *cancel = new QPushButton(tr("Cancel")); 247 QPushButton *cancel = new QPushButton(tr("Cancel"));
187 hbox->addStretch(10); 248 hbox->addStretch(10);
188 hbox->addWidget(ok); 249 hbox->addWidget(ok);