68 long out = ((((((
long)in - (last_out>>8)) * a))>>8) + last_out);
102 class Smooth <uint8_t>
105 unsigned int last_out;
114 Smooth(
float smoothness)
116 setSmoothness(smoothness);
124 uint8_t next(uint8_t in)
126 unsigned int out = (((((
int)in - (last_out>>8)) * a)) + last_out);
128 return (uint8_t)(out>>8);
137 uint8_t operator()(uint8_t n) {
148 void setSmoothness(
float smoothness)
150 a=float_to_Q0n8(1.f-smoothness);
158 class Smooth <int8_t>
170 Smooth(
float smoothness)
172 setSmoothness(smoothness);
181 int8_t next(int8_t in)
183 int out = (((((
int)in - (last_out>>8)) * a)) + last_out);
185 return (int8_t)(out>>8);
194 int8_t operator()(int8_t n) {
205 void setSmoothness(
float smoothness)
207 a=float_to_Q0n8(1.f-smoothness);
226 Smooth(
float smoothness)
228 setSmoothness(smoothness);
238 float out = last_out + a * (in - last_out);
250 float operator()(
float n) {
261 void setSmoothness(
float smoothness)
void setSmoothness(float smoothness)
Sets how much smoothing the filter will apply to its input.
Smooth(float smoothness)
Constructor.
uint16_t Q0n16
unsigned fractional number using 16 fractional bits, represents 0.0 to 0.999
A simple infinite impulse response low pass filter for smoothing control or audio signals...
T operator()(T n)
Filters the input and returns the filtered value.
Q0n16 float_to_Q0n16(float a)
Convert float to Q0n16 fix.
T next(T in)
Filters the input and returns the filtered value.