Mozzi  version v1.1.0
sound synthesis library for Arduino

This is an example of how to use the AudioDelayFeedback class.

/* Example of flanging,
using Mozzi sonification library.
Demonstrates AudioDelayFeedback.
Circuit: Audio output on digital pin 9 on a Uno or similar, or
DAC/A14 on Teensy 3.1, or
check the README or
Mozzi documentation/API
Mozzi help/discussion/announcements:!forum/mozzi-users
Tim Barrass 2012-13, CC by-nc-sa.
#include <MozziGuts.h>
#include <Oscil.h>
#include <tables/triangle_analogue512_int8.h> // wavetable
#include <tables/triangle512_int8.h> // wavetable
#include <AudioDelayFeedback.h>
#include <mozzi_midi.h> // for mtof
#define CONTROL_RATE 128 // Hz, powers of 2 are most reliable
Oscil<TRIANGLE512_NUM_CELLS, CONTROL_RATE> kDelSamps(TRIANGLE512_DATA); // for modulating delay time, measured in audio samples
AudioDelayFeedback <128> aDel;
// the delay time, measured in samples, updated in updateControl, and used in updateAudio
byte del_samps;
void setup(){
kDelSamps.setFreq(.163f); // set the delay time modulation frequency (ie. the sweep frequency)
aDel.setFeedbackLevel(-111); // can be -128 to 127
Q16n16 deltime;
void updateControl(){
// delay time range from 0 to 127 samples, @ 16384 samps per sec = 0 to 7 milliseconds
//del_samps =;
// delay time range from 1 to 33 samples, @ 16384 samps per sec = 0 to 2 milliseconds
//del_samps =;
deltime = Q8n0_to_Q16n16(17) + ((long)<<12);
AudioOutput_t updateAudio(){
char asig =; // get this so it can be used twice without calling next() again
//return asig/8 +, (uint16_t) del_samps); // mix some straight signal with the delayed signal
//return, (uint16_t) del_samps); // instead of the previous 2 lines for only the delayed signal
return MonoOutput::fromAlmostNBit(9, (asig >> 3) +, deltime)); // mix some straight signal with the delayed signal
void loop(){