0
votes

I have a question regarding the following piece of code that I found to measure how much noise is included in a piece of audio:

Sx = fft(x .* hann(length(x), 'periodic')) pk2rms = max(abs(Sx))/sqrt(sum(abs(Sx).^2)/length(Sx))

This code shall calculate the peak-to-rms ratio of a signal and shall be used to measure the noise that is included in an audio signal.

As far as I understand, the max(abs(Sx)) calculates the Peak, and the sqrt(sum(abs(Sx).^2) calculates the RMS. But I don't get why this is the case. Why do I first have to apply FFT to calculate the Peak? Isn't the peak just the highest amplitude that is included in a signal? If that was true, I should take do max(abs(x)) without converting the signal into frequency-domain? And why do I have to divide the whole thing by the length of the signal?

I can imagine that the answers to my questions could be obvious to some of you experts, but I couldn't find proper answers until now.

Thank you very much in advantage!

1

1 Answers

0
votes

The signal-to-noise ratio (SNR) gives you a figure of merit that tells you a distance between your strongest information signal and the undesired noise in the system. In a way, it is the room a useful signal has before it becomes drowned out by noise.

If you take the amplitude of your signal in the time domain, you will get the superposition of many different signals with different frequencies. This could be different components of your desired signal but also noise. This is not what you want.