46 #define AudioOutputStorage_t int 49 #define SCALE_AUDIO(x,bits) (bits > 8
? (x) >> (bits - 8
) : (x) << (8
- bits)) 50 #define SCALE_AUDIO_NEAR(x,bits) (bits > 9
? (x) >> (bits - 9
) : (x) << (9
- bits)) 51 #define CLIP_AUDIO(x) constrain((x), -244
,243
) 53 #define SCALE_AUDIO(x,bits) (bits > AUDIO_BITS ? (x) >> (bits - AUDIO_BITS) : (x) << (AUDIO_BITS - bits)) 54 #define SCALE_AUDIO_NEAR(x,bits) SCALE_AUDIO(x,bits) 59 #define AudioOutput StereoOutput 60 #if (STEREO_HACK == true) 61 #define AudioOutput_t void 63 #define AudioOutput_t StereoOutput 84 #define AudioOutput MonoOutput 98 inline AudioOutput_t portable()
const __attribute__((deprecated(
"Sketch generates stereo output, but Mozzi is configured for mono. Check mozzi_config.h."))) {
return _l; };
167 template<
typename A,
typename B>
static inline MonoOutput fromAlmostNBit(A bits, B l) {
return MonoOutput(
SCALE_AUDIO_NEAR(l, bits)); }
176 #if BYPASS_MOZZI_OUTPUT_BUFFER 178 inline bool canBufferAudioOutput();
186 inline uint32_t pdmCode8(uint16_t sample) {
188 static const byte fast_pdm_table[]{0, 0b00010000, 0b01000100,
189 0b10010010, 0b10101010, 0b10110101,
190 0b11011101, 0b11110111, 0b11111111};
192 static uint32_t lastwritten = 0;
193 static uint32_t nexttarget = 0;
199 nexttarget += sample;
200 nexttarget -= lastwritten;
201 lastwritten = nexttarget & 0b11110000000000000;
202 return fast_pdm_table[lastwritten >> 13];
206 inline uint32_t pdmCode32(uint16_t sample) {
207 uint32_t outbits = 0;
208 for (uint8_t i = 0; i < 4; ++i) {
209 outbits = outbits << 8;
210 outbits |= pdmCode8(sample);
216 #warning "Mozzi is configured to use an external void 'audioOutput(const AudioOutput f)' function. Please define one in your sketch" static MonoOutput from16Bit(int16_t l)
Construct an audio frame a zero-centered value known to be in the 16 bit range.
#define SCALE_AUDIO_NEAR(x, bits)
static StereoOutput fromNBit(uint8_t bits, T l, T r)
StereoOutput()
Default contstructor.
static MonoOutput from8Bit(int16_t l)
Construct an audio frame from a zero-centered value known to be in the 8 bit range.
#define AUDIO_MODE
AUDIO_MODE holds the audio mode setting.
#define AUDIO_CHANNELS
This sets allows to change from a single/mono audio output channel to stereo output.
This struct encapsulates one frame of mono audio output.
MonoOutput(AudioOutputStorage_t l=0)
Construct an audio frame from raw values (zero-centered)
static StereoOutput from8Bit(int16_t l, int16_t r)
AudioOutput_t portable() const __attribute__((deprecated("Sketch generates stereo output
Conversion to int operator: If used in a mono config, returns only the left channel (and gives a comp...
MonoOutput & clip()
Clip frame to supported range.
#define AudioOutput
Representation of an single audio output sample/frame.
#define SCALE_AUDIO(x, bits)
This struct encapsulates one frame of mono audio output.
static StereoOutput from16Bit(int16_t l, int16_t r)
operator AudioOutput_t() const
Conversion to int operator.
StereoOutput(AudioOutputStorage_t l, AudioOutputStorage_t r)
Construct an audio frame from raw values (zero-centered)
#define AudioOutput_t
Representation of an single audio output sample/frame.
#define STANDARD
Used to set AUDIO_MODE to STANDARD, STANDARD_PLUS, or HIFI.
#define EXTERNAL_AUDIO_OUTPUT
Defining this option as true in mozzi_config.h allows to completely customize the audio output...
static StereoOutput fromAlmostNBit(A bits, B l, B r)
static MonoOutput fromNBit(uint8_t bits, T l)
Construct an audio frame a zero-centered value known to be in the N bit range.
#define AudioOutputStorage_t
The type used to store a single channel of a single frame, internally.