Skip to content

How can I get current microphone volume? #698

Answered by mackron
FelipeIzolan asked this question in Q&A
Discussion options

You must be logged in to vote

You need to inspect the values of your samples that you get from the data callback. Take the absolute value of your samples to determine the volume. If you set your sample format to floating point (ma_format_f32), you can consider 0 to be silence and 1 to be maximum. For presentation on the UI, considering averaging your samples over a period of time and storing that in a variable (maybe average all of your samples from each data callback instantiation). Then scale the value (which will be between 0 and 1) to an appropriate value for presentation on your UI.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@FelipeIzolan
Comment options

Answer selected by FelipeIzolan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants