Finding average RMS volume

I’m looking to use the Compressor effect based on RMS values.

According to the docs, with the “Compress based on Peaks” unchecked (my preference) the threshold and noise floor selectors refer to RMS, not peak. So to set these values I need to have a way to select a section of audio to represent low volume sound and select a section of audio to represent noise and determine the average RMS volume of these areas.

The only place I’ve been able to find the ability to calculate average RMS volume is in the Analyze | Contrast tool, however this tool seems quite buggy and segfaults 100% of the time for me in 1.3.13 nightly builds and either segfaults or returns gibberish about 50% of the time in 1.3.12-Beta.

Is there another way to calculate average RMS volume of a region so as to be able to figure out the proper values for the compressor?

Using a compressor effectively is as much an art as a science. Selecting the optimum threshold and compression settings are a judgement call based on experience and the desired effect - or put another way - guessing. The RMS value will always be less than the peak value (except for square waves where the peak and RMS values are equal) so it is usually close enough to ‘guess’ a bit below the peak value. The RMS value of a sine wave is approximately 0.707 times the peak value (a bit less than 3/4).

To actually measure the RMS values you could try the experimental “Wave Stats” plug-in from this page https://forum.audacityteam.org/t/wave-stats-plug-in/15515/1
As the author of that plug-in I would welcome your feedback/comments.

I’d like to try out the RMS calculator but am having difficulty installing it. A file called File.php appeared on my desktop when I downloaded the plug in, but I don’t know where to put it. I can’t find a plug-in folder. All I have for Audacity is a file called Audacity in my Applications folder. I am running OSX 10.4.11 on a G5 iMac.

I’m not sure how you did that, but that is not the correct file.
Try this link: http://forum.audacityteam.org/download/file.php?id=1902
the file should be called “stats.ny”

I don’t use Mac’s but the instructions here say:

To install new plug-ins, place them in the Plug-Ins folder inside the Audacity installation folder. … On Mac OS X, it is usually under “Applications”. Restart Audacity, then the Plug-ins will appear underneath the divider in the “Effect”, “Generate” or “Analyze” menus.

And nowhere in all that did we establish the goal. What’s the goal? And don’t say “find the RMS value.” You didn’t wake up this morning with a burning desire to listen to an RMS value.

If your goal is to gracefully even out volume variations and increase the loudness of a show, you can’t beat Chris’ Compressor.

Chris’s Compressor
http://pdf23ds.net/software/dynamic-compressor/

Chris uses look-ahead processing and certain assumptions about what’s pleasant to hear and what isn’t to process the show. Oddly, when you listen to the finished show, it appears perfectly normal, but the high and low volume variations are gone and it’s louder. The assumptions and artistic biases are the “magic” mentioned above.

Straight RMS processing results in some very nasty artifacts, chief among them being bass note pumping where bass notes take over the show. It’s not pleasant. Some rock bands have used pumping as a special effect in their music.


<<>>

You can find the Average value and you can find the RMS value. They’re different.

Koz

I tried the new download link, by clicking on it. When I did so, a program called iGetter came up (the normal way I download) and I downloaded the file. It arrived on the desktop as File 1.php. The “1” was appended because I already had File.php on the desktop.

When I tried a different way of downloading (by holding Control while I clicked on the link), it also downloaded to the desktop and was called File.php.

The reason I couldn’t find the plugins folder was because I didn’t follow instructions when originally creating Audacity. I simply copied the Audacity icon to my Applications folder instead of copying the whole of the downloaded folder (which includes lots of additional files). Works okay like that. Anyway, the plugins folder is now there.

But how do I convert the thing called File.php to the form I require?

EDIT: I found the answer myself, after a bit of playing around. I changed the suffix to “.nv” instead of “.php” and once in the plug-ins folder, it worked.

Koz: Here’s the reason I want the RMS value of an entire file, or part thereof: to enable me to make sound files have similar sounding volume. Call them Sound 1 and Sound 2. Assume Sound 1 has a higher peak value than Sound 2. My idea is this:

  1. Normalize Sound 1 to 0dB.

  2. Find the RMS value of Sound 1.

  3. Find the RMS value of Sound 2 .

  4. Amplify Sound 2 so that it has the same RMS value as Sound 1. Could take a few attempts to find a suitable level of volume change, and each attempt would require a new calculation of RMS value, as I get closer to the correct value.

  5. Check that step (4) hasn’t caused clipping of Sound 2. If it does, repeat steps 1-5 with Sound 1 and Sound 2 changing places.

I simply want to experiment, and RMS would be quite useful to me.

That can be a problem with download managers. While DM’s can be useful, particularly for downloading large files over a dial-up modem, but they can be more trouble than they’re worth for small files, particularly for files that are served from active web pages (such as forum links). Some DM’s have a facility to set a minimum file size, so that small files (under, say 100 kB) are handled by the browser.

The RMS level does not automatically reveal how loud something will sound. It does however provide a better guide than peak level measurements.
I’ll be very interested to hear how you get on with your experiments. Experimentation of this type was one of the things I had in mind when writing the plug-in.

Take care with long files - the RMS value is calculated in RAM, so there could be problems if you attempt to analyse very long files - so keep an eye on memory usage.
I’ll also be interested in how well the plug-in performs in respect to memory usage.

After some limited testing of the Wave Stats plug-in, Audacity 1.3.1.2 (running under OSX 10.4.11 on a G5 i Mac) hasn’t crashed on files up to 3 minutes in length.

In trying to level match two sounds I have changed my approach to overcome clipping problems.

  1. Find the RMS value of Sound 1.

  2. Find the RMS value of Sound 2. Assume this is lower than for Sound 1.

  3. Calculate the difference between them in dB (say it was 7 dB), and then open the Amplify function (Effect > Amplify) for Sound 2. Amplify tells you how many dB of amplification you can apply before clipping occurs. It may be less than the 7 dB required in this case. Assume it says only 4 dB can be applied before clipping occurs. Apply 4dB of amplification.

  4. There is still 3 dB of difference. Since Sound 2 can’t be increased any further, decrease Sound 1 by 3 dB.

  5. Sound 1 and Sound 2 should now have the same RMS values.

Problem
Even though Sound 1 and Sound 2 now have the same RMS values, they may still sound of different loudness. I’m going to run some listening tests with several people to confirm this. It does seem to me though, that a simple way of determining apparent loudness is to look at how “dense” the waveform looks on the screen – the “more” sound there is on the screen (how dense the waveform is) the louder it sounds. I want to test this on a few people as well.

I suspect the reason that “A-weighted” and RMS functions may not give the best indication of apparent loudness is because some sounds are “dense” and others are more “spacious”. Even if two sounds have the same RMS value, the “dense” one will sound louder than the “spacious” one.

For example, the two sounds in the image below went through the process described above, with the result they have almost identical RMS values – but different apparent loudness. They are the same song performed by different people. I asked my partner which sounded the loudest and within about 10 seconds she picked the bottom one. When I asked her which “looked” the loudest immediately she said the bottom one.

I was amazed. “A-weightings” and “RMS” values and all sorts of complicated calculations are not as good as simply looking at a waveform. Why is that?

Just thoughts based on an hour or so of playing around.

Question
This “denseness” I have mentioned – how “dense” the sound appears on the screen – how could that be quantified? The average of the rectified waveform? It does seem a very simple method to determine apparent loudness.

I’m on the edge of my seat for the results of your Chris Compressor tests. You said you got the plugin, right?

Effect > Compress dynamics…

Chris’s reason for being is to gracefully even out the perceived loudness variations of presentations without clipping.

I know you’re having a lot of fun with this, but if smoothing out volume variations is your goal, Chris is certainly worth a test. That’s why he designed the plugin – because nobody else got it right.

Koz

Here are some results of my testing file sizes.

File 1 – 52 minutes, 16-bit stereo (~550 MB)
Crashed while trying to calculate wave stats.

File 2 – 28 minutes, 16-bit stereo (~300 MB)
Took about 20 seconds to calculate and present the stats, and about the same time to exit the wave stats window.

I was running a program called Activity Monitor while testing. It shows all sorts of data about CPU and memory. During the calculation of the wave stats for File 2, CPU usage attributed to Audacity sat around 80% with Free Memory (amount of unused physical memory) decreasing from 750 MB to 30 MB during the wave stats calculations, while VM Size (total amount of allocated virtual memory) increased by about 900 MB.

Inactive Memory (total allocated physical memory that is currently unused) was never below 1 GB. It appears that I have plenty of inactive memory being hogged by other programs that is not available to Audacity.

Can I allocate more memory to Audacity like I can for Photoshop?

The one in Photoshop is the memory map before the program starts swapping off to the hard drives. If you’re dealing with modules that don’t swap – ever – and it’s entirely possible you are, then you will always run out.

And no, you can’t force memory mapping without a developer getting into the act. Audacity uses generous memory anyway. It’s the canary in the coal mine for a computer. If you have a bad stick up in high memory, you may just not know about it until you try to do Audacity production.

Koz

That does not surprise me. The calculation occurs in RAM - real RAM, not swap file, and if you run too low on available RAM then bang it crashes. The plug-in could be modified to work with long files, but the only way that I can think of doing that would make it very slow.

Absolutely true - of course the best “measure” for loudness is by listening.
These “complicated calculations” are better than a peak level measurement, but they are still not fantastic.

Not easily. There are many factors that affect the perceived loudness.

Here’s a test that looks at peak level, A-weighted RMS and short sounds compared with longer sounds:
In this attached MP3 there are a series of sounds that are repeated for a total of 3 times.

  • The first time each of the sounds has the same amplitude (peak level). The different sounds are clearly very different loudness.
  • The second time, each sound has approximately the same A-weighted RMS level. I think that these sound much closer, but to me the higher tones toward the end of the sequence still sound noticeably louder.
  • The third time through the sounds are again (roughly) equal A-weighted RMS, but rather than constant tones they are short pulses. To my ear these sound roughly the same loudness.

Thanks for the sound file. I did some testing with it. First I opened it in iTunes (so as not to see the waveforms) and gave each section of sound a volume rating from 1-5. The first sound in each version was rated at 3, then I increased or decreased the rating depending on whether the following sounds were louder or softer. Then I opened the file in Audacity to see if my volume ratings correlated with the “density” of the waveform I could see. And they did to a reasonable approximation.

In what follows, I have labelled the “hissing” sounds A, B, C, D, and the tones T1, T2, T3.

Here are my volume ratings (waveform unseen) for the three versions (Note - my extra spaces to make numbers line up have been deleted):

A B C D T1 T2 T3
3 5 4 3 3 4 2
3 3 3.5 4 3 4 2
3 2 3 4 3 4 2

For Sound A it was tricky to estimate how loud it would be just by looking at the waveform (due to the superimposed very-low frequency component), so I have not included it in the images below. The first image is how B, C and D looked in Audacity (first version), and if I was asked to estimate the volume of B, C and D just by looking at the waveform, B would be loudest, followed by C, then D. Which is how I rated them in iTunes (5, 4, 3).




For the second version, my ratings were 3, 3.5 and 4, and in Audacity they look like this:

There’s not much between B & C, but C does “look” slightly louder because of the peaks.

For the third version, my ratings were 2, 3 and 4. Here they are in Audacity:

Again, B and C look pretty similar, but on close inspection, C “looks” louder.

I’m intrigued by how closely the volume of some sounds can be estimated just by looking at the density of the waveform as displayed in Audacity. It seems to give a better approximation to perceived loudness than any other method other than actual listening. Is it possible to add to the Wave Stats plug-in a calculation that mimics this “density”? Could it be as simple as the average of the rectified waveform? If it can be coded, I’ll test it on a wide range of music to see how it performs as a measure of perceived volume.

I forgot something. In your reply you said to my query about how “density” could be calculated: “Not easily. There are many factors that affect the perceived loudness.”

You may have misunderstood what I meant. I didn’t mean how could perceived loudness be calculated, but how could a measure of the “density” of the waveform – as it appears in Audacity – be calculated so as to put a figure on it.

That’s sort of what the RMS measure is.

It’s interesting that you rated T1, T2, T3 at 3, 4, 2 in each case, even though the amplitudes are considerably different in the first sequence to their amplitudes in the second (and third) sequence.

Note also that a tone at 10 Hz, or at 25 kHz would have a loudness of zero. Although it is possible to feel 10 Hz vibrations, it’s unlikely that your speakers are able to reproduce 10 Hz with any significant power. How “dense” does a 10 Hz, or 25 kHz tone look?

My volume estimates of 3,4,2 were for the tones were not estimates of relative loudness, simply a way for me to indicate whether a sound was louder or softer. So 4 could be ten times as loud as 3 or only 10% louder.

RE “density”, the time scale has to be of a suitable value. I found that about 1 second per centimetre on my screen gave a good indication of how loud the sound would be.

I’ve had an idea about how to measure “loudness”. I’ll try to knock up a demo plug-in in the next week or two, but if you’re still interested and don’t hear from me within two weeks feel free to ‘bump’ this topic (post a reminder).
In the mean time, if you’re interested in doing a bit of reading on the subject, there’s a relevant article on wikipedia:
http://en.wikipedia.org/wiki/Equal-loudness_contour

A quick thought to leave you with:
If someone is talking loudly, it doesn’t really matter that most of the time the audio is at a very low level (gaps between words and sentences), they still sound “loud”.

Thanks for the Wikipedia links. Reading about loudness and the science behind it just leads me to conclude that there is too much regard given to pure tones and noise and not enough regard to real sounds, particularly music and speech.

Loudness is very subjective, of course, and I’ve found that it depends on the “transparency” of the sound (the opposite to "denseness), the amount of unnatural high frequencies, and the setting. Regarding the latter, most older people (those who like their music not too loud), seem to accept quite high volumes at the cinema without complaint, but the same volume at home would send them immediately to the volume control.

As for high-frequency distortion, for example in Pleasant Valley Sunday (Monkees), it is so unpleasant to me that it makes the music seem louder than it probably is. On the other hand, well recorded “transparent” music, such as On Top Of The World (Carpenters), which I regard as one of the best-quality recordings for a pop song, you can keep turning up the volume and it never seems to get to the unpleasant stage.

Without having listened in-depth to a wide variety of music and sounds so as to make a proper judgement, I think that the way Audacity presents its waveforms gives a good indication of perceived loudness. If that is the case, all you have to do is work out how Audacity presents the waveform on screen (at a suitable resolution that gives a good approximation to loudness), and quantify the “denseness”.

What I’m going to do is to round up 5-second snippets of various sounds – classical, popular, speech, TV ads – both good-quality and poor-quality recordings, and generate three sound files in which each snippet is:

  1. Adjusted for the same RMS value;

  2. Adjusted for the same RMS A-weighted values;

  3. Adjusted so the waveform in Audacity looks to have the same loudness.

I’ll probably use a snippet from On Top Of The World as the reference between the different sounds, and then ask people to note whether a particular snippet is softer or louder than the reference. Then I’ll run them through headphones and speakers and ask friends to rate the loudness, using a simple method like the Parson’s code for melodies – louder (L), softer (S), or no change (N).

Once the results are in, that should give a pretty good indication of which is the best method of determining loudness for real-life sounds. It may turn out there isn’t a best method.

<<<Absolutely true - of course the best “measure” for loudness is by listening.
These “complicated calculations” are better than a peak level measurement, but they are still not fantastic.>>>

Which is what Chris did. He kept tweaking and listening until he got it to where he was happy. He did not start with advanced math and work down to the show. He started with the show and worked up to the programming.

There was a company a while back selling a more accurate version of the Fletcher-Munson loudness curves.

http://en.wikipedia.org/wiki/Fletcher–Munson_curves

They didn’t go anywhere, but it points up the idea that simple math doesn’t lend itself to “music,” even when you do all your research by observation.

And yes, the “density” of the waves is the RMS value. The size of the DC battery that has the same energy as the area under the curves. That value and the peak value are the some of the worst indicators of loudness even though they appear like they should work.

Koz