HydrogenAudio

Lossless Audio Compression => Lossless / Other Codecs => Topic started by: thebombzen on 2014-01-09 23:42:32

Title: Different Genre Compression Ratios - Why Is Softer Better?
Post by: thebombzen on 2014-01-09 23:42:32
I'm pretty sure this has been discussed before, but different genres of music I have consistently compress better or worse than other genres, across a variety of codecs. Softer music in general compresses much better than harder music, on spectrum of piano on the soft end and metal on the hard end. I tried three different codecs (FLAC, wavpack, and Monkey's Audio), three genres (voice and a piano, soft rock, metal), and four samples per genre. I started with a bunch of wav files in my directory and ran the following commands (note that MAC is through wine):

Code: [Select]
flac -8 *.wav
wavpack -h *.wav
for i in *.wav; do MAC "$i" "$(basename "$i" .wav).ape" -c5000; done

To print the ratios, I ran
Code: [Select]
for type in {flac,ape,wv}; do for i in *.$type; do echo "$i" $(echo "scale=3;" "$(du -b "$i" | head -c 8 | xargs)" "/" "$(du -b "$(basename "$i" .$type ).wav" | head -c 8 | xargs)" | bc); done; done


Try it yourself, it prints the ratios of the files, as long as you kept the wav files.

I noticed that every time, the voice and piano stuff compressed in the 0.3 range, the soft rock compressed in the 0.5 and 0.6 range, and heavy metal compressed in 0.7 and 0.8 range. I've noticed this as a general rule with FLACs in my collection, so I decided to make my test more scientific. However, it seems that even with the same artist, if the song is softer, it compresses better. Look at a very versatile band: Pink Floyd. Let's see how some softer songs compress versus harder songs:

Code: [Select]
Vera.flac .417
Empty Spaces.flac .436
Echoes.flac .467
Atom Heart Mother Suite.flac .506
Set the Controls for the Heart of the Sun.flac .508
Eclipse.flac .519
Wearing The Inside Out.flac .531
Wish You Were Here.flac .532
Another Brick in the Wall, Part 2.flac .546
In The Flesh.flac .547
Waiting For The Worms.flac .557
Brain Damage.flac .576
Have a Cigar.flac .583
What Do You Want From Me.flac .642


Everything from "Wish You Were Here" upward is softer and everything from "Another Brick in the Wall, Part 2" downward is harder. "What Do You Want From Me" has a ratio far above everything else and it's one of Pink Floyd's harder songs. Same goes for "Have a Cigar." "Echoes," "Empty Spaces" and "Vera" are definitely on the softer side. The notable exceptions are "Brain Damage" and "Eclipse" which look like they should be swapped, but no heuristic argument works 100 percent of the time.

So, it's clear that softer songs compress better, but why is this? Can someone give me an objective explanation?
Title: Different Genre Compression Ratios - Why Is Softer Better?
Post by: saratoga on 2014-01-09 23:44:30
Lots of zeros mean good compression.
Title: Different Genre Compression Ratios - Why Is Softer Better?
Post by: BFG on 2014-01-10 04:34:19
Simply put, softer music generally has less digital information than harder music.  Thus it's easier to compress more tightly.
Title: Different Genre Compression Ratios - Why Is Softer Better?
Post by: mjb2006 on 2014-01-10 05:47:22
When it's LPCM encoded (WAV/AIFF), the audio data takes up a specific amount of space per unit of play timeā€”no more, no less. But when it's FLAC or MPEG encoded, the data for quiet, tonal music is less complex, so it compresses more compactly, and it may also just naturally take up less space than the audio data for loud, noisy music (noise & noise-like signal being distortion, snare hits, reverb, background hiss, etc.). Different compression codecs work in different ways, but they are similar in this regard; just bringing the volume down can improve compression. Also, the closer to mono it is, the less space it needs.