Mercurial > hg > svgui
comparison widgets/LevelPanWidget.cpp @ 925:76f4b81b766d tonioni
Try using audio level fader logic
author | Chris Cannam |
---|---|
date | Tue, 24 Mar 2015 16:02:45 +0000 |
parents | cfcdec324712 |
children | bfeabe25a1a3 |
comparison
equal
deleted
inserted
replaced
924:cfcdec324712 | 925:76f4b81b766d |
---|---|
17 #include <QPainter> | 17 #include <QPainter> |
18 #include <QMouseEvent> | 18 #include <QMouseEvent> |
19 #include <QWheelEvent> | 19 #include <QWheelEvent> |
20 | 20 |
21 #include "layer/ColourMapper.h" | 21 #include "layer/ColourMapper.h" |
22 #include "base/AudioLevel.h" | |
22 | 23 |
23 #include <iostream> | 24 #include <iostream> |
24 | 25 |
25 using std::cerr; | 26 using std::cerr; |
26 using std::endl; | 27 using std::endl; |
39 LevelPanWidget::~LevelPanWidget() | 40 LevelPanWidget::~LevelPanWidget() |
40 { | 41 { |
41 } | 42 } |
42 | 43 |
43 void | 44 void |
44 LevelPanWidget::setLevel(float level) | 45 LevelPanWidget::setLevel(float flevel) |
45 { | 46 { |
46 m_level = int(round(level * maxLevel)); | 47 int level = AudioLevel::multiplier_to_fader |
47 if (m_level < 0) m_level = 0; | 48 (flevel, maxLevel, AudioLevel::ShortFader); |
48 if (m_level > maxLevel) m_level = maxLevel; | 49 if (level < 0) level = 0; |
49 update(); | 50 if (level > maxLevel) level = maxLevel; |
51 if (level != m_level) { | |
52 m_level = level; | |
53 float convertsTo = getLevel(); | |
54 if (fabsf(convertsTo - flevel) > 1e-5) { | |
55 emitLevelChanged(); | |
56 } | |
57 update(); | |
58 } | |
50 } | 59 } |
51 | 60 |
52 void | 61 void |
53 LevelPanWidget::setPan(float pan) | 62 LevelPanWidget::setPan(float pan) |
54 { | 63 { |
66 } | 75 } |
67 | 76 |
68 float | 77 float |
69 LevelPanWidget::getLevel() const | 78 LevelPanWidget::getLevel() const |
70 { | 79 { |
71 return float(m_level) / float(maxLevel); | 80 return float(AudioLevel::fader_to_multiplier |
81 (m_level, maxLevel, AudioLevel::ShortFader)); | |
72 } | 82 } |
73 | 83 |
74 float | 84 float |
75 LevelPanWidget::getPan() const | 85 LevelPanWidget::getPan() const |
76 { | 86 { |