Android的PCM字节字节、Android、PCM

2023-09-05 03:31:44 作者:回身以陌路╮

我现在用的是AudioRecord类analize原始的PCM字节它有麦克风。

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

因此​​多数民众赞成工作很好。现在我需要转换PCM字节到分贝。

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

我有一个公式,需要健全的presure在宾夕法尼亚州到数据库。

I have a formula that takes sound presure in Pa into db.

DB = 20 * LOG10(PA / REF帕)

db = 20 * log10(Pa/ref Pa)

所以现在的问题是字节我从audiorecorder获得从缓冲区什么是它的幅度帕斯卡声音pressure还是什么。

So the question is the bytes i am getting from audiorecorder from the buffer what is it is it amplitude pascal sound pressure or what.

我试图把价值成德公式,但它回来了很HIGHT分贝,所以我不认为它的​​正确

I tried to putting the value into te formula but it comes back with very hight db so i do not think its right

感谢

推荐答案

免责声明:我知道一点关于Android

Disclaimer: I know little about Android.

您的设备可能是记录单声道每秒44,100个样本(也许更少)使用每样两个字节。所以,你的第一步就是要结合字节对你的原始数据为两个字节整数(我不知道这是如何在Android中进行)。

Your device is probably recording in mono at 44,100 samples per second (maybe less) using two bytes per sample. So your first step is to combine pairs of bytes in your original data into two-byte integers (I don't know how this is done in Android).

可以然后通过首先取样品的归一化的绝对值,并将它传递到您的分贝函数计算分贝值(相对于峰值)各样品的

You can then compute the decibel value (relative to the peak) of each sample by first taking the normalized absolute value of the sample and passing it to your Db function:

float Db = 20 * log10(ABS(sampleVal) / 32768)

峰(如+32767或-32768)附近的值将有一个dB值接近0。3277(0.1)的值将有-20 dB值; 327(0.01)的数值将有-40等dB值。

A value near the peak (e.g. +32767 or -32768) will have a Db value near 0. A value of 3277 (0.1) will have a Db value of -20; a value of 327 (.01) will have a Db value of -40 etc.

 
精彩推荐
图片推荐