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)
273 template<int8_t NI, int8_t NF>
274 class Smooth<UFix<NI,NF>>
277 typedef UFix<NI, NF> internal_type;
278 internal_type last_out;
292 setSmoothness(smoothness);
309 internal_type next(internal_type in)
311 internal_type out = last_out + a * (in - last_out);
319 internal_type operator()(internal_type n) {
329 void setSmoothness(
float smoothness)
331 a=internal_type(1.f-smoothness);
340 void setSmoothness(UFix<0,_NF> smoothness)
342 a = UFix<1,0>(1) - smoothness;
351 template<int8_t NI, int8_t NF>
352 class Smooth<SFix<NI,NF>>
355 typedef SFix<NI, NF> internal_type;
356 internal_type last_out;
370 setSmoothness(smoothness);
387 internal_type next(internal_type in)
389 internal_type out = last_out + a * (in - last_out);
397 internal_type operator()(internal_type n) {
407 void setSmoothness(
float smoothness)
409 a=internal_type(1.f-smoothness);
418 void setSmoothness(UFix<0,_NF> smoothness)
420 a = UFix<1,0>(1) - smoothness;