How do I plot the impulse response of a sound?

4 vues (au cours des 30 derniers jours)
Ashley Rudolph
Ashley Rudolph le 3 Déc 2019
Commenté : Ashley Rudolph le 11 Déc 2019
My assignment is to write a Matlab program that generates sounds using parametric resonators. The ultimate goal is to produce an interesting sound built from concatenated and/or summed outputs from these second order resonators. I can start with an 8kHz sample rate and produce decaying tones at frequencies of my choice. I need to plot some pulse responses and frequency responses.
I believe I have the frequency response at 8K Hz using the freqz() function. I'm not sure how to get the impulse response. Here is my code so far:
% Resonance program in matlab
fs=input('please enter a value for fs'); % Audio sampling rate (Hz)
N = 2*fs; % 2 seconds of data, time length
w0 = pi/8; % frequency - 16 cycles to go around unit circle
R = .999;
a1 = -2.*R.*cos(w0);
a2 = R*R;
G = (1-R).*sqrt(1-2*R*cos(2*w0)+R*R);
b0= G;
b = b0; % feed forward
a = [1 a1 a2]; % feedback
[H,w]=freqz(b,a,2^12);
plot(w, abs(H));
xlabel('Radians per Sample');
ylabel('Magnitude');
title('Frequency Response at 8000 Hz');
I = filter(b,a,[1,zeros(1,500)]); %impulse response
stem ([0:500],I);
xlabel('Samples');
ylabel('Amplitude');
title('Impulse Response at 8000 Hz');
pls=[1 zeros(1,N-1)]';
hpls=filter(b,a,pls);
plot (hpls);
soundsc(hpls, fs);
xlabel('radians per sample');
ylabel('Magnitude');
title('Sound for 2 Second');
Thanks in advance!

Réponse acceptée

Mahesh Taparia
Mahesh Taparia le 9 Déc 2019
Hi Ashley,
You can use impz, an inbuilt function in MATLAB to find the impulse response of discrete system. After finding transfer function, instead of using 'imfilter' you can use the below command to find the impulse response:
impz(b,a,16000,8000);
For more information, you can refer to documentation page of impz here.

Plus de réponses (0)

Catégories

En savoir plus sur Audio Processing Algorithm Design dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by