IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
curious about lowpass filters used by LAME
osullic
post Sep 10 2014, 16:47
Post #1





Group: Members
Posts: 11
Joined: 2-April 09
Member No.: 68591



I just have a few questions about how LAME works that I was curious about.

In the Hydrogenaudio Wiki here, there's a table showing lowpass filters applicable to various command-line switches.
I'm just curious why it is a frequency band rather than a fixed frequency value. When I think of a lowpass filter, I think of values below a fixed cutoff value being allowed to pass, and values above the fixed cutoff being filtered out. How does it work when the cutoff is a band rather than a fixed value?

And where do these frequency bands come from? I mean, why have these pairs of values in particular been chosen as the endpoints of each range?

Then, I was also wondering about the lowpass filter used by LAME by default. This varies depending on the target bitrate/quality. I had a look at the LAME source code (which is over my head), but in lame.c I found what appears to be a table mapping default lowpass filters to target bitrates:
CODE
    const band_pass_t freq_map[] = {
        {8, 2000},
        {16, 3700},
        {24, 3900},
        {32, 5500},
        {40, 7000},
        {48, 7500},
        {56, 10000},
        {64, 11000},
        {80, 13500},
        {96, 15100},
        {112, 15600},
        {128, 17000},
        {160, 17500},
        {192, 18600},
        {224, 19400},
        {256, 19700},
        {320, 20500}
    };


Again, I'm just curious how/why these frequencies in particular were chosen for each target bitrate.

Thanks.
Go to the top of the page
+Quote Post
xnor
post Sep 10 2014, 16:53
Post #2





Group: Developer
Posts: 1016
Joined: 29-April 11
From: Austria
Member No.: 90198



I guess these values are based on a trade-off between added noise, artifacts ... and bandwidth.

If you have some easily compressible signal then you should be able to raise the lowpass frequency even at low bitrates.

This post has been edited by xnor: Sep 10 2014, 16:55


--------------------
"we are having an educated and deep technical discussion"-amirm
Go to the top of the page
+Quote Post
2Bdecided
post Sep 10 2014, 17:06
Post #3


ReplayGain developer


Group: Developer
Posts: 5356
Joined: 5-November 01
From: Yorkshire, UK
Member No.: 409



QUOTE (osullic @ Sep 10 2014, 16:47) *
I'm just curious why it is a frequency band rather than a fixed frequency value. When I think of a lowpass filter, I think of values below a fixed cutoff value being allowed to pass, and values above the fixed cutoff being filtered out. How does it work when the cutoff is a band rather than a fixed value?
The 100% perfect cut-off you're imagining implies a filter with a long time-domain response that "rings". If that cut off point is in the audible range (as some of these frequencies are), you can hear the ringing. Literally, it sounds like a bell ringing along with the music at the chosen frequency.

If you soften the filter, so all the sounds below A are preserved, all the frequencies above B are removed, and there's a gradual transition between A and B, then the ringing is reduced. The bigger the gap (wider the transition band) between frequency A and frequency B, the less ringing you have.

QUOTE
And where do these frequency bands come from? I mean, why have these pairs of values in particular been chosen as the endpoints of each range?
The bandwidth vs artefacts trade off is highly subjective: some people prefer wider bandwidth with more artefacts, some people prefer fewer artefacts with narrower bandwidth. At least some of these values come from listening tests which tried to judge the best compromise for most listeners. Many years ago there was a listening test on a now extinct audio forum which found 19.5kHz was a reasonable cut off for very high quality audio. mp3 is a little tricky because it's expensive (in terms of bitrate) to keep frequencies above 16kHz.

No mp3 encoders preserve all frequencies all the time at moderate bitrates on all samples without introducing audible artefacts at lower (more important) frequencies. It's just not possible.

Counter-intuitively, for people with excellent high frequency hearing, it's better to remove all the frequencies above e.g. 16kHz, than to preserver the higher frequencies some of the time if that dynamic keep/dump decision process is flawed (i.e. you can hear the switching). Lame generally doesn't make that mistake (if/when it keeps high frequencies selectively, it selects the moments pretty well so that the switching is inaudible - i.e. it only selectively removes them when they're well and truly inaudible). In contrast, some old encoders are really bad at this.

Cheers,
David.

This post has been edited by 2Bdecided: Sep 10 2014, 17:09
Go to the top of the page
+Quote Post
DVDdoug
post Sep 10 2014, 22:17
Post #4





Group: Members
Posts: 2709
Joined: 24-August 07
From: Silicon Valley
Member No.: 46454



QUOTE
I'm just curious why it is a frequency band rather than a fixed frequency value. When I think of a lowpass filter, I think of values below a fixed cutoff value being allowed to pass...
The MP3 encoder works by analyzing the relative energy in different frequency bands to determine what's audible, and what's masked and can be thrown-away. So, I think the low-pass filtering is related to ignoring the highest bands.

QUOTE
I had a look at the LAME source code (which is over my head),
I've never looked at the source code, but Inside The MP3 CODEC might be a better place to start.
Go to the top of the page
+Quote Post
2Bdecided
post Sep 11 2014, 08:40
Post #5


ReplayGain developer


Group: Developer
Posts: 5356
Joined: 5-November 01
From: Yorkshire, UK
Member No.: 409



QUOTE (DVDdoug @ Sep 10 2014, 22:17) *
QUOTE
I'm just curious why it is a frequency band rather than a fixed frequency value. When I think of a lowpass filter, I think of values below a fixed cutoff value being allowed to pass...
The MP3 encoder works by analyzing the relative energy in different frequency bands to determine what's audible, and what's masked and can be thrown-away. So, I think the low-pass filtering is related to ignoring the highest bands.
No, it's separate. The low pass filter is a simple static low pass filter. The decision to encode (or not) frequency bands based on masking and the absolute threshold of hearing is separate.

Look at a decoded mp3 as a spectrogram and you can usually see both in operation (depending on bitrate, encoder settings, etc).

Cheers,
David.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 18th December 2014 - 12:55