Passing an audio signal through a transfer function
Show older comments
I'm trying to pass an audio signal through a transfer function. I can read the .wav file with audioread function but I cannot play and plot the processed output signal with soundsc function. I have also tried lsim, it didn't work either. How can I do that? My relevant code is:
mySys=tf(sym2poly(n),sym2poly(d));
mySys=minreal(mySys);
figure
bode(mySys);
figure
impulse(mySys);
[y,Fs] = audioread('guitar_di_2.wav');
soundsc(y,Fs);
figure
plot(y)
y_fft = fft(y);
result = y_fft*mySys; % this takes a long time
figure
bode(result) % it doesn't plot this
result2 = ifft(result); % it cannot calculate this
figure
bode (result2)
soundsc(result2);
Answers (1)
Star Strider
on 15 Apr 2020
0 votes
I have no idea what ‘n’ and ‘d’ are, or how they were calculated. If they are calculated as continuous s-space polynomials, they need to be transformed to discrete transfer functions with a known sampling interval, ‘Ts’, that is tthe reciprocal of the sampling frequency of the audio file, so ‘1/Fs’. It is then possible to filter it, preferably with the Signal Processing Toolbox filtfilt function.
It is not a good idea to use an infinite-impulse-response (IIR) filter to filter in the frequency domain. There are just too many problems for that to be done easily or reliably.
2 Comments
Cosku Ozyurt
on 15 Apr 2020
Star Strider
on 15 Apr 2020
When I run this:
syms v_2 Vin % Missing, Added
H=v_2/Vin ;
H=collect(H);
pretty(H);
Hnumbers = eval(H);
[n,d]=numden(Hnumbers)
I get this:
v_2
---
Vin
n =
v_2
d =
Vin
It is not possible to construct a filter from those.
Categories
Find more on Simulation, Tuning, and Visualization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!