You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AudioOutput.h
+8-1Lines changed: 8 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,7 @@
57
57
58
58
#ifndef AUDIOOUTPUT_H
59
59
#defineAUDIOOUTPUT_H
60
+
#include<FixMath.h>
60
61
61
62
/** The type used to store a single channel of a single frame, internally. For compatibility with earlier versions of Mozzi this is defined as int.
62
63
* If you do not care about keeping old sketches working, you may be able to save some RAM by using int16_t, instead (on boards where int is larger
@@ -134,8 +135,11 @@ struct MonoOutput {
134
135
/** Construct an audio frame from a zero-centered value known to be in the 8 bit range. On AVR, if MOZZI_OUTPUT_PWM mode, this is effectively the same as calling the
135
136
* constructor, directly (no scaling gets applied). On platforms/configs using more bits, an appropriate left-shift will be performed. */
/** Construct an audio frame a zero-centered value known to be in the 16 bit range. This is jsut a shortcut for fromNBit(16, ...) provided for convenience. */
138
+
/** Construct an audio frame from a zero-centered value known to be in the 16 bit range. This is jsut a shortcut for fromNBit(16, ...) provided for convenience. */
/** Construct an audio frame from a SFix type from FixMath. Mozzi will figure out how many bits are in there and performs appropriate shifting to match the output range. */
/** Construct an audio frame a zero-centered value known to be above at almost but not quite the N bit range, e.g. at N=8 bits and a litte. On most platforms, this is
140
144
* exactly the same as fromNBit(), shifting up or down to the platforms' available resolution.
141
145
*
@@ -179,6 +183,9 @@ template<typename T> static inline StereoOutput fromNBit(uint8_t bits, T l, T r)
@note This didn't run faster than float last time it was tested, after 2014 code changes. Need to see if 2014 changes improved or worsened performance.
217
217
@param frequency in UFix<NI,NF> fixed-point number format.
218
218
*/
219
-
template <int8_t NI, int8_t NF>
219
+
template <int8_t NI, int8_t NF, uint64_t RANGE>
220
220
inline
221
-
voidsetFreq(UFix<NI,NF> frequency)
221
+
voidsetFreq(UFix<NI,NF,RANGE> frequency)
222
222
{
223
-
setFreq_Q16n16(UFix<16,16>(frequency).asRaw());
223
+
setFreq_Q16n16(UFix<16,16>(frequency).asRaw());
224
224
}
225
225
226
226
@@ -256,8 +256,9 @@ class Oscil
256
256
less than 64 Hz.
257
257
@param frequency in UFix<24,8> fixed-point number format.
258
258
*/
259
+
template <uint64_t RANGE>
259
260
inline
260
-
voidsetFreq(UFix<24,8> frequency)
261
+
voidsetFreq(UFix<24,8,RANGE> frequency)
261
262
{
262
263
setFreq_Q24n8(frequency.asRaw());
263
264
}
@@ -295,8 +296,9 @@ class Oscil
295
296
@note This didn't run faster than float last time it was tested, after 2014 code changes. Need to see if 2014 changes improved or worsened performance.
296
297
@param frequency in UFix<16,16> fixed-point number format.
297
298
*/
299
+
template <uint64_t RANGE>
298
300
inline
299
-
voidsetFreq(UFix<16,16> frequency)
301
+
voidsetFreq(UFix<16,16,RANGE> frequency)
300
302
{
301
303
setFreq_Q16n16(frequency.asRaw());
302
304
}
@@ -309,9 +311,9 @@ class Oscil
309
311
@note This didn't run faster than float last time it was tested, after 2014 code changes. Need to see if 2014 changes improved or worsened performance.
310
312
@param frequency in SFix<16,16> fixed-point number format.
0 commit comments