MCPcopy Create free account
hub / github.com/LabSound/LabSound / smooth

Method smooth

src/core/AudioParam.cpp:54–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54bool 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
83float AudioParam::finalValue(ContextRenderLock & r)
84{

Callers 4

processPolyBLEPMethod · 0.80
process_oscillatorMethod · 0.80

Calls 2

valueForContextTimeMethod · 0.80
contextMethod · 0.45

Tested by

no test coverage detected