SoundWave
SoundWave copied to clipboard
sound wave from recording voice
i am recording a voice and want to show sound wave for it but i am getting audioRecorder.averagePower(forChannel: 0)
but i am getting value less then zero and greater then 1 and you library need values from 0 to 1
how can i convert this value ?
Hi @sultan-arshi!
Do you know the minimum
and maximum
values for the number you are getting while recording a voice? If so, with a fairly simple calculation you can bring this value back in a range between 0 and 1.
If you don't know what minimum
and maximum
are, I would just do some experimentation to find arbitrary values and use that as constants in your codebase. It should be good enough to draw meaningful waves :)
according to doc A return value of 0 dB indicates full scale, or maximum power; a return value of –160 dB indicates minimum power (that is, near silence).
means max = 0 db
and min = -160 db
i tried a lot to convert them