Audio delay line with feedback for comb filter, flange, chorus and short echo effects.
More...
#include <AudioDelayFeedback.h>
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
class AudioDelayFeedback< NUM_BUFFER_SAMPLES, INTERP_TYPE >
Audio delay line with feedback for comb filter, flange, chorus and short echo effects.
- Template Parameters
-
NUM_BUFFER_SAMPLES | is the length of the delay buffer in samples, and should be a power of two. The maximum delay length which will fit in an atmega328 is half that of a plain AudioDelay object, in this case 256 cells, or about 15 milliseconds. AudioDelayFeedback uses int16_t sized cells to accomodate the higher amplitude of direct input to the delay as well as the feedback, without losing precision. Output is only the delay line signal. If you want to mix the delay with the input, do it in your sketch. AudioDelayFeedback uses more processing and memory than a plain AudioDelay, but allows for more dramatic effects with feedback. |
INTERP_TYPE | a choice of LINEAR (default) or ALLPASS interpolation. LINEAR is better for sweeping delay times, ALLPASS may be better for reverb-like effects. |
Definition at line 36 of file AudioDelayFeedback.h.
|
| AudioDelayFeedback () |
| Constructor.
|
|
| AudioDelayFeedback (uint16_t delaytime_cells) |
| Constructor. More...
|
|
| AudioDelayFeedback (uint16_t delaytime_cells, int8_t feedback_level) |
| Constructor. More...
|
|
int16_t | next (int8_t input) |
| Input a value to the delay and retrieve the signal in the delay line at the position delaytime_cells. More...
|
|
int16_t | next (int8_t input, uint16_t delaytime_cells) |
| Input a value to the delay, retrieve the signal in the delay line at the position delaytime_cells, and add feedback from the output to the input. More...
|
|
int16_t | next (int8_t input, Q16n16 delaytime_cells) |
| Input a value to the delay, retrieve the signal in the delay line at the interpolated fractional position delaytime_cells, and add feedback from the output to the input. More...
|
|
void | write (int8_t input) |
| Input a value to the delay but don't change the delay time or retrieve the output signal. More...
|
|
void | writeFeedback (int8_t input) |
| Input a value to the delay but don't advance the write position, change the delay time or retrieve the output signal. More...
|
|
void | write (int8_t input, uint16_t offset) |
| Input a value to the delay at an offset from the current write position. More...
|
|
int16_t | read (Q16n16 delaytime_cells) |
| Retrieve the signal in the delay line at the interpolated fractional position delaytime_cells. More...
|
|
int16_t | read () |
| Retrieve the signal in the delay line at the current stored delaytime_cells. More...
|
|
void | setDelayTimeCells (uint16_t delaytime_cells) |
| Set delay time expressed in samples. More...
|
|
void | setDelayTimeCells (Q16n16 delaytime_cells) |
| Set delay time expressed in samples, fractional Q16n16 for an interpolating delay. More...
|
|
void | setDelayTimeCells (float delaytime_cells) |
| Set delay time expressed in samples, fractional float for an interpolating delay. More...
|
|
void | setFeedbackLevel (int8_t feedback_level) |
| Set the feedback gain. More...
|
|
◆ AudioDelayFeedback() [1/2]
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
Constructor.
- Parameters
-
delaytime_cells | delay time expressed in cells. For example, 128 cells delay at MOZZI_AUDIO_RATE 16384 would produce a time delay of 128/16384 = 0.0078125 s = 7.8 ms Put another way, num_cells = delay_seconds * MOZZI_AUDIO_RATE. |
Definition at line 51 of file AudioDelayFeedback.h.
◆ AudioDelayFeedback() [2/2]
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
Constructor.
- Parameters
-
delaytime_cells | delay time expressed in cells. For example, 128 cells delay at MOZZI_AUDIO_RATE 16384 would produce a time delay of 128/16384 = 0.0078125 s = 7.8 ms Put another way, num_cells = delay_seconds * MOZZI_AUDIO_RATE. |
feedback_level | is the feedback level from -128 to 127 (representing -1 to 1). |
Definition at line 61 of file AudioDelayFeedback.h.
◆ next() [1/3]
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
◆ next() [2/3]
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
Input a value to the delay, retrieve the signal in the delay line at the interpolated fractional position delaytime_cells, and add feedback from the output to the input.
- Parameters
-
input | the signal input. |
delaytime_cells | is a fractional number to set the delay time in terms of cells or partial cells in the delay buffer. It doesn't change the stored internal value of _delaytime_cells. |
Definition at line 113 of file AudioDelayFeedback.h.
◆ next() [3/3]
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
int16_t AudioDelayFeedback< NUM_BUFFER_SAMPLES, INTERP_TYPE >::next |
( |
int8_t |
input, |
|
|
uint16_t |
delaytime_cells |
|
) |
| |
|
inline |
Input a value to the delay, retrieve the signal in the delay line at the position delaytime_cells, and add feedback from the output to the input.
- Parameters
-
input | the signal input. |
delaytime_cells | indicates the delay time in terms of cells in the delay buffer. It doesn't change the stored internal value of _delaytime_cells. |
- Note
- Timing: 4us
Definition at line 88 of file AudioDelayFeedback.h.
◆ read() [1/2]
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
Retrieve the signal in the delay line at the current stored delaytime_cells.
It doesn't change the stored internal value of _delaytime_cells or feedback the output to the input.
Definition at line 192 of file AudioDelayFeedback.h.
◆ read() [2/2]
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
Retrieve the signal in the delay line at the interpolated fractional position delaytime_cells.
It doesn't change the stored internal value of _delaytime_cells or feedback the output to the input.
- Parameters
-
delaytime_cells | indicates the delay time in terms of cells in the delay buffer. |
Definition at line 182 of file AudioDelayFeedback.h.
◆ setDelayTimeCells() [1/3]
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
void AudioDelayFeedback< NUM_BUFFER_SAMPLES, INTERP_TYPE >::setDelayTimeCells |
( |
float |
delaytime_cells | ) |
|
|
inline |
Set delay time expressed in samples, fractional float for an interpolating delay.
- Parameters
-
delaytime_cells | delay time expressed in cells, with each cell played per tick of MOZZI_AUDIO_RATE. For example, 128 cells delay at MOZZI_AUDIO_RATE would produce a time delay of 128/16384 = 0.0078125 s = 7.8 ms Put another way, num_cells = delay_seconds * MOZZI_AUDIO_RATE. |
Definition at line 228 of file AudioDelayFeedback.h.
◆ setDelayTimeCells() [2/3]
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
Set delay time expressed in samples, fractional Q16n16 for an interpolating delay.
- Parameters
-
delaytime_cells | delay time expressed in cells, with each cell played per tick of MOZZI_AUDIO_RATE. For example, 128 cells delay at MOZZI_AUDIO_RATE would produce a time delay of 128/16384 = 0.0078125 s = 7.8 ms Put another way, num_cells = delay_seconds * MOZZI_AUDIO_RATE. |
Definition at line 216 of file AudioDelayFeedback.h.
◆ setDelayTimeCells() [3/3]
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
void AudioDelayFeedback< NUM_BUFFER_SAMPLES, INTERP_TYPE >::setDelayTimeCells |
( |
uint16_t |
delaytime_cells | ) |
|
|
inline |
Set delay time expressed in samples.
- Parameters
-
delaytime_cells | delay time expressed in cells, with each cell played per tick of MOZZI_AUDIO_RATE. For example, 128 cells delay at MOZZI_AUDIO_RATE would produce a time delay of 128/16384 = 0.0078125 s = 7.8 ms Put another way, num_cells = delay_seconds * MOZZI_AUDIO_RATE. |
Definition at line 204 of file AudioDelayFeedback.h.
◆ setFeedbackLevel()
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
void AudioDelayFeedback< NUM_BUFFER_SAMPLES, INTERP_TYPE >::setFeedbackLevel |
( |
int8_t |
feedback_level | ) |
|
|
inline |
Set the feedback gain.
- Parameters
-
feedback_level | is the feedback level from -128 to 127 (representing -1 to 1). |
Definition at line 238 of file AudioDelayFeedback.h.
◆ write() [1/2]
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
Input a value to the delay but don't change the delay time or retrieve the output signal.
- Parameters
-
Definition at line 146 of file AudioDelayFeedback.h.
◆ write() [2/2]
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
void AudioDelayFeedback< NUM_BUFFER_SAMPLES, INTERP_TYPE >::write |
( |
int8_t |
input, |
|
|
uint16_t |
offset |
|
) |
| |
|
inline |
Input a value to the delay at an offset from the current write position.
Don't advance the main write position or change the stored delay time or retrieve the output signal.
- Parameters
-
input | the signal input. |
offset | the number of cells behind the ordinary write position where the input will be written. |
Definition at line 170 of file AudioDelayFeedback.h.
◆ writeFeedback()
template<uint16_t NUM_BUFFER_SAMPLES, int8_t INTERP_TYPE = LINEAR>
Input a value to the delay but don't advance the write position, change the delay time or retrieve the output signal.
This can be useful for manually adding feedback to the delay line, "behind" the advancing write head.
- Parameters
-
Definition at line 158 of file AudioDelayFeedback.h.