声谱图声谱

2023-09-11 22:53:58 作者:失败乃成功之母

我做了一个应用程序,绘制FFT到屏幕上实时(从麦克风)。关于x轴,频率上y轴和象素重新$ P $的颜色时间psents幅度(pretty的太大的香草FFT频谱)。

I have made an app that paints FFT to the screen realtime (from mic). Time on x-axis, frequency on y-axis and the color of the pixel represents the amplitude (pretty much a vanilla FFT spectrogram).

我的问题是,即使我可以看到从音乐的模式也有很大的噪音。谷歌搜索它,我看到申请对数计算的振幅的人。我应该这样做呢?如果是的话,会是什么公式什么样子的? (我使用C#,但我可以翻译成数学code所以任何样品即可。)

My problem is that even though I can see a pattern from the music there is also a lot of noise. Googling it I see people applying a logarithmic calculation to the amplitude. Should I be doing this? And if so, what would the formula look like? (I'm using C#, but I can translate the math into code so any sample is ok.)

我可以通过将它呈现较深的颜色值越低配色方案绕过这个问题。我只是不知道,如果音频是重新正确psented没写对数计算$ P $。

I can bypass this problem by applying a color scheme showing lower values as darker colors. I'm just not sure if the audio is correctly represented without a logarithmic calculation on it.

推荐答案

再对数刻度幅度presentation接近人类听觉系统的灵敏度,并因此为您提供了一个更好的再presentation你所听到的,相比于非对数刻度。在数学上,所有你需要做的是:

Representation of the amplitude on a logarithmic scale approximates the sensitivity of the human auditory system, and therefore gives you a better representation of what you hear, as compared to a non-logarithmic scale. Mathematically, all you have to do is:

Alog = 20*log10 (abs (A))

其中, A 是FFT数据的振幅,而考勤是输出。的系数 20 仅仅是一个惯例,具有形象,你大概无论如何扩展到彩色方案没有影响。

Where A is the amplitude of the FFT data, and Alog is the output. the factor of 20 is just a convention and has no effect on the image, which you probably scale anyway to a color-scheme.

修改

有关说明 20 因素:是dB(分贝)单位数单位测量的比:它重新presents规模在其上在100和10的距离,是一样的1000和100之间(因为它们具有相同的比率:1000/100 = 100/10)。如果以dB为单位衡量你:

Explanation regarding the 20 factor: The dB (decibel) unit is a logarithmic unit measuring ratios: it represents a scale on which the distance between 100 and 10, is the same as between 1000 and 100 (since they have the same ratio: 1000/100 = 100/10). If you measure it in dB you get:

10*log10 (1000/100) = 10*log10 (100/10) = 10

的系数 10 是因为办法第十,这意味着1倍儿为10分贝,(如1千克为1000克),

The factor of 10 is because deci means tenth, which means 1 Bel is 10 deciBels, (like 1 kilogram is 1000 grams)

,由于人的听觉系统也是(约)测定比,是有意义的测量对数刻度的声级,即测量的声级比向一些参考值。由于声音的层次与声波的功率(瓦​​)相关联,则实际测量的功率P / preF的比率。此外,功率正比于振幅的平方,所以这一切的一切你:

Since the human auditory system is also (approximately) measuring ratios, it makes sense to measure sound level on a logarithmic scale, i.e measure the ratio of sound level to some reference value. Since the level of a sound is associated with the power (in Watts) of the sound wave, you actually measure the ratio of powers P/Pref. Also, the power is proportional to the amplitude squared, so all in all you get:

10*log10 (P/Pref) = 10*log10 (A^2 / Aref^2) = 20*log10 (A/Aref)

在日志规则。这就是 20 因子的起源 - 记得在计算机中的音频再由声波的瞬时幅度psented $ P $。

by the log rules. That's the origin of the 20 factor - remember that in the computer the audio is represented by the instantaneous amplitude of the sound wave.

相关推荐