Convolution of .wav files. Direct recorded guitar and Impulse response of guitar amplifier.

24 次查看(过去 30 天)
I am trying to convolve a short clip of guitar recorded directly into my computer through an audio interface, with an impulse response of the amplifier I usually play it through. I took this impulse response in MATLAB using the audio toolbox. When I put the Impulse response in an 'IR Loader' in my DAW (Digital Audio Workstation ie recording software), and apply it to the unaffected guitar signal It sounds right, however I am trying to do the operation in MATLAB. I tried convolving in time domain and it results in a delay/echo sound which is not what I am trying to achieve. I am trying to basically affect the EQ of the direct recorded guitar sound to make it sound as if it was going through the amplifier. Here is my code:
[DirectGuitar,Fs] = audioread("DirectGuitar.wav"); %Recording of Direct Guitar
[AmpIR] = audioread("DrZIR.wav"); %Impulse Response of 'Dr Z' Amplifier
Ampsound = conv(DirectGuitar,DrZIR); %convolution of the two
audiowrite('Ampsound.wav',Ampsound,Fs);
[DrZ,Fs] = audioread("Ampsound.wav");
sound(DrZ,Fs); %here I get a delay/echo
I also tried doing Fourier transforms of the two wav files and convolving them in frequency domain then doing an Inverse Fourier transform back and this resulted in a noisy, distorted, possibly bit crushed sound.
FTgtr = fft(DirectGuitar); % FFT of guitar
FTDrZ = fft(DrZIR); %FFT of amp IR
FreqDomainAmp = conv(FTDrZ,FTgtr); % Freq Domain convolution
Ampsound = ifft(FreqDomainAmp); % Inverse Fourier transform back to time domain
Ampsound = real(Ampsound); %to get rid of imaginary parts
audiowrite('Ampsound.wav',Ampsound,Fs);
[DrZ,Fs] = audioread("Ampsound.wav");
sound(DrZ,Fs); %here I get a noisy distorted bit crushed sound
Am I in the wrong ballpark alltogether trying to convolve these two signals?
Thanks for your help.

采纳的回答

Mathieu NOE
Mathieu NOE 2020-11-16
hello again
your impulse response is too long , if you look in detail there are delyed and attenuated spikes after the main (first) one
so removing that unecessary trailing section will also remove the echoes
hope the zip attached will get to you

更多回答(1 个)

Mathieu NOE
Mathieu NOE 2020-11-16
hello
your impulse response is a FIR filter; yes you can do signal processing by using the conv function, as the theory says, but IMHO there are matlab functions like filter and filtfilt that do all the hardwork for you , whatever FIR or IIR filter you want to apply
so I would stick to the time domain approach and simply replace the conv by filter
[DirectGuitar,Fs] = audioread("DirectGuitar.wav"); %Recording of Direct Guitar
[AmpIR] = audioread("DrZIR.wav"); %Impulse Response of 'Dr Z' Amplifier
% Ampsound = conv(DirectGuitar,DrZIR); %convolution of the two
Ampsound = filter(AmpIR,1,DirectGuitar);
audiowrite('Ampsound.wav',Ampsound,Fs);
[DrZ,Fs] = audioread("Ampsound.wav");
sound(DrZ,Fs); %here I get a delay/echo
regards
  3 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Audio Processing Algorithm Design 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by