“What if we had, not one Wah Wah Filter, not two, but 20?”: Implementing an M-Fold Wah-Wah Filter in Matlab

Digital Audio Systems, DESC9115, 2020 Master of Interaction Design & Electronic Arts (Audio and Acoustics) Sydney School of Architecture, Design and Planning, The University of Sydney

ABSTRACT An M-fold Wah-Wah filter can be described as an effect where multiple Wah-Wah filters are applied to a signal, each at a certain frequency range. This report describes the implementation of such a filter in Matlab. By using preexisting code on a single state-variable bandpass filter, multiple bandpass filters are implemented across a defined frequency spectrum. The filter is adjustable through a number of variables, these being: the number of bandpass filters (M), the damping factor of each filter, the spectrum for which the filters are applied, as well as the Wah Frequency, i.e. the number of cycles through each bandpass.

1. INTRODUCTION The Wah-Wah filter is commonly used by guitarist to alter the shape and tone of the note(s) they are playing. The effect can be described as the combination of ‘u’ and ‘ah’ sounds created by human voice. The mouth’s shape here going from a small O to a big O. The center frequencies are called “formants”. The Wah-Wah pedal works in a similar manner, the formants shifts creating a “wah” sound.

The Wah-Wah filter is a time-varying line filter. Each filter has a set of unique characteristics such as the range of frequencies the effect is applied to and its Wah- Frequency, i.e. how fast the wah sound shifts. Often advanced guitarist tamper with these characteristics to create a Wah effect they’d prefer. Recently, advanced guitarists have experimented with two Wah pedals to achieve the effect at different ranges (Chapman, 2019) (Figure 1). What if guitarists were to use 5, 20, or even 100 Wah-Wah filters simultaneously? In analogue terms this would be difficult, as one Wah-Wah pedal, is the size of an average foot and using two requires a lot of space. In digital terms, this is achievable and is described by Zölzer (2011) as an M-fold Wah-Wah filter, where multiple filters are combined together.

{Figure 1 – Guitarists experimenting with two Analogue Wah-Wah Pedals}

1.1 Details of the Filter As mentioned, the Wah-Wah Filter is a time-varying delay line filter, i.e. implemented in the time domain. Zölzer (2011) describes three types of Wah-Wah filters: • A basic Wah-Wah, “variations can be derived by modifying its control”, this is the most popular form of the Wah-Wah effect, where the control is through a foot pedal; • an automatic Wah-Wah, where the control is periodic through a low frequency oscillator (LFO); • a sensitive Wah-Wah, where the control is adaptive, “based on the attack of each note”. For this assignment, I will be focusing on the auto Wah-Wah. The LFO being a triangular wave that will control the center frequencies.

The Wah-Wah effect is implemented using a bandpass filter with a small bandwidth, the center frequency being variable. To describe it lightly, a bandpass filter is implemented using a low pass filter combined with a high pass filter (Chamberlain, 1980). The response of this type of filter is presented in Figure 2. Chamberlain (1980), describes that by making the bandwidth filter very small, “only one harmonic will be emphasized by the narrow peak, and others will be greatly attenuated” and by varying the center frequency a distinct wah effect is created “as each harmonic is approached and passed by”.

{Figure 2 – Frequency response of bandpass filter}

Diagrammatically this is can be shown by mixing a signal that is passed through a bandpass with the unfiltered signal (Figure 3). Zölzer (2011) describes that by “replacing this unit delay in the bandpass filter by an M tap delay leads to the M-fold Wah-Wah filter” (Figure 4). The M-fold Wah-Wah filter sweeps the entire frequency range and simultaneously modulates the center frequency of each bandpass filter, as with a single wah-wah filter.

{Figure 3 – Wah Wah Filter with single time-varying bandpass filter}

{Figure 4 – M-fold Wah Wah Filter}

Figure 5 presents the effect of passing a white noise signal through an M-fold Wah-Wah on a spectrogram. It illustrates how the response is periodic.

{Figure 5 – Spectrogram of White noise signal passed through an M-fold Wah-Wah filter}

Zölzer (2011) mentions how M-fold Wah-Wah filters contain between 5-20 bandpass filters, where a low damping factor (Q) is required. A Bell effect may be achieved by implementing 100 bandpass filters. These parameter settings are presented in Table 1, Δf is the difference between the cut-off frequencies of the bandpass filters.

{Table 1 – Parameter settings for M-fold Wah Wah Filter}

2. LAB WORK 2.1 Bandpass Filter Function The first step in creating the M-fold Wah-Wah filter in Matlab was to build an Auto Wah-Wah filter, more specifically a variable bandpass filter where the centre frequency is controlled by an LFO. A code base online created by Marshall (n.d.) provided the basis for this implementation. The code reads a sound file (x) and sets the base parameters of the filter. This being the damping factor (damp), the cut-off frequency of the single bandpass filter (minf and maxf), as well as the wah frequency (Fw) of the overall filter.

damp = 0.01; minf = 500; maxf = 3000; Fw = 2000;

With these parameters set, the code then calculates Δf (delta), by dividing Fw and the sampling frequency (fs), and creates a triangle wave of centre frequencies (Fc). This is how the auto-wah effect is implemented, where Fc sweeps up and down the bandpass. The triangular wave is trimmed to fit the size of the input.

% change in centre frequency per sample (Hz) delta = Fw/fs;

% create triangle wave of centre frequency values Fc=minf:delta:maxf; while(length(Fc) < length(x) ) Fc= [ Fc (maxf:-delta:minf) ]; Fc= [ Fc (minf:delta:maxf) ]; end

% trim tri wave to size of input Fc = Fc(1:length(x));

Then by using the difference equation described in Chapter 2 of DAFX: Effects (Zölzer, 2011), the bandpass filter is implemented. This requires the coefficient of the difference equation to be recalculated each time Fc changes. A Q value is determined using the input parameter damp. A vector of zeros is created for the highpass (yh), bandpass (yb) and lowpass (yl) filters for the difference equations. The first sample of each filter is set to avoid negative referencing.

% difference equation coefficients % must be recalculated each time Fc changes F1 = 2*sin((pi*Fc(1))/fs); % this dictates size of the pass bands Q1 = 2*damp;

% create emptly out vectors yh=zeros(size(x)); yb=zeros(size(x)); yl=zeros(size(x));

% first sample, to avoid referencing of negative signals yh(1) = x(1); yb(1) = F1*yh(1); yl(1) = F1*yb(1);

The difference equation is finally applied to obtain the outputs yh, yb and yl across the whole input (x). On each loop they are recalculated when Fc changes.

% apply difference equation to the sample for n=2:length(x) yh(n) = x(n) - yl(n-1) - Q1*yb(n-1); yb(n) = F1*yh(n) + yb(n-1); yl(n) = F1*yb(n) + yl(n-1); F1 = 2*sin((pi*Fc(n))/fs); end

Finally, the output (yb) is normalised to give the final wah-wah effect.

%normalise maxyb = max(abs(yb)); yb = yb./maxyb;

The above code describes the implementation of a single bandpass filter. Aside from the parameter settings, it was used to create a bandpass filter function. This function is used to implement multiple bandpass filters. The function call looks as follows:

yb = bandpass(x, fs, damp, minf, maxf, Fw)

2.2 M-Fold Wah-Wah Filter Function Therefore, to implement the described M-fold Wah-Wah filter, a for loop was used to apply multiple bandpass filters across a defined frequency spectrum. An increment variable is derived by subtracting the low end (Fmin) from the high end (Fmax) and dividing this by the desired number of bandpass filters (M). The output (yb) is a vector that has M columns each defining the output of a single bandpass filter operation on the input.

% Increment value that is used on Fmin to deteremine low and high end % bandpass filter Finc = (Fmax-Fmin)/M;

for i = 1:M yb(:,i) = bandpass(x, fs, damp, Fmin, Fmin +Finc, Fw);

Fmin = Fmin + Finc; % Increment Fmin to next bandpass end

Finally, the signals are mixed together and normalised to provide the final output.

%Mix signals and normalise y_out = sum(yb,2); max_y_out = max(abs(y_out)); y_out = y_out./max_y_out;

The function call is as follows:

y_out = mFoldWahWah(x, fs, M, damp, Fmin, Fmax, Fw);

2.3 Output and Parameter Settings The function was first tested on a white noise signal to confirm it was operational. Figure 6, 7 and 8 below presents the spectrogram for a processed white noise signal with M = 5, 20 and 100, respectively. As seen, the filter does work showing multiple bandpass filters operating at their respective frequency ranges. With M = 100 the effect isn’t visible. This would be due to the high number of M and the really small bandwidth required. It can be deduced from the first two figures that M = 100 does work.

{Figure 6 – Spectrogram of processed white noise, M = 5}

{Figure 7 – Spectrogram of processed white noise, M = 20}

{Figure 8 – Spectrogram of processed white noise, M = 100}

The filter was then tested on an acoustic guitar sample. Figure 9 presents the unprocessed signal, while Figure 10 presents the processed signal with M = 20.

{Figure 9 – Spectrogram of unprocessed acoustic guitar sample}

{Figure 10 – Spectrogram of processed acoustic guitar sample, M = 20}

In terms of parameter settings: • For a high M, a very low damping factor is required. i.e. for M = 100, damp = 0.0001. For M = 20, damp = 0.001. For M = 5, damp = 0.01 (or higher). • Fmin and Fmax should ideally be kept very wide and cover the entire frequency spectrum. However, one can focus in on a specific range if they wish to. Nonetheless with a high M and small range, the effect is less audible. • Fw can be set to a low value but is best kept high for more audible effect. This is down to the discretion of the user.

3. DISCUSSION & CONCLUSION Overall, the filter works quite well. There are quite a few parameters that need to be tampered with to achieve a preferred effect, these being the number of bandpass filters (M), the damping factor (damp), the frequency spectrum (Fmin and Fmax) and the Wah Frequency (Fw). This allows the user to experiment a lot with how the filter may sound. Nonetheless it would take some time to really find the desired effect for the filter. The aesthetic of the sound is quite futuristic, which differs it from a conventional Wah-Wah. I would say it is akin to a synth rather than a guitar. To maintain the integrity of the guitar sound, it would be best to stay away from a really high number of M (50 or more). Over this covering the whole frequency spectrum will make the filter tamper with very high frequencies which may not be desirable. Nonetheless, the filter is quite versatile and after presenting it to my guitarist friend, he was quite intrigued by the effect and was excited to experiment with it.

4. REFERENCES

Chapman, R. (2019). How to Wah - Are two Wah pedals better than one? [Youtube Video]. Retrieved from: https://www.youtube.com/watch?v=iAlTn_8qfHw

Chamberlin, H. (1980). Musical applications of microprocessors . New Jersey, U.S.A: Hayden Book Co.

Marshall, D. (n.d.) Digital Audio Effects [Lecture Slides]. Cardiff Univerisity, Wales. Retrieved from: https://users.cs.cf.ac.uk/Dave.Marshall/CM0268/PDF/10_CM0268_Audio_FX.pdf

Zölzer, U. (Ed.). (2011). DAFX: digital audio effects. John Wiley & Sons.