comparison audioio/PlaySpeedRangeMapper.cpp @ 60:06b3c3f437e6

* Make audio dial remember its more accurate mapped value as well as its display position * Add tool tip support to audio dial to show values
author Chris Cannam
date Tue, 17 Oct 2006 13:04:49 +0000
parents 1016a8ceceda
children 050d764df239
comparison
equal deleted inserted replaced
59:1016a8ceceda 60:06b3c3f437e6
26 26
27 int 27 int
28 PlaySpeedRangeMapper::getPositionForValue(float value) const 28 PlaySpeedRangeMapper::getPositionForValue(float value) const
29 { 29 {
30 // value is percent 30 // value is percent
31 float factor = getFactorForValue(value);
32 int position = getPositionForFactor(factor);
33 return position;
34 }
31 35
32 float factor = getFactorForValue(value); 36 int
33 37 PlaySpeedRangeMapper::getPositionForFactor(float factor) const
38 {
34 bool slow = (factor > 1.0); 39 bool slow = (factor > 1.0);
35 40
36 if (!slow) factor = 1.0 / factor; 41 if (!slow) factor = 1.0 / factor;
37 42
38 int half = (m_maxpos + m_minpos) / 2; 43 int half = (m_maxpos + m_minpos) / 2;
53 58
54 float 59 float
55 PlaySpeedRangeMapper::getValueForPosition(int position) const 60 PlaySpeedRangeMapper::getValueForPosition(int position) const
56 { 61 {
57 float factor = getFactorForPosition(position); 62 float factor = getFactorForPosition(position);
63 float pc = getValueForFactor(factor);
64 return pc;
65 }
66
67 float
68 PlaySpeedRangeMapper::getValueForFactor(float factor) const
69 {
58 float pc; 70 float pc;
59 if (factor < 1.0) pc = ((1.0 / factor) - 1.0) * 100.0; 71 if (factor < 1.0) pc = ((1.0 / factor) - 1.0) * 100.0;
60 else pc = (1.0 - factor) * 100.0; 72 else pc = (1.0 - factor) * 100.0;
61 // std::cerr << "position = " << position << " percent = " << pc << std::endl; 73 // std::cerr << "position = " << position << " percent = " << pc << std::endl;
62 return pc; 74 return pc;