File Exchange

image thumbnail

Sound Analysis with Matlab Implementation

version 1.3.0.0 (338 KB) by Hristo Zhivomirov
Time and frequency analysis, measurement of the crest factor, the dynamic range, etc.

75 Downloads

Updated 18 Feb 2017

View License

The present code is a Matlab program for signal analysis of a given sound file. The analysis includes:
1) Plotting of the:
- signal in the time domain;
- signal in the frequency domain (spectrum);
- signal in the time-frequency domain (spectrogram);
- amplitude probability distribution of the signal;
- autocorrelation function of the signal.
2) Displaying of the:
- minimum and maximum value of the signal;
- standard deviation (RMS-value);
- mean value (DC-value);
- crest-factor Q;
- dynamic range D;
- autocorrelation time.
The code is based on the theory described in:

[1] D. Manolakis, V. Ingle. Applied Digital Signal Processing. Cambridge, Cambridge University Press, 2011.

[2] G. Heinzel, A. Rudiger, R. Schilling. Spectrum and spectral density estimation by the Discrete Fourier transform (DFT), including a comprehensive list of window functions and some new flat-top windows. Germany, Hannover, Max-Planck-Institut für Gravitationsphysik, 2002.

[3] I. Tashev, A. Acero. Statistical Modeling of the Speech Signal. IWAENC 2010, August 30 - September 2 2010, Tel Aviv, Israel.

[4] M. Mijic, D. Masovic, D. Pavlovic, M. Petrovic. Statistical properties of music signals. 126th AES Convention, May 7 – May 10, Munich, Germany. Proceedings of papers, p. 7702, 2009.

[5] Хр. Живомиров, Д. Пламенова. Изследване някои параметри на аудио сигналите. Национална конференция с м.у. „Акустика 2012”, 12 Октомври 2012, Варна / Списание Акустика, ISSN: 1312-4897, год. XIV, бр. 14, стр. 89-95, 2012.

Comments and Ratings (20)

Hello Jasper!

Yes, the code treats only the first sound channel. In order to do the second one, please change line 11 to x = x(:, 2);. And yes, it is long-term-average spectrum, while the spectrogram on lines 26-33 is the short-time one.

All best,
Hristo

Jasper Ward

Am I right in thinking that this will only do the left channel of an audio file? If so is there a way I can alter the code so it will analyse a stereo? My other query is how the "signal in the frequency domain" section works. Is this a long-term-average-spectrum?

Hi David! Yes, perhaps the frequency of your data is described in kHz...

David Duque

Or do you think it is described in kHz instead of Hz?

David Duque

Unfortunately in my sample the frequencies are between 0 and 25 and they actually should be from 0 to at least 10000. Do you know how I can fix it?

Hi David! I just do not want to restrict the spectral analysis to the human hearing frequency range. For instance, the analysed signal could be infrasound or ultrasound.

Hi Akshat! I use electrical (not sound) level when perform the spectral analysis. I treat the signal itself, regardless of the underlying process. The reference level is 1 V.

AKSHAT NEGI

what is the reference decibel value for this code in this function?

David Duque

Thank you very much! I still have a question, why is the Frequency Range not from around 16Hz to 20000Hz?

Just what I needed, thank you!

Sean Jungst

Thanks a lot! This code helped me create a very interesting GUI project for my Matlab class.

Very nice..
Question) How can i interpret from the autocorrelation graph & value ?

what is the autocorrelation of the music signal?

Hi, Nguyen! The basic reason for a minus sign in front of some dB value is because the logarithm of a number 0<x<1 is negative.

Why dB have "-"?

Thank you very much!

Michael

helal

Updates

1.3.0.0

A new version of the code has been uploaded.

1.2.0.0

A new version of the code has been uploaded.

1.1.0.0

Calculation of the autocorrelation function of the signal is added.

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: plotpsd

Communities