aditya aditya - 2 months ago 27
Android Question

How to generate the spectrogram of a wav file in Matlab with frequency on the x-axis

As part of a research project, I would like to analyze a sound file by generating it's spectrogram.

I have been able to successfully generate the spectrogram of the wave file in matlab with frequency on the y-axis and the time on the x-axis. I would however, like to generate the spectrogram with the frequency on the x-axis and the time on the y-axis. How can this be done?

I have searched through stack and have not found any accepted answers.

My code which generates the spectrogram with the frequency on the y-axis and the time on the x-axis (Matlab code):

[song, fs] = wavread('filename.wav');
windowSize = 256;
windowOverlap = [];
freqRange = 0:300;
spectrogram(song, windowSize, windowOverlap, freqRange, fs, 'yaxis');


I changed the parameter 'yaxis' in the function spectrogram to 'xaxis' and the frequency is now on the x-axis with time on the y-axis. But, I get a spectrogram different from what is generated from a reliable source.

Here is the spectrogram that I generate - spectrogram

The spectrogram generated from a reliable source (I don't have the code).

reliable_spectrogram

Moreover, the color scheme is different in both the spectrograms. And my recording is 50 seconds long whereas the time displayed on the label is 9 seconds. How can I resolve these issues?

My end task is to be able to generate the spectrogram on an android device (probably using the GraphView library in android). So I would have to write code to generate the spectrogram in Java.

Any help on this is greatly appreciated.

Answer

Preface

Sorry, I don’t have whichever