📜  c# 标准麦克风分贝 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:22.695000             🧑  作者: Mango

代码示例1
double sum = 0;
for (var i = 0; i < _buffer.length; i = i + 2)
{
    double sample = BitConverter.ToInt16(_buffer, i) / 32768.0;
    sum += (sample * sample);
}
double rms = Math.Sqrt(sum / (_buffer.length / 2));
var decibel = 20 * Math.Log10(rms);