comparison widgets/PluginParameterBox.cpp @ 530:c7fd7bce3c09

* fix to rounding problems in plugin parameter box
author Chris Cannam
date Mon, 30 Mar 2009 13:47:00 +0000
parents 4cb5cd9ccac7
children 1fe7951a61e8
comparison
equal deleted inserted replaced
529:3228b7913aa4 530:c7fd7bce3c09
118 118
119 int imin = 0, imax = 100; 119 int imin = 0, imax = 100;
120 120
121 if (!(hint & PortHint::Logarithmic)) { 121 if (!(hint & PortHint::Logarithmic)) {
122 if (qtz > 0.0) { 122 if (qtz > 0.0) {
123 imax = int((max - min) / qtz); 123 imax = lrintf((max - min) / qtz);
124 } else { 124 } else {
125 qtz = (max - min) / 100.0; 125 qtz = (max - min) / 100.0;
126 } 126 }
127 } 127 }
128 128
256 qtz = (max - min) / 100.0; 256 qtz = (max - min) / 100.0;
257 } 257 }
258 newValue = min + ival * qtz; 258 newValue = min + ival * qtz;
259 } 259 }
260 260
261 std::cerr << "PluginParameterBox::dialChanged: newValue = " << newValue << std::endl; 261 // std::cerr << "PluginParameterBox::dialChanged: newValue = " << newValue << std::endl;
262 262
263 QDoubleSpinBox *spin = m_params[identifier].spin; 263 QDoubleSpinBox *spin = m_params[identifier].spin;
264 if (spin) { 264 if (spin) {
265 spin->blockSignals(true); 265 spin->blockSignals(true);
266 spin->setValue(newValue); 266 spin->setValue(newValue);
267 spin->blockSignals(false); 267 spin->blockSignals(false);
268 } 268 }
269 269
270 // std::cerr << "setting plugin parameter \"" << identifier.toStdString() << "\" to value " << newValue << std::endl;
271
270 m_plugin->setParameter(identifier.toStdString(), newValue); 272 m_plugin->setParameter(identifier.toStdString(), newValue);
271 273
272 updateProgramCombo(); 274 updateProgramCombo();
273 275
274 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); 276 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString());
323 325
324 float qtz = 0.0; 326 float qtz = 0.0;
325 if (params.isQuantized) qtz = params.quantizeStep; 327 if (params.isQuantized) qtz = params.quantizeStep;
326 328
327 if (qtz > 0.0) { 329 if (qtz > 0.0) {
328 int step = int((value - min) / qtz); 330 int step = lrintf((value - min) / qtz);
329 value = min + step * qtz; 331 value = min + step * qtz;
330 } 332 }
331 333
332 int imax = 100; 334 int imax = 100;
333 335
334 if (qtz > 0.0) { 336 if (qtz > 0.0) {
335 imax = int((max - min) / qtz); 337 imax = lrintf((max - min) / qtz);
336 } else { 338 } else {
337 qtz = (max - min) / 100.0; 339 qtz = (max - min) / 100.0;
338 } 340 }
339 341
340 int ival = lrintf((value - min) / qtz); 342 int ival = lrintf((value - min) / qtz);
348 dial->setValue(ival); 350 dial->setValue(ival);
349 } 351 }
350 dial->blockSignals(false); 352 dial->blockSignals(false);
351 } 353 }
352 354
355 std::cerr << "setting plugin parameter \"" << identifier.toStdString() << "\" to value " << value << std::endl;
356
353 m_plugin->setParameter(identifier.toStdString(), value); 357 m_plugin->setParameter(identifier.toStdString(), value);
354 358
355 updateProgramCombo(); 359 updateProgramCombo();
356 360
357 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString()); 361 emit pluginConfigurationChanged(PluginXml(m_plugin).toXmlString());