# Making a mesh out of the parameters from a STFT

I do not possess much knowledge about signal processing, so i hope to do a find an answer. I am reading a wav-file and then apply a fft on it. In theory, i think i have a 3 parameters i can use. Time (length of my audio signal), frequeny and amplitude. i defined frequency and time like this:

[y,fs] = audioread('filename');
fftlen=4096;
f=0:1:fftlen-1;
f=f/(fftlen-1)*fs;

t = linspace(0,length(y)/fs,length(y))


Of course there are other parameters i need to define too... But how can i define the axes for mesh? If X is time, Y=frequency and Z= Amplitude for example. I need to do it with a stft. If necessary, i can post my whole code.

• No, an FFT only has one parameter (FFT length), which directly depends on the shape of the input. I think you might be asking the wrong question (XY Problem). What is it that you want to do? – Marcus Müller Jan 27 '17 at 9:51
• By the way,since you and this user,this user,this and thisshare the same IP address (and hence, the same unregistered user avatar), I'd like to point out that you really should create an account when you ask multiple questions – it makes it possible for you to go back and accept answers a while after asking etc, and thus is really useful for you. – Marcus Müller Jan 27 '17 at 10:12
• i.e when asking a lot of questions, I actually find that politeness would require you to identify yourself. That allows us to take reference to other questions of you, and might save us a lot of work. – Marcus Müller Jan 27 '17 at 10:16

I am reading a wav-file and then apply a fft on it. In theory, i think i have a 3 parameters i can use. Time (length of my audio signal), frequeny and amplitude.

Given that you mention "STFT, mesh", simply running a Fast Fourier Transform on your audio signal is not going to produce what you are after. This is because, a single FFT, over the whole signal, returns the same signal in a different representation.

Therefore, what you are after is many Short Time Fourier Transform of length shorter than the signal, applied in a "sliding window" way, with some overlap and their Magnitude Spectrum.

Eventually, what you will end up with is, a Spectrogram. The output from a function that performs a spectrogram is usually a two dimensional array. One of the dimensions is related to the dimension of Time and the other is Frequency. The reason why I say "is related to" rather than "is", is because of the "sliding window" and the fact that what you will end up with is actually a "frame index" rather than time itself. The third dimension is the Magnitude of a frequency component at some point in time (or at a given "sliding window" frame).

If you have a signal that is 1024 samples long and you do a spectrogram with 512 point FFTs and 0% overlap, you will get back a matrix that is 512x2 in dimensions.

The spacing between adjacent cells of the Spectrogram's output is determined by the parameters of the Spectrogram. But, in a nutshell, the spacing between the columns depends on the frame overlap and the spacing between the rows depends on the Sampling Frequency.

To turn the two dimensional output of Spectrogram to a "three dimensional" plot, all that you have to do is layout a grid of size equal to the spectrogram and modulate the dimension vertical to it by the spectrogram's magnitude.

ALL of this business, is done in MATLAB with two functions. spectrogram and mesh (or surf).

Hope this helps.