NateRickard / Plugin.AudioRecorder

Audio Recorder plugin for Xamarin and Windows
MIT License
164 stars 68 forks source link

Audio Level Metering #39

Open cortensinger opened 5 years ago

cortensinger commented 5 years ago

I want to access the input volume level coming in through the microphone. For the end result, I want to display a live 'Volume Meter' for user feedback while recording.

Is there any possible way to access the microphone's input volume when recording audio using this plugin?

EDIT: I see this plugin implements recording via an InputAudioQueue, and not the AVAudioRecorder. But these AudioQueues have the CurrentLevelMeter property that could be used to do what I want. Is there a way that I can access the current AudioQueue from my DependencyService thats responsible for all this?

EDIT 2: I was able to fix this in my code, but I had to edit your source code, so I dont know if I should close this issue or not. To fix it, I simply cloned the project to create a local assembly and then made a Public Static Float volumeLevel variable in the AudioRecordingService.cs file and then updated the value of volumeLevel with the result of Calculate_Levels() every time its called in the AudioStream_OnBroadcast() event handler. Then from my personal app, I referenced the local DLL and was able to simply access the volumeLevel variable whenever I wanted to update the GUI to show the changing volume level. This was it still acts as a cross-platform solution and it doesnt add any more heavy lifting than you have already done in your code. Works great!

NateRickard commented 4 years ago

I'd love to see a PR that added this functionality into the library...