Tips, Techniques, Examples about my favorite musical instrument, the Twelve-String Guitar.

If you play guitar check out Playing Technique, or Strings / Setup. There are also some interesting posts about guitars at, you guessed it, Guitars.

If you want to spread your musical talents around, you will find some good info at Recording.

Marketing - meh - I'm probably the world's best bad example. Although you could find funny stuff there.

I've made some music videos through the years, and you can find them and other interesting music at Music I Like, Music I Play.

Saturday, February 24, 2007

ogg vorbis encoding

I find it difficult to record the sound of any of my 12-string guitars...more difficult than getting an accurate reproduction of a nylon string classical or a 6 string steel guitar. It seems to be a more complex sound and the complexity that sounds so nice when you are playing is not reproduced. And when I want to share a recorded sound that I think comes close, compressing it into mp3 is like the final nail in the coffin.

Encoding is the process of converting the uncompressed audio file into something that won't take a lot of resources to email, download, or play. If you record at 16 / 44 (16 bit words, 44,100 samples per second) your file will be about 10 megabytes for each minute of sound. Your friends won't like clicking on your music when it takes minutes, or even hours for dial-ups, to download. Encoding into compressed file formats shrinks the file size without doing too much damage to the music. Mp3 has been the primary method, and it is used by almost everyone. However it is protected by a patent, and no one is even sure who owns the patent. Microsoft incorporated the algorithm in Windows Media Player, and negotiated the rights with a company they thought held the patent, but a court said they were wrong - please pay 1.4 billion dollars. Ouch!

Enter Ogg Vorbis

This odd name describes an open source compression scheme. To test it, I did pretty much the same thing as when I compared mp3 compression rates - inverted each compressed file and created a spectrum chart of the difference, that is, the sound that was in the original but not in the compressed file. The picture at the very top shows the spectrum of the 9 second snippet of twelve-string music. Pictured below are the differences of various ogg files, from the highest quality compression (quality = 10), to the default (quality = 3):

Encoding at the default (quality = 3) results in a file size nearly identical to a constant 128 bit rate mp3, which is used as default in SoundClick, the online service I use. Visually, the quality of the ogg file seems better, and you can compare the audio below. I'm using lame to encode.

The following spectrums compare mp3 and ogg set to constant bit rate (I set average, minimum, and maximum rates to 256). This may not be the best way to encode a constant rate ogg file. I only show this for academic purpose. If you are going to use ogg you should probably use the default variable bit rate encoding that you automatically get simply by setting the 'q' parameter to something from one to ten.

In file size comparisons, ogg holds its own, coming in slightly smaller for all apples to apples comparisons:
mp3 128 bit constant - 224,861
ogg vorbis quality 3 - 223,280 quality 5 - 317,585
quality 7 - 445,945
quality 10 - 809,254

Here's the size comparison between mp3 constant bit rate 256 and ogg 256 (I chose parameters for average bit rate, minimum and maximum bitrates all set to 256):
ogg vorbis -b 256 -m 256 -M 256 - 457,072
lame -c -b 256 - 449,723

But Use Your Ears

Pictures are nice, but ears always have the final word. Here are the audio files:
Original wav file (2,465,836 bytes)
oggenc -q 3 (223,280 bytes)
oggenc -q 5 (317,585 bytes)
oggenc -q 7 (445,945 bytes)
oggenc -q 10 (809,254 bytes)
oggenc -b 256 -m 256 -M 256 (457,072 bytes)
lame -c -b 128 (224,861 bytes)
lame -c -b 256 (449,723 bytes)

So far these tests use a raw recording - I didn't do any equalization or reverb. I've noticed that added reverb to a 12-string guitar and encoding at lower bit rates just sounds horrible. This is unfortunate, because I use a close mic'ed setup and would like to add a wee bit of 'roominess' to the sound. In a post to come soon, I will try adding some tasteful reverb and comparing default ogg (quality = 3) to lame at 128 kbit rate.

Since I wrote this, I found this site that has a huge amount of information about mp3's. There are apparently big differences in quality among the various encoders. However, as of 2002, when the site was last updated, Lame was preferred for 128 constant bit rate. Lame has been under development since then, so I expect that even now it would be preferred. I also learned that the best parameters to use for 128 CBR is a built-in preset: --preset cbr 128. It fine tunes the encoder to lessen ringing problems, so this may be why reverb sounds bad. I will try this preset in my verb tests.

Note: Wave diagrams from Audacity.

No comments:

Post a Comment