mic_stream
mic_stream copied to clipboard
calculate amplitude
Is there a way to calculate the amplitude of the streamed microphone data?
You can calculate the amplitude from the sampled data. How you do this depends on what type of amplitude you want (e.g., average amplitude over some delta time or mean squared amplitude).
Maybe have a look through this website: http://www.sengpielaudio.com/calculator-amplitude.htm Figure out what exactly you want to know, search for the right formula, and turn it into a discrete function.
Thank you! Could you explain to me what exactly you calculate in the _calculateIntensitySamples(samples) function?
It extracts the local minimum and maximum from each list of samples to calculate the local amplitude
@paxbo did you manage to do it?
Unfortunately not.. I switched to a native implementation in Java
Again, the important question is which kind of amplitude you want to calculate
@anarchuser my goal is to determine whether there is an active speaker or if the microphone is only registering background noise. I was thinking that the amplitude would be a good indicator of that, however, I'm unsure of the kind of amplitude that's more appropriate.
Then you want to have a look at calculating the mel-frequency cepstral coefficients. The mel-frequency cepstrum was invented for human voice recognition and as such allows you to easily distinguish between speech and noise
Coincidentally, there seems to be a package available for calculating the MFCCs: https://pub.dev/packages/mfcc
You can transform the audio stream to an mfcc stream. Do make sure to first transform the audio stream to Double. Then you can read out the right coefficient every now and then (You probably want the first one)
@anarchuser thank you for the help! Much appreciated