Some time ago, I began exploring the early reverb algorithms of Schroeder and Moorer, whose work dates back all the way to the 1960s and 70s respectively. Still their designs and theories inform the making of algorithmic reverbs today. Recently I took it upon myself to continue experimenting with the Moorer design I left off with in an earlier post. This resulted in the complete reverb plug-in “AdVerb”, which is available for free in downloads. Let me share what went into designing and implementing this effect.
One of the foremost challenges in basing a reverb design on Schroeder or Moorer is that it tends to sound a little metallic because with the number of comb filters suggested, the echo density doesn’t build up fast or dense enough. The all-pass filters in series that come after the comb filter section helps to diffuse the reverb tail, but I found that the delaying all-pass filters added a little metallic sound of their own. One obvious way of overcoming this is to add more comb filters (today’s computers can certainly handle it). More importantly, however, the delay times of the comb filters need to be mutually prime so that their frequency responses don’t overlap, which would result in increased beating in the reverb tail.
To arrive at my values for the 8 comb filters I’m using, I wrote a simple little script that calculated the greatest common divisor between all the delay times I chose and made sure that the results were 1. This required a little bit of tweaking in the numbers, as you can imagine finding 8 coprimes is not as easy as it sounds, especially when trying to keep the range minimal between them. It’s not as important for the two all-pass filters to be mutually prime because they are in series, not in parallel like the comb filters.
I also discovered, after a number of tests, that the tap delay used to generate the early reflections (based on Moorer’s design) was causing some problems in my sound. I’m still a bit unsure as to why, though it could be poorly chosen tap delay times or something to do with mixing, but it was enough so that I decided to discard the tap delay network and just focus on comb filters and all-pass filters. It was then that I took an idea from Dattorro and Frenette who both showed how the use of modulated comb/all-pass filters can help smear the echo density and add warmth to the reverb. Dattorro is responsible for the well-known plate reverbs that use modulating all-pass filters in series.
The idea behind a modulated delay line is that some oscillator (usually a low-frequency sine wave) modulates the delay value according to a frequency rate and amplitude. This is actually the basis for chorusing and flanging effects. In a reverb, however, the values need to be kept very small so that the chorusing effect will not be evident.
I had fun experimenting with these modulated delay lines, and so I eventually decided to modulate one of the all-pass filters as well and give control of it to the user, which offers a great deal more fun and crazy ways to use this plug-in. Let’s take a look at the modulated all-pass filter (the modulated comb filter is very similar). We already know what an all-pass filter looks like, so here’s just the modulated delay line:
The oscillator modulates the value currently in the delay line that we then use to interpolate, resulting in the actual value. In code it looks like this:
double offset, read_offset, fraction, next; size_t read_pos; offset = (delay_length / 2.) * (1. + sin(phase) * depth); phase += phase_incr; if (phase > TWO_PI) phase -= TWO_PI; if (offset > delay_length) offset = delay_length; read_offset = ((size_t)delay_buffer->p - (size_t)delay_buffer->p_head) / sizeof(double) - offset; if (read_offset delay_length) { read_offset = read_offset - delay_length; } read_pos = (size_t)read_offset; fraction = read_offset - read_pos; if (read_pos != delay_length - 1) { next = *(delay_buffer->p_head + read_pos + 1); } else { next = *delay_buffer->p_head; } return *(delay_buffer->p_head + read_pos) + fraction * (next - *(delay_buffer->p_head + read_pos));
In case that looks a little daunting, we’ll step through the C code (apologies for the pointer arithmetic!). At the top we calculate the offset using the delay length in samples as our base point. The following lines are easily seen as incrementing and wrapping the phase of the oscillator as well as capping the offset to the delay length.
The next line calculates the current position in the buffer from the current position pointer, p, and the buffer head, p_head. This is accomplished by casting the pointer addresses to integral values and dividing by the size of the data type of each buffer element. The read_offset position will determine where in the delay buffer we read from, so it needs to be clamped to the buffer’s length as well.
The rest is simply linear interpolation (albeit with some pointer arithmetic: delay_buffer->p_head + read_pos + 1 is equivalent to delay_buffer[read_pos + 1]). Once we have our modulated delay value, we can finish processing the all-pass filter:
delay_val = get_modulated_delay_value(allpass_filter); // don't write the modulated delay_val into the buffer, only use it for the output sample *delay_buffer->p = sample_in + (*delay_buffer->p * allpass_filter->g); sample_out = delay_val - (allpass_filter->g * sample_in);
The final topology of the reverb is given below:
The pre-delay is implemented by a simple delay line, and the low-pass filters are of the one-pole IIR variety. Putting the LPFs inside the comb filters’ feedback loops simulates the absorption of energy that sound undergoes as it comes in contact with surfaces and travels through air. This factor can be controlled with a damping parameter in the plug-in.
The one-pole moving-average filter is there for an extra bit of high frequency roll-off, and I chose it because this particular filter is an FIR type and has linear phase so it won’t add further disturbance to the modulated samples entering it. The last (normal) all-pass filter in the series serves to add extra diffusion to the reverb tail.
Here are some short sound samples using a selection of presets included in the plug-in:
Piano, “Medium Room” preset
The preceding sample demonstrates a normal reverb setting. Following are a few samples that demonstrate a couple of subtle and not-so-subtle effects:
Piano, “Make it Vintage” preset
Piano, “Bad Grammar” preset
Flute, “Shimmering Tail” preset
Feel free to get in touch regarding any questions or comments on “AdVerb“.