punarinta / react-native-sound-level

A package to dynamically measure sound input level in React Native applications. Can be used to help user to adjust microphone sensitivity.
MIT License
79 stars 45 forks source link

Detecting sound in background #4

Open lightwolfz opened 5 years ago

lightwolfz commented 5 years ago

Is it possible to detect sound level when app is on the background or when screen is locked? I tried to use the library with react-native-background-timer it work but only after a minute it's only return rawValue: 0, value: -160 is there anyway to solve this?

punarinta commented 5 years ago

I haven't ever tested tested this, to be frank. What platform did you try it on? I'm not a guru of iOS, but on Android I don't think there are any hinders for background audio signal acquisition.

lightwolfz commented 5 years ago

I used it on Android it was fine when testing with the emulator but not seems to work on my device.

lightwolfz commented 5 years ago

Any ideas?

punarinta commented 5 years ago

@lightwolfz no ideas, sorry man. What I thought could be the reason is that react-native-background-timer fires only in a specific moment of time and during the rest of the period no data is collected. And measurements are averaged over a period of time. However this doesn't explain why does it still work in the emulator.

punarinta commented 5 years ago

If you have any clues please write them here. I'd be very thankful.

lightwolfz commented 5 years ago

I'll keep working on it. I'll post the solution here if I have more information. Thanks for your support 😄