Create an LTI system from .wav file

I'm using Matlab for the first time and would like to know how to use the data from a .wav file to create an LTI system and play that as a sound. So far I have some basic functionality with the program, the DFT, magnitue and phase of the DFT if that makes any difference.
I've attempted something along these lines, but i'm certain it's not the right way to go about it
n = info.BitsPerSample;
y(n) = x(n) + 0.5*x(n-1) + 0.7*x(n-2);
sound(y(n), FS);
For the audio itself I have the following
[data,Fs] = audioread('sound.wav');
info = audioinfo('sound.wav');
sound(data, Fs);

6 Comments

You can use the invfreqz function to create a transfer function from the fft information. You can then use that to create state space or other realisations from it. Playing it is not likely going to produce the desired result, because it is not actually ‘playable’ other than listening to its impulse response or step response, or to white noise filtered through it.
You can also use the System Identification Toolbox for this. The results will be essentially the same.
I'm quite curious abou the content of this wav file and how you would interpret it as LTI system ? a voice or music record is not comparable to a LTI system impulse response (that may be recorded as wav file maybe)
@Star Strider I looked up the functions and managed to get an output, thank you! And yeah the sound was quite underwhelming, just a simple boop sound.
@Mathieu NOE The wav file is just some simple acoustic guitar notes, my college professor wanted to have us implement it as such for an assignment. I was just confused as to how it would be implemented becasue I have no experience using Matlab.
@Bernardo Rodriguez Jr — That’s all there is to it. The LTI system estimate simply will do its best to model the transfer function as depicted in the Fourier transform of the sound.
I’m curious as to what your professor wanted to demonstrate with that assignment or lab exercise.
well
that wav file is the output of a system , if we can call the system = the guitar ; and your fingers are your inputs
so yes maybe we could build a model of the guitar , but having only the output is not sufficient to know / modelize the guitar ; you can look at matlab function tfestimate to see how input and output data together can help you create a transfer function of a process , that can be transformed to a LTI model .
Also there are techniques to build models directly from time domain data (but always input and output data is needed)
% Reference:
% Subspace Identification for Linear Systems
% Theory - Implementation - Applications
% Peter Van Overschee / Bart De Moor
% Kluwer Academic Publishers, 1996
% Stochastic algorithm: Figure 3.13 page 90 (positive)
% Combined algorithm: Figure 4.8 page 131 (robust)

Sign in to comment.

Answers (1)

Hi,
To pass a signal through a LTI system is done through convolution of transfer function and input signal
[data,Fs] = audioread('sound.wav');
%y(n) = x(n) + 0.5*x(n-1) + 0.7*x(n-2);
b = [1 0.5 0.7]; %numerator coefficients
a = 1; %denominator coefficients
y = filter(b,a,data);
sound(y, Fs);
%OR%
b = [1 0.5 0.7];
w(:,1) = conv(data(:,1),b);
w(:,2) = conv(data(:,2),b);
y = w;
sound(y, Fs);
In above both cases the y has same value, here the filter function process is same as convolution it can be done in either way
refer to filter and conv functions

Categories

Find more on Simulation, Tuning, and Visualization in Help Center and File Exchange

Products

Release

R2021b

Tags

Asked:

on 28 Apr 2022

Commented:

on 6 May 2022

Community Treasure Hunt

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

Start Hunting!