Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/AutomatableModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,8 @@ class FloatModel : public AutomatableModel
AutomatableModel( Float, val, min, max, step, parent, displayName, defaultConstructed )
{
}

float getRoundedValue() const;
float getDigitCount();
defaultTypedMethods(float);

} ;
Expand Down
20 changes: 19 additions & 1 deletion src/core/AutomatableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,10 @@ float AutomatableModel::inverseScaledValue( float value ) const

QString AutomatableModel::displayValue( const float val ) const
{
const FloatModel *floatmodel = dynamic_cast<const FloatModel*>( this );
switch( m_dataType )
{
case Float: return QString::number( castValue<float>( scaledValue( val ) ) );
case Float: return QString::number( castValue<float>( scaledValue( floatmodel->getRoundedValue() ) ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is used to convert any value into a string, not just the current value. Reset and Paste value are now incorrect:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to look into it. Thank you for the hint!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is stupid. My intention was to fix the mixer bug ( 1.2345 % means 123,45 % ). I guess I revert this and search an other solution for this.

case Integer: return QString::number( castValue<int>( scaledValue( val ) ) );
case Bool: return QString::number( castValue<bool>( scaledValue( val ) ) );
}
Expand Down Expand Up @@ -713,6 +714,23 @@ float AutomatableModel::globalAutomationValueAt( const MidiTime& time )
}
}

float FloatModel::getRoundedValue() const
{
return static_cast<float>( static_cast<int>( value() / step<float>() + 0.5 ) ) * step<float>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is causing a problem in the tripleoscillator coarse detune knobs:
image
The negative values are off by one.
And when you set it to zero
image
The actual value is -1 as you fixed this to use the true value in #3437
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, got a fix for that. Is there an issue filed for? @Umcaruje

}




float FloatModel::getDigitCount()
{
float steptemp = step<float>();
int digits = 0;
while ( steptemp < 1 )
{
steptemp = steptemp / 0.1f;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

steptemp = steptemp * 10.0f; // easier to figure, and probably faster (but I guess the compiler already optimise it...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I added this in this PR #3597.

digits++;
}
return digits;
}

13 changes: 7 additions & 6 deletions src/gui/widgets/Fader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ void Fader::mouseMoveEvent( QMouseEvent *mouseEvent )

float delta = dy * ( model()->maxValue() - model()->minValue() ) / (float) ( height() - ( *m_knob ).height() );

model()->setValue( m_startValue + delta );
const float step = model()->step<float>();
float newValue = static_cast<float>( static_cast<int>( ( m_startValue + delta ) / step + 0.5 ) ) * step;
model()->setValue( newValue );

updateTextFloat();
}
Expand Down Expand Up @@ -215,27 +217,26 @@ void Fader::mouseDoubleClickEvent( QMouseEvent* mouseEvent )
{
bool ok;
float newValue;

// TODO: dbV handling
if( m_displayConversion )
{
newValue = QInputDialog::getDouble( this, windowTitle(),
tr( "Please enter a new value between %1 and %2:" ).
arg( model()->minValue() * 100 ).
arg( model()->maxValue() * 100 ),
model()->value() * 100,
model()->getRoundedValue() * 100,
model()->minValue() * 100,
model()->maxValue() * 100, 4, &ok ) * 0.01f;
model()->maxValue() * 100, model()->getDigitCount(), &ok ) * 0.01f;
}
else
{
newValue = QInputDialog::getDouble( this, windowTitle(),
tr( "Please enter a new value between %1 and %2:" ).
arg( model()->minValue() ).
arg( model()->maxValue() ),
model()->value(),
model()->getRoundedValue(),
model()->minValue(),
model()->maxValue(), 4, &ok );
model()->maxValue(), model()->getDigitCount(), &ok );
}

if( ok )
Expand Down
22 changes: 12 additions & 10 deletions src/gui/widgets/Knob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include "templates.h"
#include "TextFloat.h"


TextFloat * Knob::s_textFloat = NULL;


Expand Down Expand Up @@ -729,6 +728,7 @@ void Knob::setPosition( const QPoint & _p )
const float oldValue = model()->value();



if( model()->isScaleLogarithmic() ) // logarithmic code
{
const float pos = model()->minValue() < 0
Expand All @@ -738,7 +738,8 @@ void Knob::setPosition( const QPoint & _p )
float newValue = value * ratio;
if( qAbs( newValue ) >= step )
{
model()->setValue( oldValue - newValue );
float roundedValue = static_cast<float>( static_cast<int>( ( oldValue - newValue ) / step + 0.5 ) ) * step;
model()->setValue( roundedValue );
m_leftOver = 0.0f;
}
else
Expand All @@ -747,12 +748,12 @@ void Knob::setPosition( const QPoint & _p )
}
}


else // linear code
{
if( qAbs( value ) >= step )
{
model()->setValue( oldValue - value );
float roundedValue = static_cast<float>( static_cast<int>( ( oldValue - value ) / step + 0.5 ) ) * step;
model()->setValue( roundedValue );
m_leftOver = 0.0f;
}
else
Expand All @@ -769,15 +770,16 @@ void Knob::enterValue()
{
bool ok;
float new_val;

if( isVolumeKnob() &&
ConfigManager::inst()->value( "app", "displaydbfs" ).toInt() )
{
new_val = QInputDialog::getDouble(
this, windowTitle(),
tr( "Please enter a new value between "
"-96.0 dBFS and 6.0 dBFS:" ),
20.0 * log10( model()->value() / 100.0 ),
-96.0, 6.0, 4, &ok );
20.0 * log10( model()->getRoundedValue() / 100.0 ),
-96.0, 6.0, model()->getDigitCount(), &ok );
if( new_val <= -96.0 )
{
new_val = 0.0f;
Expand All @@ -795,9 +797,9 @@ void Knob::enterValue()
"%1 and %2:" ).
arg( model()->minValue() ).
arg( model()->maxValue() ),
model()->value(),
model()->getRoundedValue(),
model()->minValue(),
model()->maxValue(), 4, &ok );
model()->maxValue(), model()->getDigitCount(), &ok );
}

if( ok )
Expand Down Expand Up @@ -828,11 +830,11 @@ QString Knob::displayValue() const
ConfigManager::inst()->value( "app", "displaydbfs" ).toInt() )
{
return m_description.trimmed() + QString( " %1 dBFS" ).
arg( 20.0 * log10( model()->value() / volumeRatio() ),
arg( 20.0 * log10( model()->getRoundedValue() / volumeRatio() ),
3, 'f', 2 );
}
return m_description.trimmed() + QString( " %1" ).
arg( model()->value() ) + m_unit;
arg( model()->getRoundedValue() ) + m_unit;
}


Expand Down