# HG changeset patch # User Chris Cannam # Date 1427212965 0 # Node ID 76f4b81b766d7a3eabc3a133dc8279b774d2826a # Parent cfcdec32471224c857504f3dcbeaf6f7eb802d58 Try using audio level fader logic diff -r cfcdec324712 -r 76f4b81b766d widgets/LevelPanWidget.cpp --- a/widgets/LevelPanWidget.cpp Tue Mar 24 15:48:12 2015 +0000 +++ b/widgets/LevelPanWidget.cpp Tue Mar 24 16:02:45 2015 +0000 @@ -19,6 +19,7 @@ #include #include "layer/ColourMapper.h" +#include "base/AudioLevel.h" #include @@ -41,12 +42,20 @@ } void -LevelPanWidget::setLevel(float level) +LevelPanWidget::setLevel(float flevel) { - m_level = int(round(level * maxLevel)); - if (m_level < 0) m_level = 0; - if (m_level > maxLevel) m_level = maxLevel; - update(); + int level = AudioLevel::multiplier_to_fader + (flevel, maxLevel, AudioLevel::ShortFader); + if (level < 0) level = 0; + if (level > maxLevel) level = maxLevel; + if (level != m_level) { + m_level = level; + float convertsTo = getLevel(); + if (fabsf(convertsTo - flevel) > 1e-5) { + emitLevelChanged(); + } + update(); + } } void @@ -68,7 +77,8 @@ float LevelPanWidget::getLevel() const { - return float(m_level) / float(maxLevel); + return float(AudioLevel::fader_to_multiplier + (m_level, maxLevel, AudioLevel::ShortFader)); } float