bastienFalcou / SoundWave

Illustrate your sound waves on the fly 🚀
MIT License
596 stars 93 forks source link

sound wave from recording voice #52

Open sultan-arshi opened 4 years ago

sultan-arshi commented 4 years ago

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 ?

bastienFalcou commented 4 years ago

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 :)

sultan-arshi commented 4 years ago

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