Digital Audio Effects
Digital Audio Effects
Having learned to make basic sounds from basic waveforms and more advanced synthesis methods lets see how we can add some digital audio effects. These may be applied:
212
The order of applying the same effects can have drastic differences
in the output audio.
Selection of effects and the ordering is a matter for the sound you
wish to create. There is no absolute rule for the ordering.
Back Close
Effect Types Parameters Typical Guitar (and and other) Effects Pipeline
Some ordering is standard for some audio processing, E.g : all effect illustration below. You can use modules or selectively set certain Linking Effects Compression Distortion EQ Noisetogether Redux Amp Sim modules to on or off. Modulation Delay Reverb
The patches of the G1/G1X consist of eight serially linked effect modules, as shown in the
213
DRIVE
FD Clean VX Clean HW Clean US Blues BG Crunch
EQ
ZNR
ZNR
AMP
AMP Sim.
MODULATION
Chorus Ensemble Flanger Step Pitch Shift
DELAY
Delay Tape Echo Analog Delay Ping Pong Delay
REVERB
Hall Room Spring Arena Tiled Room
Effect types
* Manufacturer names and product names mentioned in this listing are trademarks or registered trademarks of their respective owners. The names are used only to illustrate sonic characteristics and do not indicate any afliation with ZOOM CORPORATION. For some effect modules, you can select an effect type from several possible choices. For example, the MODULATION module comprises Chorus, Flanger, and other effect types. The REVERB module comprises Hall, Room, and other effect types from which you can choose one.
Back Close
Classifying Effects
Audio effects can be classied by the way do their processing: Basic Filtering Lowpass, Highpass lter etc,, Equaliser: see CM2202 Notes
214
Time Varying Filters Wah-wah, Phaser Delays Vibrato, Flanger, Chorus, Echo Modulators Ring modulation, Tremolo, Vibrato Non-linear Processing Compression, Limiters, Distortion, Exciters/Enhancers Spacial Effects Panning, Reverb (see CM2202 Notes ), Surround Sound Some of the above studied here.3
See these notes for further information. This additional information may be useful for Coursework but is NOT examinable
3
Back Close
Time-varying Filters
Some common effects are realised by simply time varying a lter in a couple of different ways: Wah-wah A bandpass lter with a time varying centre (resonant) frequency and a small bandwidth. Filtered signal mixed with direct signal. Phasing A notch lter, that can be realised as set of cascading IIR lters, again mixed with direct signal.
215
Back Close
Wah-wah Example
The signal ow for a wah-wah is as follows:
direct-mix x(n) Time Varying
wah-mix
y (n)
216
BP
Back Close
+ T
+ T
218
1 Q1
T T
where:
= = = =
Back Close
F1 = 2 sin(fc/fs),
and Q1 = 2d
Back Close
BP filter with narrow pass band, Fc oscillates up and down the spectrum Difference equation taken from DAFX chapter 2 Changing this from a BP to a BR/BS (notch instead of a bandpass) converts this effect to a phaser yl(n) = F1*yb(n) + yl(n-1) yb(n) = F1*yh(n) + yb(n-1) yh(n) = x(n) - yl(n-1) - Q1*yb(n-1) vary Fc from 500 to 5000 Hz
%%%%%%% EFFECT COEFFICIENTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % damping factor % lower the damping factor the smaller the pass band damp = 0.05; % min and max centre cutoff frequency of variable bandpass filter minf=500; maxf=3000; % wah frequency, how many Hz per second are cycled through Fw = 2000; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
221
% 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));
Back Close
% 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; yh=zeros(size(x)); yb=zeros(size(x)); yl=zeros(size(x)); % first yh(1) = yb(1) = yl(1) = % create emptly out vectors
222
% 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 %normalise maxyb = max(abs(yb)); yb = yb/maxyb;
Back Close
% write output wav files wavwrite(yb, Fs, N, out_wah.wav); figure(1) hold on plot(x,r); plot(yb,b); title(Wah-wah and original Signal);
223
Back Close
224
10
15 x 10
4
Back Close
225
In a cave or large room we here an echo and also reverberation takes place this is a different effect see later If walls are closer together repeated reections can appear as parallel boundaries and we hear a modication of sound colour instead.
Back Close
226
Back Close
The delayed (processed) signal is added to the input signal some amplitude gain, g The difference equation is simply: y (n) = x(n) + gx(n M ) The transfer function is: H (z ) = 1 + gz M
with M = /fs
227
Back Close
x(n)
y (n)
228
TM
x(n M )
Back Close
rcomb.m:
x=zeros(100,1);x(1)=1; % unit impulse signal of length 100 g=0.5; %Example gain Delayline=zeros(10,1); % memory allocation for length 10 for n=1:length(x); y(n)=x(n)+g*Delayline(10); Delayline=[x(n);Delayline(1:10-1)]; end;
229
Back Close
Simulates endless reections at both ends of cylinder. We get an endless series of responses, y (n) to input, x(n). The input signal circulates in delay line (delay time ) that is fed
back to the input..
230
Each time it is fed back it is attenuated by g . Input sometime scaled by c to compensate for high amplication
of the structure.
y (n) = Cx(n) + gy (n M ) H (z ) =
with M = /fs
c 1 gz M
Back Close
x(n)
y (n)
231
TM
y (n M )
Back Close
iircomb.m:
x=zeros(100,1);x(1)=1; % unit impulse signal of length 100 g=0.5; Delayline=zeros(10,1); % memory allocation for length 10 for n=1:length(x); y(n)=x(n)+g*Delayline(10); Delayline=[y(n);Delayline(1:10-1)]; end;
232
Back Close
233
x(n)
TM
x(n M )
FF
y (n)
FB
234
Universal in that we can form any comb lter, an allpass or a delay: BL FB FF FIR Comb 1 0 g IIR Comb 1 g 0 Allpass a a 1 delay 0 0 1
Back Close
unicomb.m:
235
x=zeros(100,1);x(1)=1; % unit impulse signal of length 100 BL=0.5; FB=-0.5; FF=1; M=10; Delayline=zeros(M,1); % memory allocation for length 10 for n=1:length(x); xh=x(n)+FB*Delayline(M); y(n)=FF*Delayline(M)+BL*xh; Delayline=[xh;Delayline(1:M-1)]; end;
Back Close
If we vary the distance between and observer and a sound source Implementation: A Delay line and a low frequency oscillator (LFO) Only listen to the delay no forward or backward feed. Typical delay time = 510 Ms and LFO rate 514Hz.
236
Back Close
Back Close
for n=1:(LEN-1) M=MODFREQ; MOD=sin(M*2*pi*n); ZEIGER=1+DELAY+WIDTH*MOD; i=floor(ZEIGER); frac=ZEIGER-i; Delayline=[x(n);Delayline(1:L-1)]; %---Linear Interpolation----------------------------y(n,1)=Delayline(i+1)*frac+Delayline(i)*(1-frac); %---Allpass Interpolation-----------------------------%y(n,1)=(Delayline(i+1)+(1-frac)*Delayline(i)-(1-frac)*ya_alt); %ya_alt=ya(n,1); end
238
Back Close
0.2
239
0.1 0
!0.1
!0.2
!0.3
!0.4
50
100
150
200
250
300
350
400
450
500
Back Close
Flanging continuously varying LFO of delay, Chorus multiple copies of sound delayed by small random delays
Back Close
% to avoid referencing of negative samples y(1:max_samp_delay)=x(1:max_samp_delay); % set amp suggested coefficient from page 71 DAFX amp=0.7; % for each sample for i = (max_samp_delay+1):length(x), cur_sin=abs(sin_ref(i)); %abs of current sin val 0-1 % generate delay from 1-max_samp_delay and ensure whole number cur_delay=ceil(cur_sin*max_samp_delay); % add delayed sample y(i) = (amp*x(i)) + amp*(x(i-cur_delay)); end % write output wavwrite(y,Fs,outfile);
242
Back Close
243
0.5
!0.5
!1
!1.5 0
10
15 x 10
4
Back Close
Modulation
Modulation is the process where parameters of a sinusoidal signal (amplitude, frequency and phase) are modied or varied by an audio signal. We have met some example effects s that could be considered as a class of modulation already: Amplitude Modulation Wah-wah, Phaser Frequency Modulation Audio synthesis technique (Already Studied) Phase Modulation Vibrato, Chorus, Flanger We will now introduce some Modulation effects.
244
Back Close
Ring Modulation
Ring modulation (RM) is where the audio modulator signal, x(n) is multiplied by a sine wave, m(n), with a carrier frequency, fc .
This is very simple to implement digitally: y (n) = x(n).m(n) Although audible result is easy to comprehend for simple signals
245
If the modulator is also a sine wave with frequency, fx then one hears the sum and difference frequencies: fc + fx and fc fx , for
example.
When the input is periodic with at a fundamental frequency, f0, then a spectrum with amplitude lines at frequencies |kf0 fc | Used to create robotic speech effects on old sci- movies and can
create some odd almost non-musical effects if not used with care. (Original speech )
Back Close
Back Close
247
50
100
150
200
250
Back Close
Amplitude Modulation
Amplitude Modulation (AM) is dened by:
y (n) = (1 + m(n)).x(n) Normalise the peak amplitude of M(n) to 1. is depth of modulation = 1 gives maximum modulation = 0 tuns off modulation
248
When x(n) and m(n) both sine waves with frequencies fc and fx respectively we here three frequencies: carrier, difference and sum: fc , fc fx , fc + fx .
Back Close
249
Back Close
250
Non-linear Processing
Non-linear Processors are characterised by the fact that they create (intentional or unintentional) harmonic and inharmonic frequency components not present in the original signal. Three major categories of non-linear processing: Dynamic Processing: control of signal envelop aim to minimise harmonic distortion Examples: Compressors, Limiters Intentional non-linear harmonic processing: Aim to introduce strong harmonic distortion. Examples: Many electric guitar effects such as distortion Exciters/Enhancers: add additional harmonics for subtle sound improvement.
Back Close 251
Back Close
Overdrive
For overdrive, Symmetrical soft clipping of input values has to be performed. A simple three layer non-linear soft saturation scheme may be: for 0 x < 1/3 2x 2 3x) f (x) = 3(2 for 1/3 x < 2/3 3 1 for 2/3 x 1
253
In the middle third there is a non-linear (quadratic) output Above 2/3 the output is set to 1.
Back Close
254
Back Close
255
% read the sample waveform filename=acoustic.wav; [x,Fs,bits] = wavread(filename); % call symmetrical soft clipping % function y = symclip(x); % write output wavwrite(y,Fs,bits,... out_overdrive.wav); figure(1); hold on plot(y,r); plot(x,b); title(Overdriven Signal);
10
15 x 10
4
Back Close
Distortion/Fuzz
A non-linear function commonly used to simulate distortion/fuzz is given by:
x 2 (1 ex /|x|) f ( x) = |x|
256
Back Close
function y=fuzzexp(x, gain, mix) % y=fuzzexp(x, gain, mix) % Distortion based on an exponential function % x - input % gain - amount of distortion, >0-> % mix - mix of original and distorted sound, 1=only distorted q=x*gain/max(abs(x)); z=sign(-q).*(1-exp(sign(-q).*q)); y=mix*z*max(abs(x))/max(abs(z))+(1-mix)*x; y=y*max(abs(x))/max(abs(y));
filename=acoustic.wav; % read the sample waveform [x,Fs,bits] = wavread(filename); % Call fuzzexp gain = 11; % Spinal Tap it mix = 1; % Hear only fuzz y = fuzzexp(x,gain,mix); % write output wavwrite(y,Fs,bits,out_fuzz.wav);
10
15 x 10
4
Back Close