JavaScript Web Synth From Scratch — Delay Module

We got ourselves a nice keyboard to play generated sounds in the previous chapter.
Now I think it is time to add a module infrastructure, where we can add different modules that can spice up our sound.
There are different types of it in the audio world: delays, distortions, low/high pass filters and we will implement the delay on this fabulous occasion.

Delay

Basic synth with delay diagram

The implementation is simple, we would save u the current state in a cyclic feedback array and return
u = u + gain^i * (u + feedback[abs(cyclicN-(i*time*sampleRate))])

Yoopti doo we got a delay, Check out the demo here.

Some words on the modules infrastructure

Have a look at the synth.js file.
We can subscribe a module to the synth and at lines 49–51 pass the wave through all modules.
Still very simplistic, it’s a start that suits our current needs.

Full source code is here, thank you very much for reading.
Comment, reach out, like, shout, clap, criticize, whatever you prefer.
I would be happy to.

I love music, climbing and I am a full stack web developer.