Android PCM Bytes

前端 未结 5 946
无人共我
无人共我 2020-12-28 21:30

I am using the AudioRecord class to analize raw pcm bytes as it comes in the mic.

So thats working nicely. Now i need convert the pcm bytes into decibel.

I h

5条回答
  •  长发绾君心
    2020-12-28 22:16

    The problem is likely the definition of the "reference" sound pressure at the mic. I have no idea what it would be or if it's available.

    The only audio application I've ever used, defined 0db as "full volume", when the samples were at + or - max value (in unsigned 16 bits, that'd be 0 and 65535). To get this into db I'd probably do something like this:

    // assume input_sample is in the range 0 to 65535
    sample = (input_sample * 10.0) - 327675.0
    db = log10(sample / 327675.0)
    

    I don't know if that's right, but it feels right to the mathematically challenged me. As the input_sample approaches the "middle", it'll look more and more like negative infinity.

    Now that I think about it, though, if you want a SPL or something that might require different trickery like doing RMS evaluation between the zero crossings, again something that I could only guess at because I have no idea how it really works.

提交回复
热议问题