I'm receiving PCM samples through stream which is one channel, 8000 samples per second. I figured out way of finding out loudness by calculating 'force' of signal by adding abs value of every next 1000 samples and then dividing by samples count which is 1000. It works somewhat good but sometimes my calculations are going crazy, my sum of absolute values of samples seems to constantly build up and reach ridiculous values... so I think that I'm doing something wrong there. Funny thing is that when calculations are going crazy everything will go back to normal when I hit 'sound input device' with my hand ;)
Anyway. My question is: how to properly calculate loudness of set of PCM samples?