Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The values returned by the App #1

Open
UdayKandpal opened this issue Dec 10, 2018 · 6 comments
Open

The values returned by the App #1

UdayKandpal opened this issue Dec 10, 2018 · 6 comments

Comments

@UdayKandpal
Copy link

Hi, I want to try this app for finding the decibel value of the the sound/pressure at the MIC. Your app description says -160 is the silence level. So, how to convert the values from 0 to 200 dB. Can we place a 20 dB sound near MIC and expect a value of 20 in the value or the rawValue. Basically I want to understand what value is returned in the value and rawValue of your app. On Ubuntu placing MIC near sound takes the value to at most 0 and rawValue to at most 32767. On MAC OS, the value and rawValue remain the same and got to about 6 (positive value) at most. So I wonder it can show data in decibels say for sounds of 50 dB or 90 dB. Do respond at the earliest.

@punarinta
Copy link
Owner

punarinta commented Dec 10, 2018

Hi @UdayKandpal!
That was done purely for normalizing data, so that it could be used for vizualisation, otherwise (see rawValue) the range would depend on the operating system.

As I understand that -160db notation is originally for sensitivity of the whole audio system at the moment, not for actual sound level, so there are definitely things like microphone autoadjustment playing role, hence those possible sensitivity issues. Check that you disable this stuff everywhere.

Conversion from [-160;0] to [0;160] can be done by simply adding 160, I think this is correct. Stretching the range to 200dB feels wrong, because that scale is logarithmic.

rawValue comes directly from the operating system, so you may use it to get more precise values if you know how your mic/amplification works.

@UdayKandpal
Copy link
Author

UdayKandpal commented Dec 10, 2018

Hi @punarinta

As I analysed your code, I found that rawValue will be same as value on MacOs.

However, I think adding 160 might not work as value given by MacOS without any noise near microphone is -50 (that would be 110dB if we convert by adding 160), whereas it turns towards 0 or 5 (that is around 160-165 decibel which is wrong value) when song is played near MIC through earphone. On Android you have used 20 log(amplitude/32767) as formula for decibel. However we only get negative values as amplitude will be always smaller than equal to 32767 i.e. will only reach 0 on android at max.

This does not give us the value required in the decibel. Could you guide us through getting the actual decibel value.

@punarinta
Copy link
Owner

punarinta commented Dec 10, 2018

@UdayKandpal values can sometimes get over zero because some OS's allow extra amplification. See for example a screenshot of how mic level management looks like in my Ubuntu:
untitled
That small white pin is a 0dB level as I understand it.

Or a similar thing in the settings
screenshot from 2018-12-10 12-07-15

The level you get in the library is a product of your input level and your amplification level. Unfortunately I don't know how operating systems produce the final result, but I believe if you fix the amplification on let's say 100% (0dB) level then it should work in a similar way everywhere.

@ncstc1
Copy link

ncstc1 commented Sep 14, 2023

Regarding the current value on android, I think there is a typo: Math.log is used instead of Math.log10.

After the change, the values (and their variations) are more comparable to those retrieved in the same conditions on iOS (the comparison is tricky due to calibration or hardware differences but at least the range is comparable).

For example a quiet environment is around -45 (pseudo dBFS?).

What transformations do you apply to have more comparable values or use different units?

@amitkajwani-simformsolutions

any update on this @ncstc1 ?

@ncstc1
Copy link

ncstc1 commented Feb 1, 2024

I only made the patch I mentioned above (use log10 instead of log in RNSoundLevelModule.java).

Did you make more changes on your side?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants