Android-Audio-Waveform-Generator icon indicating copy to clipboard operation
Android-Audio-Waveform-Generator copied to clipboard

计算RMS的时候,为什么要乘以2

Open happyfsyy opened this issue 2 years ago • 1 comments
trafficstars

private fun calRMS(left: Float) {
    if (sampleCount == perSamplePoints) {
        val rms = sqrt(sampleSum / perSamplePoints) * 2 // 0~1
        sampleData.add(rms.toFloat())
        sampleCount = 0
        sampleSum = 0.0
    }

    sampleCount++
    sampleSum += left.toDouble().pow(2.0)
}

第二行,rms=sqrt(sampleSum/perSamplePoints)*2,为什么要乘以2 ?

happyfsyy avatar Sep 11 '23 02:09 happyfsyy

额,具体原因很久忘记了,可能就是为了放大下数据?

stefanJi avatar Sep 14 '23 07:09 stefanJi