Having learned to make basic sounds from basic waveforms and more advanced synthesis methods lets see how we can at some digital audio effects. Chapter 7 provides knowledge of digital audio effects.
Trang 1CM3106 Chapter 7: Digital Audio Effects
Prof David Marshall
dave.marshall@cs.cardiff.ac.uk
and
Dr Kirill Sidorov
K.Sidorov@cs.cf.ac.ukwww.facebook.com/kirill.sidorov
School of Computer Science & Informatics
Cardiff University, UK
Trang 2Digital Audio Effects
Having learned to make basic sounds from basic waveforms
and more advanced synthesis methods lets see how we can atsome digital audio effects
These may be applied:
As part of the audio creation/synthesis stage — to be
subsequently filtered, (re)synthesised
At the end of the audio chain— as part of the
production/mastering phase
Effects can be applied in different orders and sometimes
in a parallel audio chain
The order of applying the same effects can have drasticdifferences in the output audio
Selection of effects and the ordering is a matter for thesound you wish to create There is no absolute rule for
the ordering
Trang 3FX Pipeline
Apply effects in which order?
Some ordering is standard for some audio processing, E.g:
Can also be configurable.
Common for order guitar (and other sources) effects pedal:
Delay Tape Echo Analog Delay Ping Pong Delay
AMP Sim.
Ensemble Flanger Step Pitch Shift
COMP/EFX DRIVE EQ ZNR AMP MODULATION DELAY REVERB
Effect modules
Effect types
Effect Types and Parameters
Linking Effects
The patches of the G1/G1X consist of eight
serially linked effect modules, as shown in the
illustration below You can use all effect modules together or selectively set certain modules to on or off
Explanation of symbols
●Module selector
The Module selector symbol shows the position of the knob at which this module/parameter is called up.
● Expression pedal
A p e d a l i c o n i n t h e l i s t i n g indicates a parameter that can be controlled with the built-in or an external expression pedal
When this item is selected, the parameter in the
module can then be controlled in real time with a
connected expression pedal
A [TAP] icon in the listing indicates a parameter that can be set with the [BANK UP•TAP]
TAP
* 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 affiliation 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.
Effect Types and Parameters
Determines the overall volume level of the patch.
Sets the patch level in the range from 2 – 98, 1.0 A setting of 80 corresponds to unity gain (input level and output level are equal).
This module comprises the effects that control the level dynamics such as compressor, and modulation effects such as tremolo and phaser.
Ring Mod (Ring Modulator)
This effect produces a metallic ringing sound Higher setting values result in higher modulation frequency.
Clean sound of the combo amp VOX
Trang 4Effects Types
Audio effects can be classified by the way process signals:
Basic Filtering: Lowpass, Highpass filter etc.,
Equaliser
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, Surround Sound
Trang 5Basic Digital Audio Filtering Effects:
Equalisers
Filtering:
Filtersby definition remove/attenuate audio from the
spectrum above or below some cut-off frequency
For many audio applications this a little too restrictive
Equalisation:
Equalisers, by contrast, enhance/diminishcertain frequencybands whilst leaving othersunchanged:
Built using a series of shelvingand peak filters
First or second-order filters usually employed
Trang 6Shelving and Peak Filters
Shelving Filter:
Boost or cut the low or high frequency bands with a
cut-off frequency, Fc and gainG:
Trang 7Shelving and Peak Filters (Cont.)
Peak Filter:
Boost or cut mid-frequencybands with a cut-off
frequency,Fc, a bandwidth,fb and gain G:
Trang 9Shelving Filters (Cont.)
Shelving Filter Parameters:
Thegain, G, in dB can be adjusted accordingly:
Trang 10Shelving Filters Signal Flow Graph
1
CM3106 Chapter 6: MIDI Equalisation 10
Trang 12Peak Filters (Cont.)
Peak Filter Parameters:
The center/cut-off frequency , d , is given by:
Trang 13Peak Filters Signal Flow Graph
Trang 14Shelving Filter EQ MATLAB Example (1)
shelving.m
function [b, a] = shelving (G, fc, fs, Q, type)
%
% Derive coefficients for a shelving filter with a given amplitude
% and cutoff frequency All coefficients are calculated as
% described in Zolzer’s DAFX book (p 50 -55).
%
% Usage: [B,A] = shelving(G, Fc, Fs, Q, type);
%
% G is the logrithmic gain (in dB)
% FC is the center frequency
% Fs is the sampling rate
% Q adjusts the slope be replacing the sqrt(2) term
% type is a character string defining filter type
% Choices are: ’Base_Shelf’ or ’Treble_Shelf’
Trang 15Shelving Filter EQ MATLAB Example (2)
Trang 16Shelving Filter EQ MATLAB Example (3)
Trang 17Shelving Filter EQ MATLAB Example (3)
Trang 18Shelving Filter EQ MATLAB Example (4)
Trang 19Shelving Filter EQ MATLAB Example (5)
Example use: shelving eg.m
infile = ’acoustic.wav’ ;
[ x, Fs, N ] = wavread(infile); % read in wav sample
% Set parameters for Shelving Filter
% Change these to experiment with filter
% Plot the original and equalised waveforms
figure( 1 ), hold on;
plot(yb, ’b’ );
plot(x, ’r’ );
title( ’Bass Shelf Filter Equalised Signal’ );
Trang 20Shelving Filter EQ MATLAB Example (6)
shelving eg.m cont.
% Do treble shelf filter
Trang 21Shelving Filter EQ MATLAB Example Output
The output from the above code is (red plot is original audio):
0 5 10 15
x 10 4
−1
−0.5 0 0.5 1
Original Audio
Click on above images or here to hear: original audio,
bass shelf filtered audio,treble shelf filtered audio
Trang 22Time-varying Filters
Time-varying Filter Effects
Some common effects are realised by simply time varying a
filter in a couple of different ways:
Wah-wah: A bandpass filter with a (modulated) time
varying centre (resonant) frequency and a smallbandwidth Filtered signal mixed with directsignal
Phasing: A notch filter, that can be realised as set of
cascading IIR filters, again mixed with directsignal
Trang 23Wah-wah Example
Wah-wah, Signal flow diagram:
y(n)+
×
×BP
direct-mix
wah-mix Time
Varying x(n)
whereBPis a time-varying frequency bandpass filter
Wah-wah Variations
Aphaseris similarly implemented with a notch filter
replacingthebandpass filter
A variation is theM-fold wah-wah filter where M tap delaybandpass filters spread over the entire spectrum change theircentre frequencies simultaneously
Abell effectcan be achieved with around a hundredM
CM3106 Chapter 6: MIDI Time-varying Filters 23
Trang 24Time Varying Filter Implementation:
State Variable Filter
The Practical State Variable Filter
In time varying filters we now wantindependent control overthe cut-off frequencyand damping factor of a filter
(Borrowed from analog electronics) We can implement a
State Variable Filter to solve this problem
One further advantage is that we cansimultaneously
getlowpass, bandpass and highpass filter output
Trang 25The State Variable Filter
y h (n)
×
F 1+
y b (n)
×
F 1+
×
−1 x(n)
Trang 26The State Variable Filter Algorithm
State Variable Filter difference equations are given by:
yl(n) = F1yb(n) + yl(n− 1)
yb(n) = F1yh(n) + yb(n− 1)
yh(n) = x (n)− yl(n− 1) − Q1yb(n− 1)
with tuning coefficients F1 andQ1 related to the cut-off
frequency, fc, and damping, d:
F1 = 2 sin(πfc/fs), and Q1 = 2d
Trang 27MATLAB Wah-wah Implementation
Making a Wah-wah
We simply implement the State Variable Filter with a Sinusoid
Modulated(variable) frequency,fc
wah wah.m:
% wah_wah.m state variable band pass
%
% 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
Trang 29Wah-wah Implementation
wah wah.m (Cont.):
% change in centre frequency per sample (Hz)
% 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;
Trang 30Wah-wah Implementation
wah wah.m (Cont.):
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 and Output
Trang 31Wah-wah MATLAB Example (Cont.)
The output from the above code is (red plot is original audio):
Original AudioClick on images or here to hear: original audio,wah-wah audio
Trang 32Delay Based Effects
Many useful audio effects can be implemented using adelaystructure:
Sounds reflected off walls
In a cave or large room we here an echo and also
see later
If walls are closer together repeated reflections canappear as parallel boundaries and we hear a modification
of sound colour instead
Vibrato, Flanging, Chorus and Echo are examples ofdelay effects
Trang 33Basic Delay Structure
The Return of IIR and FIR filters:
We build basic delay structures out of some very basic IIRand
FIR filters:
We use FIR and IIR comb filters
Combination of FIR and IIR gives the Universal CombFilter
Trang 34FIR Comb Filter
FIR Comb Filter: A single delay
This simulates asingle delay:
The input signal is delayed by a given time duration, τ 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) with M = τ /fsThe transfer function is:
H(z) = 1 + gz−M
Trang 35FIR Comb Filter Signal Flow Diagram
1
CM3106 Chapter 6: MIDI Delay Based Effects 35
Trang 36FIR Comb Filter MATLAB Code
Trang 37IIR Comb Filter
IIR Comb Filter: single delay
This simulates asingle delay:
Simulatesendless reflections 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 isfed back to the input
Each time it is fed back it is attenuated byg
Input sometime scaled byc tocompensate for high
amplification of the structure
The difference equation is simply:
Trang 38IIR Comb Filter Signal Flow Diagram
1
CM3106 Chapter 6: MIDI Delay Based Effects 38
Trang 39IIR Comb Filter MATLAB Code
Trang 40Universal Comb Filter
Universal Comb Filter
Combination of the FIR and IIR comb filters
Basically this is an allpass filter with anM sample delayoperator and an additional multiplier, FF
T M x(n− M)
Parameters:
FF= feedforward,FB = feedbackward,BL =blend
CM3106 Chapter 6: MIDI Delay Based Effects 40
Trang 41Universal Comb Filter Parameters
Why is “Universal”?
Universalin that we can form any comb filter, an
allpass or a delay filter:
Trang 42Universal Comb Filter MATLAB Code
Trang 43Vibrato - A Simple Delay Based Effect
Vibrato:
Vibrato —Varying (modulating) the time delay
periodically
If we vary the distance between an observer and a
sound source (cf Doppler effect) we here a change inpitch
Implementation: A Delay line and alow frequencyoscillator(LFO) tovary the delay
Onlylisten to the delay— no forward or backward feed.Typical delay time = 5–10 Ms and LFO rate = 5–14Hz
Trang 44Vibrato MATLAB Code
vibrato.m function:
See vibrato eg.m for sample call this function
function y= vibrato (x,SAMPLERATE,Modfreq,Width)
ya_alt= 0
Delay=Width; % basic delay of input sample in sec
DELAY=round(Delay * SAMPLERATE); % basic delay in # samples
WIDTH=round(Width * SAMPLERATE); % modulation width in # samples
if WIDTH > DELAY
error( ’delay greater than basic delay !!!’ );
return;
end;
MODFREQ=Modfreq / SAMPLERATE; % modulation frequency in # samples
L= 2+ DELAY + WIDTH *2 ; % length of the entire delay
Delayline=zeros(L, 1 ); % memory allocation for delay
y=zeros(size(x)); % memory allocation for output vector
Trang 45Vibrato MATLAB Code (Cont.)
Trang 46Vibrato MATLAB Example (Cont.)
The output from the above code is (red plot is original audio):
Original Audio
Click image or here to hear: original audio, vibrato audio
Trang 47Comb Filter Delay Effects:
Flanger, Chorus, Slapback, Echo
A few other popular effects can be made with a comb filter (FIR or IIR) and some modulation.
Flanger, Chorus, Slapback, Echo same basic approach but different sound outputs:
Effect Delay Range (ms) Modulation
Slapback (or doubling) — quick repetition of the sound,
Flanging — continuously varying LFO of delay,
Chorus — multiple copies of sound delayed by small random
delays
Trang 48Flanger MATLAB Code
% parameters to vary the effect %
max_time_delay= 0.003 ; % 3ms max delay in seconds
rate= 1 %rate of flange in Hz
index= 1 length(x);
% sin reference to create oscillating delay
sin_ref = (sin( 2* pi * index * (rate / Fs))) ’
%convert delay in ms to max delay in samples
max_samp_delay=round(max_time_delay * Fs);
Trang 49Flanger MATLAB Code (Cont.)
% 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);
Trang 50Flanger MATLAB Example (Cont.)
The output from the above code is (red plot is original audio):
Original AudioClick here to hear: original audio, flanged audio
Trang 51Modulation:
The process where parameters of a sinusoidal signal
(amplitude, frequency and phase) are modified or varied by anaudio signal
We have met some example effects that could be considered
as a class of modulation already:
We will now look at some other Modulation effects
Trang 52more complicated for signals having numerous partials
If the modulator is also a sine wave with frequency, f x then one hears the sum and difference frequencies: f c + f x and f c − fx, for example.
When the input is periodic with at a fundamental frequency, f 0 , then a
spectrum with amplitude lines at frequencies |kf0± f c |
Used to create robotic speech effects on old sci-fi movies and can create some odd almost non-musical effects if not used with care ( Original speech ).
ring modIlikeMM.m code here
Ring Modulated: I Like Multimedia
Trang 53MATLAB Ring Modulation
Two examples
An audio sample and a sine wave being modulated by a sinewave
Example 1: Audio RM, ring mod.m
% read the sample waveform
[x,Fs,bits] = wavread( ’acoustic.wav’ );
Trang 54Example 1: Audio RM Output
Original AudioClick image or here to hear: original audio,
ring modulated audio
Trang 55MATLAB Ring Modulation: Two sine waves
Example 2: Two sine waves RM ring mod 2sine.m
% Ring Modulate with a sine wave frequency Fc
Fc = 440 ;
carrier= sin( 2* pi * index * (Fc / Fs)) ’
%create a modulator sine wave frequency Fx
Fx = 200 ;
modulator = sin( 2* pi * index * (Fx / Fs)) ’
% Ring Modulate with sine wave, freq Fc
y = modulator * carrier;
% write output
wavwrite(y,Fs,bits, ’twosine_ringmod.wav’ );
Trang 56Example 2: Two Sine RM Output
Output of Two sine wave ring modulation (fc = 440, fx = 380)
Click image or here to hear:
Two RM sine waves (fc = 440, fx = 200)
Trang 57α = 0 tuns off modulation
x (n) is the audio carrier signal
m(n) is a low-frequency oscillator modulator
When x (n) and m(n) both sine waves with frequencies f c and f x
respectively we here three frequencies: carrier, difference and sum:
fc, f c − f x , f c + fx.