MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ apply_smoothing()

double MayaFlux::Nodes::Input::InputNode::apply_smoothing ( double  target,
double  current 
) const
private

Definition at line 108 of file InputNode.cpp.

109{
110 switch (m_config.smoothing) {
112 return target;
113
115 double diff = target - current;
116 return current + diff * m_config.smoothing_factor;
117 }
118
120 // y[n] = a * x[n] + (1-a) * y[n-1]
121 return m_config.smoothing_factor * target + (1.0 - m_config.smoothing_factor) * current;
122 }
123
124 case SmoothingMode::SLEW: {
125 double diff = target - current;
126 if (std::abs(diff) <= m_config.slew_rate) {
127 return target;
128 }
129 return current + (diff > 0 ? m_config.slew_rate : -m_config.slew_rate);
130 }
131
132 default:
133 return target;
134 }
135}
@ LINEAR
Linear interpolation between values.
@ NONE
No smoothing - immediate value changes (buttons)
@ EXPONENTIAL
Exponential smoothing / 1-pole lowpass (default)
double slew_rate
Max change per sample (SLEW mode)
Definition InputNode.hpp:82
double smoothing_factor
0-1, higher = faster response
Definition InputNode.hpp:81

References MayaFlux::Nodes::Input::EXPONENTIAL, MayaFlux::Nodes::Input::LINEAR, m_config, MayaFlux::Nodes::Input::NONE, MayaFlux::Nodes::Input::SLEW, MayaFlux::Nodes::Input::InputConfig::slew_rate, MayaFlux::Nodes::Input::InputConfig::smoothing, and MayaFlux::Nodes::Input::InputConfig::smoothing_factor.

Referenced by process_input(), and process_sample().

+ Here is the caller graph for this function: