16 #include "IntegerType.h"
17 #include "AudioOutput.h"
36 template<
typename T=AudioOutputStorage_t>
52 Ri = NUMERATOR / (hl-ll);
63 Ri = NUMERATOR / (hl-ll);
77 Ri = NUMERATOR / (hl-ll);
89 typename IntegerType<
sizeof(T)>::unsigned_type sub = in-hl;
96 typename IntegerType<
sizeof(T)>::unsigned_type q = ((
typename IntegerType<
sizeof(T)+
sizeof(T)>::unsigned_type) sub*Ri) >> SHIFT;
97 typename IntegerType<
sizeof(T)>::unsigned_type r = sub - q*R;
98 if (q&0b1)
return ll+r;
104 typename IntegerType<
sizeof(T)>::unsigned_type sub = ll-in;
105 typename IntegerType<
sizeof(T)>::unsigned_type q = ((
typename IntegerType<
sizeof(T)+
sizeof(T)>::unsigned_type) sub*Ri) >> SHIFT;
106 typename IntegerType<
sizeof(T)>::unsigned_type r = sub - q*R;
107 if (q&0b1)
return hl-r;
118 static const uint8_t SHIFT = (
sizeof(T) << 3);
119 static const typename IntegerType<
sizeof(T)>::unsigned_type NUMERATOR = ((
typename IntegerType<
sizeof(T)+
sizeof(T)>::unsigned_type) 1<<(SHIFT))-1;
void setHighLimit(T highLimit)
Set the high limit where the wave will start to be folded back the other way.
void setLowLimit(T lowLimit)
Set the low limit where the wave will start to be folded back the other way.
void setLimits(T lowLimit, T highLimit)
Set the low and the high limits at the same time.
T next(T in)
Return the next folded sample.
Provides appropriate integer types that can bit the given number of bytes on this platform (at most 6...