Problem 1....... you can use Matlab
The following Scilab code generates a 10-second “chirp” with discrete frequencies ranging from 0 to 0.2 with a sampling frequency of 8 kHz.
clear;
Fs = 8000;
Nbits = 16;
tMax = 10;
N = Fs*tMax+1;
f = linspace(0.0,0.2,N);
x = zeros(f);
phi = 0;
for n=0:N-1 x(n+1) = 0.8*sin(phi);
phi = phi+2*%pi*f(n+1);
end sound(x,Fs,Nbits);
sleep(10000); //allows full sound to play
Add code that calculates and plays y (n)=h(n)?x (n) where h(n) is the impulse response of an IIR lowpass filter with cutoff frequency 800 Hz and based on a 4th order Butterworth prototype. You should also generate a plot of y (n) vs. frequency (plot(f,y);). Name your program p1.sce Calculate the output from the input and filter coefficients using the following command: y = filter(b,a,x);
clear; clc;
Fs = 8000;
Nbits = 16;
tMax = 10;
N = Fs*tMax+1;
f = linspace(0.0,0.2,N);
x = zeros(size(f));
plot(f,x)
phi = 0;
for n=0:N-1 x(n+1) = 0.8*sin(phi);
phi = phi+2*pi*f(n+1);
end
sound(x,Fs,Nbits);
pause % this will pause the programm after sounding the
first.
% sleep(10000);
%% Adding new codes
% creating the low pass butterwidth filter
Fn = 800; % cut off frequency
n = 4; % order of the filter
[b,a] = butter(n,Fn/(Fs/2))
% b = zeros, a = poles of the TF
TF = tf(b,a);
imp_res = impulse(TF);
y_n = conv(imp_res,x);
y_n = y_n(1:length(f));
% Ploting the Y(n) with frequency
plot(f,y_n);
grid on
xlabel('frequency')
ylabel('y(n)')
title('frequency responce')
% Playing Y(n)
sound(y_n,Fs,Nbits);
% the output from the input and filter coefficients
y = filter(b,a,x)
% end program
Get Answers For Free
Most questions answered within 1 hours.