Lecture BSc Multimedia - Chapter 7: Digital audio effects

118 56 0
Lecture BSc Multimedia - Chapter 7: Digital audio effects

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

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.

CM3106 Chapter 7: Digital Audio Effects Prof David Marshall dave.marshall@cs.cardiff.ac.uk and Dr Kirill Sidorov K.Sidorov@cs.cf.ac.uk www.facebook.com/kirill.sidorov School of Computer Science & Informatics Cardiff University, UK Digital Audio Effects Having learned to make basic sounds from basic waveforms and more advanced synthesis methods lets see how we can at some 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 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 CM3106 Chapter 6: MIDI Intro FX Pipeline Effect Types and Parameters Apply effects in which order? Some ordering is standard for some audio processing, E.g: Compression → Distortion → EQ → Noise Redux Amp Sim → illustration below.→ You can use all effect modules together or selectively set certain Linking Effects Modulation → Delay → Reverb modules to on or off CanThealso beofconfigurable patches the G1/G1X consist of eight serially linked effect modules, as shown in the Common for order guitar (and other sources) effects pedal: Effect modules COMP/EFX DRIVE Compressor FD Clean Auto Wah EQ ZNR AMP MODULATION DELAY ZNR AMP Sim Chorus Delay Hall VX Clean Ensemble Tape Echo Room Analog Delay Spring Booster HW Clean Flanger Tremolo US Blues Step Phaser BG Crunch Pitch Shift Ping Pong Delay REVERB 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 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 CM3106 Chapter 6: MIDI Intro Effects 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 CM3106 Chapter 6: MIDI Intro Basic Digital Audio Filtering Effects: Equalisers Filtering: Filters by 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/diminish certain frequency bands whilst leaving others unchanged: Built using a series of shelving and peak filters First or second-order filters usually employed CM3106 Chapter 6: MIDI Equalisation Shelving and Peak Filters Shelving Filter: Boost or cut the low or high frequency bands with a cut-off frequency, Fc and gain G : CM3106 Chapter 6: MIDI Equalisation Shelving and Peak Filters (Cont.) Peak Filter: Boost or cut mid-frequency bands with a cut-off frequency,Fc , a bandwidth, fb and gain G : CM3106 Chapter 6: MIDI Equalisation Shelving Filters A First-order Shelving Filter: Transfer function: H(z) = + H0 (1 ± A(z)) where LF /HF + /− where A(z) is a first-order allpass filter — passes all frequencies but modifies phase: A(z) = z −1 + aB/C + aB/C z −1 B=Boost, C=Cut which leads the following algorithm/difference equation: y1 (n) y (n) = aB/C x(n) + x(n − 1) − aB/C y1 (n − 1) H0 = (x(n) ± y 1(n)) + x(n) CM3106 Chapter 6: MIDI Equalisation Shelving Filters (Cont.) Shelving Filter Parameters: The gain, G , in dB can be adjusted accordingly: H0 = V0 − where V0 = 10G /20 and the cut-off frequency for boost, aB , or cut, aC are given by: tan(2πfc /fs ) − tan(2πfc /fs ) + tan(2πfc /fs ) − V0 = tan(2πfc /fs ) − V0 aB = aC CM3106 Chapter 6: MIDI Equalisation Shelving Filters Signal Flow Graph H0 /2 x(n) A(z) ± y1 (n) × + y(n) where A(z) is given by: x(n) T × × aB/C + × x(n − 1) + y(n) −aB/C T y1 (n − 1) CM3106 Chapter 6: MIDI Equalisation 10 MATLAB Moorer Reverb moorer.m: function [y,b,a]=moorer(x,cg,cg1,cd,ag,ad,k) % This is a reverberator based on Moorer’s design which consists of % parallel feedback comb filters (each with a low pass filter in the % feedback loop) in series with an all pass filter % % The structure is: [y,b,a] = moorer(x,cg,cg1,cd,ag,ad,k) % % where x = the input signal % cg = a vector of length which contains g2/(1-g1) (this should be less % than for stability), where g2 is the feedback gain of each of the % comb filters and g1 is from the following parameter % cg1 = a vector of length which contains the gain of the low pass % filters in the feedback loop of each of the comb filters (should be % less than for stability) % cd = a vector of length which contains the delay of each of comb filter % ag = the gain of the allpass filter (should be less than for stability) % ad = the delay of the allpass filter % k = the gain factor of the direct signal % y = the output signal % b = the numerator coefficients of the transfer function % a = the denominator coefficients of the transfer function % CM3106 Chapter 6: MIDI Reverb/Spatial Effects 104 MATLAB Moorer Reverb (Cont.) moorer.m (Cont.): % send the input [outcomb1,b1,a1] [outcomb2,b2,a2] [outcomb3,b3,a3] [outcomb4,b4,a4] [outcomb5,b5,a5] [outcomb6,b6,a6] to each of the comb filters separately = lpcomb(x,cg(1),cg1(1),cd(1)); = lpcomb(x,cg(2),cg1(2),cd(2)); = lpcomb(x,cg(3),cg1(3),cd(3)); = lpcomb(x,cg(4),cg1(4),cd(4)); = lpcomb(x,cg(5),cg1(5),cd(5)); = lpcomb(x,cg(6),cg1(6),cd(6)); % sum the ouptut of the comb filters apinput = outcomb1 + outcomb2 + outcomb3 + outcomb4 + outcomb5 + outcomb6; %find the combined filter coefficients of the the comb filters [b,a]=parallelcoefficients(b1,a1,b2,a2); [b,a]=parallelcoefficients(b,a,b3,a3); [b,a]=parallelcoefficients(b,a,b4,a4); [b,a]=parallelcoefficients(b,a,b5,a5); [b,a]=parallelcoefficients(b,a,b6,a6); CM3106 Chapter 6: MIDI Reverb/Spatial Effects 105 MATLAB Moorer Reverb (Cont.) moorer.m (Cont.): % send the output of the comb filters to the allpass filter [y,b7,a7] = allpass(apinput,ag,ad); %find the combined filter coefficients of the the comb filters in series % with the allpass filters [b,a]=seriescoefficients(b,a,b7,a7); % add the scaled direct signal y = y + k*x; % normalize the output signal y = y/max(y); CM3106 Chapter 6: MIDI Reverb/Spatial Effects 106 MATLAB Moorer Reverb (Cont.) Example call, reverb moorer eg.m: % reverb_moorer_eg.m % Script to call the Moorer Reverb Algoritm % read the sample waveform filename=’ /acoustic.wav’; [x,Fs,bits] = wavread(filename); % Call moorer reverb %set delay of each comb filter %set delay of each allpass filter in number of samples %Compute a random set of milliseconds and use sample rate rand(’state’,sum(100*clock)) cd = floor(0.05*rand([1,6])*Fs); % set gains of comb pass filters g1 = 0.5*ones(1,6); %set feedback of each comb filter g2 = 0.5*ones(1,6); CM3106 Chapter 6: MIDI Reverb/Spatial Effects 107 MATLAB Moorer Reverb (Cont.) reverb moorer eg.m: % set input cg and cg1 for moorer function see help moorer cg = g2./(1-g1); cg1 = g1; %set gain of allpass filter ag = 0.7; %set delay of allpass filter ad = 0.08*Fs; %set direct signal gain k = 0.5; [y b a] = moorer(x,cg,cg1,cd,ag,ad,k); % write output wavwrite(y,Fs,bits,’out_moorerreverb.wav’); CM3106 Chapter 6: MIDI Reverb/Spatial Effects 108 MATLAB Moorer Reverb (Cont.) The input signal (blue) and reverberated signal (red): Moorer Reverberated Signal 0.8 0.6 0.4 0.2 −0.2 −0.4 −0.6 −0.8 −1 10 15 x 10 0.5 Original Audio −0.5 −1 10 15 x 10 Click here to hear: original audio, Moorer reverberated audio CM3106 Chapter 6: MIDI Reverb/Spatial Effects 109 Convolution Reverb Convolution Reverb: Basic Idea If the impulse response of the room is known then the most faithful reverberation method would be to convolve it with the input signal Due to the usual length of the target response it is not feasible to implement this with filters — several hundreds of taps in the filters would be required However, convolution readily implemented using FFT: Recall: The discrete convolution formula: ∞ y (n) = k=−∞ x(k).h(n − k) = x(n) ∗ h(n) Recall: The convolution theorem which states that: If f (x) and g (x) are two functions with Fourier transforms F (u) and G (u), then the Fourier transform of the convolution f (x) ∗ g (x) is simply the product of the Fourier transforms of the two functions, F (u)G (u) CM3106 Chapter 6: MIDI Reverb/Spatial Effects 110 Commercial Convolution Reverbs Commercial Convolution Reverbs Altiverb — one of the first mainstream convolution reverb effects units Most sample based synthesisers (E.g Kontakt, Intakt) provide some convolution reverb effect Dedicated sample-based software instruments such as Garritan Violin and PianoTeq Piano use convolution not only for reverb simulation but also to simulate key responses of the instruments body vibration CM3106 Chapter 6: MIDI Reverb/Spatial Effects 111 Room Impulse Responses Record a Room Impulse Apart from providing a high (professional) quality recording of a room’s impulse response, the process of using an impulse response is quite straightforward: Record a short impulse (gun shot,drum hit, hand clap) in the room Room impulse responses can be simulated in software also The impulse encodes the rooms reverb characteristics: CM3106 Chapter 6: MIDI Reverb/Spatial Effects 112 MATLAB Convolution Reverb (1) Let’s develop a fast convolution routine: fconv.m function [y]=fconv(x, h) % FCONV Fast Convolution % [y] = FCONV(x, h) convolves x and h, % and normalizes the output to +-1 % x = input vector % h = input vector % Ly=length(x)+length(h)-1; Ly2=pow2(nextpow2(Ly)); X=fft(x, Ly2); H=fft(h, Ly2); Y=X.*H; y=real(ifft(Y, Ly2)); y=y(1:1:Ly); y=y/max(abs(y)); % % Find smallest power of % that is > Ly % Fast Fourier transform % Fast Fourier transform % DO CONVOLUTION % Inverse fast Fourier transform % Take just the first N elements % Normalize the output See also: MATLAB built in function conv() CM3106 Chapter 6: MIDI Reverb/Spatial Effects 113 MATLAB Convolution Reverb (2) reverb convolution eg.m % reverb_convolution_eg.m % Script to call implement Convolution Reverb % read the sample waveform filename=’ /acoustic.wav’; [x,Fs,bits] = wavread(filename); % read the impulse response waveform filename=’impulse_room.wav’; [imp,Fsimp,bitsimp] = wavread(filename); % Do convolution with FFT y = fconv(x,imp); % write output wavwrite(y,Fs,bits,’out_IRreverb.wav’); CM3106 Chapter 6: MIDI Reverb/Spatial Effects 114 MATLAB Convolution Reverb (3) Some example results: Living Room Impulse Response Convolution Reverb: Impulse Response Impulse Response Reverberated Signal 0.5 0.8 0.4 0.6 0.3 0.4 0.2 0.2 0.1 −0.2 −0.4 −0.1 −0.6 −0.8 −0.2 −0.3 −1 500 1000 1500 2000 10 12 14 16 2500 x 10 0.5 Original Audio −0.5 −1 10 15 x 10 Click on above images or here to hear: original audio, room impulse response audio, room impulse reverberated audio CM3106 Chapter 6: MIDI Reverb/Spatial Effects 115 MATLAB Convolution Reverb (4) Cathedral Impulse Response Convolution Reverb: Impulse Response Impulse Response Reverberated Signal 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 −0.2 −0.4 −0.2 −0.6 −0.4 −0.8 −0.6 0.5 1.5 2.5 3.5 4.5 −1 0.2 0.4 0.6 0.8 1.2 1.4 x 10 1.6 1.8 x 10 Click on above images or here to hear: original audio, cathedral impulse response audio, cathedral reverberated audio CM3106 Chapter 6: MIDI Reverb/Spatial Effects 116 MATLAB Convolution Reverb (5) It is easy to implement some other (odd?) effects also Reverse Cathedral Impulse Response Convolution Reverb: Impulse Response Impulse Response Reverberated Signal 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 −0.2 −0.4 −0.2 −0.6 −0.4 −0.8 −0.6 0.5 1.5 2.5 3.5 4.5 −1 0.2 0.4 0.6 0.8 1.2 1.4 x 10 1.6 1.8 x 10 Click on above images or here to hear: original audio, reverse cathedral impulse response audio, reverse cathedral reverberated audio CM3106 Chapter 6: MIDI Reverb/Spatial Effects 117 MATLAB Convolution Reverb (6) You can basically convolve with anything Speech Impulse Response Convolution Reverb!: Impulse Response Impulse Response Reverberated Signal 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 −0.2 −0.2 −0.4 −0.4 −0.6 −0.6 −0.8 −0.8 0.5 1.5 2.5 3.5 4.5 −1 0.2 0.4 0.6 0.8 1.2 1.4 x 10 1.6 1.8 x 10 Click on above images or here to hear: original audio, speech ‘impulse response’ audio, speech impulse reverberated audio CM3106 Chapter 6: MIDI Reverb/Spatial Effects 118 ... 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 CM3106 Chapter 6: MIDI Time-varying Filters 30 Wah-wah... direct signal CM3106 Chapter 6: MIDI Time-varying Filters 22 Wah-wah Example Wah-wah, Signal flow diagram: direct-mix x(n) Time Varying BP × + y(n) wah-mix × where BP is a time-varying frequency... Original Audio −0.5 −1 10 15 x 10 Click on above images or here to hear: original audio, bass shelf filtered audio, treble shelf filtered audio CM3106 Chapter 6: MIDI Equalisation 21 Time-varying

Ngày đăng: 12/02/2020, 22:09

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan