From cf925d7c5bfa946681780cee39f4aa6662d8a2fd Mon Sep 17 00:00:00 2001 From: Vesa Date: Sat, 15 Mar 2014 10:45:55 +0200 Subject: [PATCH] Knob: add volumeRatio property to allow showing knobs with ratios other than 100 in dBV Waveshaper, Dynamics processor: make input/output knobs respect the show in dBV setting --- include/knob.h | 3 +++ .../dynamics_processor/dynamics_processor_control_dialog.cpp | 4 ++++ plugins/waveshaper/waveshaper_control_dialog.cpp | 4 ++++ src/gui/widgets/knob.cpp | 3 ++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/knob.h b/include/knob.h index 2c6d8de07..81141220d 100644 --- a/include/knob.h +++ b/include/knob.h @@ -58,6 +58,8 @@ class EXPORT knob : public QWidget, public FloatModelView // correctly so we need to do this: Q_PROPERTY(QColor outerColor READ outerColor WRITE setOuterColor) mapPropertyFromModel(bool,isVolumeKnob,setVolumeKnob,m_volumeKnob); + mapPropertyFromModel(float,volumeRatio,setVolumeRatio,m_volumeRatio); + public: knob( int _knob_num, QWidget * _parent = NULL, const QString & _name = QString() ); virtual ~knob(); @@ -149,6 +151,7 @@ private: QPixmap * m_knobPixmap; BoolModel m_volumeKnob; + FloatModel m_volumeRatio; QPoint m_mouseOffset; QPoint m_origMousePos; diff --git a/plugins/dynamics_processor/dynamics_processor_control_dialog.cpp b/plugins/dynamics_processor/dynamics_processor_control_dialog.cpp index 6fcb1d1d6..e92e8e6d0 100644 --- a/plugins/dynamics_processor/dynamics_processor_control_dialog.cpp +++ b/plugins/dynamics_processor/dynamics_processor_control_dialog.cpp @@ -58,12 +58,16 @@ dynProcControlDialog::dynProcControlDialog( waveGraph -> setMaximumSize( 204, 205 ); knob * inputKnob = new knob( knobBright_26, this); + inputKnob -> setVolumeKnob( true ); + inputKnob -> setVolumeRatio( 1.0 ); inputKnob -> move( 14, 251 ); inputKnob->setModel( &_controls->m_inputModel ); inputKnob->setLabel( tr( "INPUT" ) ); inputKnob->setHintText( tr( "Input gain:" ) + " ", "" ); knob * outputKnob = new knob( knobBright_26, this ); + outputKnob -> setVolumeKnob( true ); + outputKnob -> setVolumeRatio( 1.0 ); outputKnob -> move( 54, 251 ); outputKnob->setModel( &_controls->m_outputModel ); outputKnob->setLabel( tr( "OUTPUT" ) ); diff --git a/plugins/waveshaper/waveshaper_control_dialog.cpp b/plugins/waveshaper/waveshaper_control_dialog.cpp index 5adb373de..b32b5b211 100644 --- a/plugins/waveshaper/waveshaper_control_dialog.cpp +++ b/plugins/waveshaper/waveshaper_control_dialog.cpp @@ -58,12 +58,16 @@ waveShaperControlDialog::waveShaperControlDialog( waveGraph -> setMaximumSize( 204, 205 ); knob * inputKnob = new knob( knobBright_26, this); + inputKnob -> setVolumeKnob( true ); + inputKnob -> setVolumeRatio( 1.0 ); inputKnob -> move( 14, 251 ); inputKnob->setModel( &_controls->m_inputModel ); inputKnob->setLabel( tr( "INPUT" ) ); inputKnob->setHintText( tr( "Input gain:" ) + " ", "" ); knob * outputKnob = new knob( knobBright_26, this ); + outputKnob -> setVolumeKnob( true ); + outputKnob -> setVolumeRatio( 1.0 ); outputKnob -> move( 54, 251 ); outputKnob->setModel( &_controls->m_outputModel ); outputKnob->setLabel( tr( "OUTPUT" ) ); diff --git a/src/gui/widgets/knob.cpp b/src/gui/widgets/knob.cpp index 074f32813..73f00d84a 100644 --- a/src/gui/widgets/knob.cpp +++ b/src/gui/widgets/knob.cpp @@ -61,6 +61,7 @@ knob::knob( int _knob_num, QWidget * _parent, const QString & _name ) : m_label( "" ), m_knobPixmap( NULL ), m_volumeKnob( false ), + m_volumeRatio( 100.0, 0.0, 1000000.0 ), m_buttonPressed( false ), m_angle( -10 ), m_outerColor( NULL ) @@ -668,7 +669,7 @@ QString knob::displayValue() const configManager::inst()->value( "app", "displaydbv" ).toInt() ) { return m_description.trimmed() + QString( " %1 dBV" ). - arg( 20.0 * log10( model()->value() / 100.0 ), + arg( 20.0 * log10( model()->value() / volumeRatio() ), 3, 'f', 2 ); } return m_description.trimmed() + QString( " %1" ).