MEAP The Library

MOZZI
MEAP The Class
C++ tips
Mozzi Reworks
mOscil
mSample
Generators
mDust
mNoise
mOperator
mSineLFO
mEnvSection
Effects
mBitcrusher
mChorus
mDigitalDelay
mFlanger
mPlateReverb
mSchroederReverb
DSP
mDelayLine
mFeedbackComb
mFeedforwardComb
mFIR
mIIR
mNaturalComb
mOnePoleLPF
mResonz
mRingz
mSchroederAllpass
mInstruments
mDrumRack
mFM4Instrument
mMarimbaInstrument
mPopInstrument
mRompler
mStringInstrument
mStringSynthInstrument
Composition
mMML
mTransitionTable
Utilities
mEventDelayMicros
mRandomDistribution

class: mDigitalDelay


delay effect

Description

Basic delay effect with control over delay time and feedback.

Template Parameters

template <class T = int32_t>

T: data type used internally in delay lines

Class Methods

Constructor

mDigitalDelay(float delay = 0, uint32_t max_delay = 4095, float feedback = 0.5, float mix = 0.5)

delay: delay time in samples

max_delay: maximum delay time in samples that you will want the delay line to have

feedback: feedback amount from output to input (0 to 1.0)

mix: dry/wet mix of effect (0 to 1.0)


void setDelay(float delay_samples)

Sets delay time in samples. Note that fractional samples are allowed. If you jump to a different delay time while audio is being played you will hear clicks. To avoid this, ramp between delay times using MOZZI’s smooth class or a similar approach.


int32_t setDelayMS(float ms)

Sets delay time in milliseconds

returns: the calculated delay time in samples


int32_t setDelaySixteenths(uint16_t num_sixteenths, uint16_t bpm)

Sets delay as a number of sixteenth notes at a specified tempo.

returns: the calculated delay time in samples


void setFeedback(float feedback)

feedback: feedback amount from output to input (0 to 1.0)


void setMix(float mix)

mix: dry/wet mix of effect (0 to 1.0)


void clear()

Clears any audio currently in delay line.


T next(T in_sample)

Send a sample of audio into the delay and return a sample back. Note that clipping can occur within the delay line if input is too loud, especially with high feedback.

Example

// global declaration
mDigitalDelay my_delay(16384, 32768, 0.5, 0.5) // half second delay time, one second maximum delay time

// in updateAudio
out_sample = my_delay.next(oscillator_output) // where oscillator_output is the output of some previous sound-generating object

Relevant Tutorials