[go: up one dir, main page]

0% found this document useful (0 votes)
4 views3 pages

SC Algo Flow

The document outlines a MATLAB script for processing an audio signal, specifically a song, using a low-pass FIR filter. It includes steps for reading the audio file, plotting the input signal's responses, designing the filter, and plotting the output signal's responses after convolution. The algorithm provides a structured approach to signal processing with specific parameters like sampling frequency and cutoff frequency.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

SC Algo Flow

The document outlines a MATLAB script for processing an audio signal, specifically a song, using a low-pass FIR filter. It includes steps for reading the audio file, plotting the input signal's responses, designing the filter, and plotting the output signal's responses after convolution. The algorithm provides a structured approach to signal processing with specific parameters like sampling frequency and cutoff frequency.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Fs = 22000; % Sampling Frequency

N = 100; % Order
Fc = 1500; % Cutoff Frequency
song = 'Eugene';

[sam, fs]=wavread(song);
%soundsc(w, fs);
le = length(sam)-1;
t=0: 1/Fs : le/Fs;
f = 0: Fs/le :Fs;
wp=Fc/(Fs/2);

figure(1); %plot original input


subplot (2, 2, 1); plot(t,sam,'b');
xlabel('Time'); ylabel('Amplitude'); title('Impulse Response of Input') % Time
- domain

mag = abs(sam); subplot(2, 2, 2); plot (t, mag,'b'); %Magnitude


Response
xlabel('Frequency'); ylabel('Magnitude');title('Magnitude Response of Input')
% Time domain

freq = abs(fft(sam)); subplot(2, 2, 3); plot (f, freq,'b'); % Frequency


Response
xlabel('Frequency');ylabel('Amplitude');title('Frequency Response of Input') %
Frquency domain

phase = angle(sam); subplot(2, 2, 4); plot (t, phase,'b'); % Phase


Response
xlabel('Frequency'); ylabel('Amplitude');title('Phase Response of Input')
% time domain

figure(2);
win = boxcar(N+1);
b = fir1(N,wp,'low',win);

[h, o] = freqz(b,1,250);
m=20*log(abs(h));

subplot(2,1,1); plot(b,'b'); title('Ideal Impulse Response')


xlabel('n'); ylabel('hd(n)')
subplot(2,1,2); plot(m,'b'); title('Magnitude Response')
xlabel('n'); ylabel('w(n)')

sam=sam(:);
b = b(:); b= b';
convo = conv(sam, b);
convo = convo(:); convo = convo';

figure(3) %plot convolved signals


subplot(3, 2, 1); plot(convo); % impulse response
xlabel('Time'); ylabel('Amplitude'); title('Impulse Response of Output
Signal') % Frequency domain
magconvo = abs(convo);
subplot(3, 2, 2); plot(magconvo); % magnitude response
xlabel('Frequency'); ylabel('Amplitude'); title('Magnitude Response of
Output Signal') % Frequency domain

magindB = 20*log10(magconvo);
subplot(3, 2, 3); plot(magindB); % magnitude response in dB
xlabel('Frequency'); ylabel('Amplitude'); title('Magnitude Response of
Output Signal in dB') % Frequency domain

confreq = abs(fft(convo)); %frequency response


subplot(3, 2, 4); plot(confreq);
xlabel('Frequency'); ylabel('Amplitude'); title('Frequency Response of
Output Signal') % Frequency domain

phaseconvo = angle(convo); %frequency response


subplot(3, 2, 5); plot(phaseconvo);
xlabel('Frequency'); ylabel('Amplitude'); title('Phase Response of
Output Signal') % Frequency domain

Algorithm:

1. Start
2. Initialize Sampling frequency (Fs = 22000), Filter order
(N=100), Cut-off Frequency (Fc = 1500) and Input (song =
(‘filename’)
3. Read song (wavread)
4. Set Wp = Fc/ (Fs/2)
5. Plot Input’s Impulse Response, Magnitude Response, Frequency
Response, and Phase Response
6. Set win = boxcar(N+1)
7. Compute for b = fir1(N, Wp , ‘low, win )
8. Compute [h, o] = freqz (b, 1, 250)
9. Plot the Ideal Impulse Response and Magnitude Response of a
Low-pass Boxcar Filter
10. Set sam and b ready for convolution. Sam = sam(:) , b = b(:),
b=b`
11. Convolve sam and b
12. Plot Output’s Impulse Response, Magnitude Response, Frequency
Response, and Phase Response
13. End

You might also like