Getting loudness of a track with RMS
Another thing is that the RMS value is not very well correlated with perceived loudness. You might want to consider calling it level or volume instead. 
There is something called equal loudness contours which quantifies how sensitive the ear is to one particular frquency compared to another frequency, see the Wikipedia article. These curves are level dependent.
For instance, the ear is very sensitive to a 1kHz tone compared to a 100Hz tone, as shown in this image (horizontal axis is frequency in Hz): 



One of the relative simple things you can do is to filter your PCM data with an inverted equal loudness curve. Or you can apply the standard A weighting, see the Wikipedia Weighting Filter article. Then you can compute the RMS value of the output of the equal loudness weighted filter.