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

Is it possible to set sampling rate? #18

Open nwatab opened 4 years ago

nwatab commented 4 years ago

Thank you for nice library. Is it possible to set or change sampling rate? It seems that the sampling rate is fixed to 22050Hz.

Jonjoe commented 3 years ago

Hey bud, I know this is late but I love it when engineers come back and explain how they solved things so heres your answer :)

I had the same issue. I started looking through the code and I found this https://github.com/punarinta/react-native-sound-level/blob/master/index.js#L13

It means you can pass a sample number into the start function like this vvv

RNSoundLevel.start(1000);
ncstc1 commented 1 year ago

Hello there, the start argument will change the monitorInterval but not the audio sampling rate.

At this point I think the sampling rate is fixed and cannot be changed.

punarinta commented 1 year ago

@ncstc1 I've added sampling rate control in v1.2.0. Here's a usage example.

alessioemireni commented 1 year ago

on iOS doesn't compile because the parameter is sampleRate and not samplingRate https://github.com/punarinta/react-native-sound-level/commit/823eca0963cf007322f1e545ca740c1023def054#diff-d62cb5adc173b12956b9aa426c235fe753fdc142830696461d56287931b454d6R75

alessioemireni commented 1 year ago

@punarinta I have opened a pull request to fix the compilation error and add the option to allow haptic/sound system during recording on iOS devices. https://github.com/punarinta/react-native-sound-level/pull/32 Let me know. Thx

alaingoldman commented 10 months ago

@alessioemireni this PR helped me a lot thanks!