FX INTRODUCTION / 11 / DRAFT
Delay: read past audio
Repeats remain after a note stops because earlier audio is played back.
This article is a work in progress. The examples will be refined through listening. Run starts playback; Stop ends it. Use Apply after editing values. Stop the playing iframe before trying another one.
Listen with the built-in FX
| Setting | Meaning |
|---|---|
| time | Delay time (seconds) |
| feedback | Proportion of delayed audio fed back |
| mix | Wet signal proportion |
Select none in FX Monitor to see the waveform after the built-in FX. This pass-through effect makes input and output overlap; it does not compare the signal before and after the built-in FX.
How the PCM is processed
A ring buffer is an array that wraps back to the start when writing reaches the end. Read delaySamples before the current position and mix it with the input. Writing the delayed signal back multiplied by feedback keeps the repeats going.
input[ch][i] is one input sample. ch identifies a left or right audio channel, not a physical FM voice. Store values carried between blocks in state. Since process cannot access outer variables, put settings in context.
Try it with liveFx
The 48000 in context.sampleRate is a placeholder. Match it to the actual output rate shown in FX Monitor. It is used to calculate times and frequencies; it does not change the browser's output sample rate.
This example uses resetState: true, so Apply clears stored audio and rebuilds the buffers, cutting off tails. Normally, a liveFx with the same name preserves state.
Open in a separate Playground tab ↗
Select delay-lab in FX Monitor to compare the input and output of this process.
- Set feedback to 0 to hear a single echo.
- Compare seconds at 0.125, 0.25, and 0.5.
- Set feedback to 0.6 for longer repeats.
Scope of this example
Changing the time instantly moves the read position and can cause clicks. A practical implementation also needs interpolation or crossfades. Tails continue after key-off, but Stop ends processing itself.
The waveform shows changes over time; Spectrum shows the strength of frequency components. A short display window or smoothing can hide some changes. Listen while changing one setting at a time.