Calculate decibels
问题 I'm recording mic input using the XNA library (I don't think this is really technology specific, but it never hurts). Every time I get a sample I would like to calculate the decibels. I have done many searches on the internet and not found a rock solid example... Here is my attempt at calculating decibels from a sample: double peak = 0; for (var i = 0; i < _buffer.Length; i = i + 2) { var sample = BitConverter.ToInt16(_buffer, i); if (sample > peak) peak = sample; else if (sample < -peak)