| 52 | } |
| 53 | |
| 54 | bool AudioParam::smooth(ContextRenderLock & r) |
| 55 | { |
| 56 | // If values have been explicitly scheduled on the timeline, then use the exact value. |
| 57 | // Smoothing effectively is performed by the timeline. |
| 58 | bool useTimelineValue = false; |
| 59 | if (r.context()) |
| 60 | m_value = m_timeline.valueForContextTime(r, static_cast<float>(m_value), useTimelineValue); |
| 61 | |
| 62 | if (m_smoothedValue == m_value) |
| 63 | { |
| 64 | // Smoothed value has already approached and snapped to value. |
| 65 | return true; |
| 66 | } |
| 67 | |
| 68 | if (useTimelineValue) |
| 69 | m_smoothedValue = m_value; |
| 70 | else |
| 71 | { |
| 72 | // Dezipper - exponential approach. |
| 73 | m_smoothedValue += (m_value - m_smoothedValue) * m_smoothingConstant; |
| 74 | |
| 75 | // If we get close enough then snap to actual value. |
| 76 | if (fabs(m_smoothedValue - m_value) < SnapThreshold) // @fixme: the threshold needs to be adjustable depending on range - but this is OK general purpose value. |
| 77 | m_smoothedValue = m_value; |
| 78 | } |
| 79 | |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | float AudioParam::finalValue(ContextRenderLock & r) |
| 84 | { |
no test coverage detected