Hi there If I got it right, all you wanna do is calculate the decibels of an audio file and trigger an an alert in case it goes over a certain threshold.
I found this great answer on Stack overflow, really recommend the whole read but I'll add here the TL;DR, however I do recommend the full read as you'll find some nice discussions on calibration and other problems you might find as you implement and test your solution. -- excerpt from the best answer Many wave-file editors have a vertical scale in decibels. There is no calibration or reference measurements, just a simple calculation: dB = 20 * log10(amplitude) The amplitude in this case is expressed as a number between 0 and 1, where 1 represents the maximum amplitude in the sound file. For example, if you have a 16 bit sound file, the amplitude can go as high as 32767. So you just divide the sample by 32767. (We work with absolute values, positive numbers only.) So if you have a wave that peaks at 14731, then: amplitude = 14731 / 32767 = 0.44 dB = 20 * log10(0.44) = -7.13 -- https://stackoverflow.com/a/9812267 2021年1月4日(月) 4:21 Jeff Mangan <j...@magentatech.com>: > I am able to open a wav file and iterate through samples of it. I am > trying to figure out the level of sound (loud vs low talking) and I believe > it's a matter of getting some value from the sample and then running some > math formulas. > > Anyone have any ideas or references on this, prefer not some heavy > complicated package since i just need to open the file and get the volume > level. I tried using portaudio but it seems to be a lot more than I need, > and was never able to get it working. > > My objective is to trigger an alert if a sample level is above some > threshold, so it does not need to be accurate, I can just get a sample > sound, get the level for that, and then if the level is above that trigger > the alert. > > Much appreciated any help, thanks. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/CAHr9bga_cjDGR%3DQE5OdWY%2BucX1ojLGN%3DMyqUOviXnt7miKyCNQ%40mail.gmail.com > <https://groups.google.com/d/msgid/golang-nuts/CAHr9bga_cjDGR%3DQE5OdWY%2BucX1ojLGN%3DMyqUOviXnt7miKyCNQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CADKBw2LUK1eV00N1MvS8iYg-5FtYSC%2B9njHkxKtfFjn93haXvA%40mail.gmail.com.