IPB

Welcome Guest ( Log In | Register )

2 Pages V   1 2 >  
Reply to this topicStart new topic
LAME applying 16kHz cutoff at 320K CBR, Is this normal?
PlazzTT
post Oct 4 2009, 12:19
Post #1





Group: Members
Posts: 160
Joined: 17-January 02
Member No.: 1067



I have a recording from cassette tape in FLAC. From the spectral I can see it has frequencies up to 21kHz, but when I encode it to MP3 (V0 or 320K) with LAME, there's a clear cut-off at 16kHz (except for at the very end of the track when there's no music, just tape hiss, there's no cut-off here).

I assume this is normal behaviour, I'd like to know why this happens.

I can post a clip / spectral screenshots if needed.
Go to the top of the page
+Quote Post
Big_Berny
post Oct 4 2009, 12:51
Post #2





Group: Members
Posts: 242
Joined: 9-February 03
Member No.: 4921



I don't know if that's normal. But if you recorded cassette tapes with home equipment the frequency range probably doesn't even go over 16 kHz. So maybe it was just noise over 16 kHz which LAME cut-off?
Go to the top of the page
+Quote Post
lvqcl
post Oct 4 2009, 12:56
Post #3





Group: Developer
Posts: 3433
Joined: 2-December 07
Member No.: 49183



It's sfb21 problem.

QUOTE (2Bdecided)
The issue is simple: sfb21. Due to the compromised design of mp3 (search for sfb21 to read all about it), to maintain much information in the frequencies above 16kHz, you have to over encode all lower frequencies - i.e. store them with greater accuracy than the psychacoustic model believes is necessary [...] and hence the higher the bitrate.


So LAME can decide to discard frequencies above 16 kHz and to spend more bits to more important frequencies.
Go to the top of the page
+Quote Post
PlazzTT
post Oct 4 2009, 13:30
Post #4





Group: Members
Posts: 160
Joined: 17-January 02
Member No.: 1067



Makes sense, thanks. There's no actual music above about 11kHz anyway, just noise.
Go to the top of the page
+Quote Post
Dynamic
post Oct 9 2009, 07:14
Post #5





Group: Members
Posts: 830
Joined: 17-September 06
Member No.: 35307



QUOTE (lvqcl @ Oct 4 2009, 12:56) *
It's sfb21 problem.

QUOTE (2Bdecided)
The issue is simple: sfb21. Due to the compromised design of mp3 (search for sfb21 to read all about it), to maintain much information in the frequencies above 16kHz, you have to over encode all lower frequencies - i.e. store them with greater accuracy than the psychacoustic model believes is necessary [...] and hence the higher the bitrate.


So LAME can decide to discard frequencies above 16 kHz and to spend more bits to more important frequencies.


Sorry to rake up a 5-day-old thread, but I suspect the mechanism cited is wrong.

The OP talked about using -V 0 and CBR 320kbps. The sfb21 problem is worked around at V0 and the extra bits are expended to encode as the psy-model deems necessary. Only at -V 3 and lower quality is the -Y switch used, which in any case doesn't discard high frequencies, it simply encodes them with coarser amplitude resolution. Only if they're below the lowest quantization level available at the time would they then be completed eliminated rather than rounded up or rounded down in amplitude to the nearest available level.

What I think is really happening with this tape is that the psymodel is determining that the very small HF content is fully masked by the music. (ABX experiments over many year confirm that in the presence of real music, a 16kHz lowpass is transparent for most people). When the music stops, it's no longer masked. Also, possibly, the ATH thresholds are lowered in the absence of sound for a reasonable amount of time.
Go to the top of the page
+Quote Post
UVSM
post Oct 9 2009, 10:34
Post #6





Group: Members
Posts: 21
Joined: 8-October 09
Member No.: 73806



Earlier versions Lame 3.93, 3.92, 3.90, 3.88 do not cut frequency on 16kHz. They keep all spectrum of frequencies, up to 22,05 kHz.


This post has been edited by UVSM: Oct 9 2009, 10:49
Go to the top of the page
+Quote Post
UVSM
post Oct 9 2009, 10:40
Post #7





Group: Members
Posts: 21
Joined: 8-October 09
Member No.: 73806



You can try -b320 -q0 -k -m s

This post has been edited by UVSM: Oct 9 2009, 10:52
Go to the top of the page
+Quote Post
odyssey
post Oct 9 2009, 11:42
Post #8





Group: Members
Posts: 2296
Joined: 18-May 03
From: Denmark
Member No.: 6695



You would you want to preserve frequencies you cannot hear anyway? If you want to preserve stuff you don't hear, you should consider a lossless medium instead.


--------------------
Can't wait for a HD-AAC encoder :P
Go to the top of the page
+Quote Post
pdq
post Oct 9 2009, 12:54
Post #9





Group: Members
Posts: 3440
Joined: 1-September 05
From: SE Pennsylvania
Member No.: 24233



QUOTE (UVSM @ Oct 9 2009, 05:40) *
You can try -b320 -q0 -k -m s

I thought -k was disabled in 3.98.2?

And why would anyone choose -m s? This can only compromise quality.
Go to the top of the page
+Quote Post
odyssey
post Oct 9 2009, 13:01
Post #10





Group: Members
Posts: 2296
Joined: 18-May 03
From: Denmark
Member No.: 6695



We've had this discussion countless of times.

Use search.

In short:
1. Don't use parameters for mp3-encodings.
1b. And don't use ancient mp3-encoders.
2. Don't judge audio-quality by looking at spectrograms
3. Use lossless if in doubt

This post has been edited by odyssey: Oct 9 2009, 13:01


--------------------
Can't wait for a HD-AAC encoder :P
Go to the top of the page
+Quote Post
PlazzTT
post Oct 9 2009, 14:53
Post #11





Group: Members
Posts: 160
Joined: 17-January 02
Member No.: 1067



QUOTE (odyssey @ Oct 9 2009, 11:42) *
You would you want to preserve frequencies you cannot hear anyway? If you want to preserve stuff you don't hear, you should consider a lossless medium instead.


I'm not complaining here. I'm not looking for a "workaround" either, just curious what's going on that's all smile.gif
Go to the top of the page
+Quote Post
Rio
post Oct 10 2009, 07:00
Post #12





Group: Members
Posts: 207
Joined: 18-December 06
From: Olongapo
Member No.: 38799



what frontend was used from flac to mp3? what commandline was used for lame and what version? my gutshot here is if the transcode was downsampled to 32kHz then you'll just get a max of 16kHz.


--------------------
"Listen to me...
Never take unsolicited advice..."
Go to the top of the page
+Quote Post
[JAZ]
post Oct 10 2009, 11:32
Post #13





Group: Members
Posts: 1796
Joined: 24-June 02
From: Catalunya(Spain)
Member No.: 2383



QUOTE (Rio @ Oct 10 2009, 08:00) *
my gutshot here is if the transcode was downsampled to 32kHz then you'll just get a max of 16kHz.


QUOTE (PlazzTT @ Oct 4 2009, 13:19) *
[...] there's a clear cut-off at 16kHz (except for at the very end of the track when there's no music, just tape hiss, there's no cut-off here).



Shot failed wink.gif

The most probable reason is psychoacoustics. (coupled with the fact that this is mp3). And the reason why older releases of LAME did not do it is because this is in fact an improvement (getting more bits in other places).

Go to the top of the page
+Quote Post
odyssey
post Oct 10 2009, 12:23
Post #14





Group: Members
Posts: 2296
Joined: 18-May 03
From: Denmark
Member No.: 6695



QUOTE (PlazzTT @ Oct 9 2009, 15:53) *
I'm not complaining here. I'm not looking for a "workaround" either, just curious what's going on that's all smile.gif

It's good to be curious. You wonder why lame throws out frequencies. The reason are simple, as JAZ also mentioned: lame is a LOSSY codec - Meaning that it will try it's best to preserve as much human-audible quality as possible for any given bitrate. Even 320kbit may not be sufficient for certain samples to be encoded without artifacts, so a lowpass to filter out any frequencies you can't hear is a very good reason to give the encoder a better chance of encoding the audible samples with less problems.

Anyone who wants to preserve inaudible frequencies (or sonics or other imaginable things) should use a lossless codec. The advantage of using a lossless codec is that you will have an archive of your music without ANY loss, and can at any time create smaller encodings even when new codecs are released and not worry about re-ripping CD's.


--------------------
Can't wait for a HD-AAC encoder :P
Go to the top of the page
+Quote Post
Rio
post Oct 11 2009, 04:08
Post #15





Group: Members
Posts: 207
Joined: 18-December 06
From: Olongapo
Member No.: 38799



It just also got me curious here. Why did a -V0 or 320 LAME encode filter frequencies above 16kHz? Even if LAME is a lossy codec, this should not be the case. A -V2 encode filters at 18.5kHz, -V0 at 20.5, but this at 16kHz?!

Even if "the more important frequencies" are preserved, it is still mind boggling. Was it really encoded with just "-V0 %s %d" or "-b 320 %s %d"?

Assuming that we don't know the source of the FLAC file (assuming it's not from cassette tape), LAME should still not be behaving this way.

"The most probable reason is psychoacoustics. (coupled with the fact that this is mp3). And the reason why older releases of LAME did not do it is because this is in fact an improvement (getting more bits in other places)."

Much as I strongly agree with [JAZ] regarding psychoacoustics and improvement from previous versions, it still really puzzles me why LAME in this case just got more bits below 16kHz instead of up to 20.5kHz. All of a sudden LAME recognized the audio file as coming from a cassette tape?!


--------------------
"Listen to me...
Never take unsolicited advice..."
Go to the top of the page
+Quote Post
Dynamic
post Oct 11 2009, 18:44
Post #16





Group: Members
Posts: 830
Joined: 17-September 06
Member No.: 35307



QUOTE (Rio @ Oct 11 2009, 04:08) *
Assuming that we don't know the source of the FLAC file (assuming it's not from cassette tape), LAME should still not be behaving this way.

...

Much as I strongly agree with [JAZ] regarding psychoacoustics and improvement from previous versions, it still really puzzles me why LAME in this case just got more bits below 16kHz instead of up to 20.5kHz. All of a sudden LAME recognized the audio file as coming from a cassette tape?!


This is a little lengthy, I'm afraid... We DO know that it's from a cassette tape source, so we can think about that and how LAME may behave in response to a typical digitzed cassette signal when it isn't told that it's from tape or given any special commandline instructions other than -V0 or -b320.

Consider these three points then read on:

(a): Dolby NR may be used to dramatically lower noise level below inherent tape noise and to correct back to the intended EQ of the mastering engineer (i.e. reverse the HF boost applied at manufacturing which enables Dolby NR to be used without dulling the consumer's signal). When making a "correct" cassette transfer Dolby "ought" to be turned on if it was on the original tape (as it would be for nearly any commercial release).

(b): Normal or Chrome Cassette tapes (apart from expensive METAL tapes, perhaps) do not typically support signal content to any more than about 15 or 16 kHz thanks to the tape speed chosen and the size of magnetic domains in those materials, and indeed many players set for normal or chrome or their Dolby circuits may include a low-pass at this frequency to avoid passing additional noise (or bias tones) to people's speakers (esp sensitive tweeters).

: LAME uses both an ATH model (dynamically varying according to the average signal volume, if I recall correctly) and a masking model in its psychoacoustics. MP3 splits the audio into many sub-bands and encodes a scalefactor and a set of DCT transform coefficients in each, and can choose the number of bits (hence quantization noise) for each sub-band, that number of bits being available to each transform coefficient (effectively a coded frequency component) within the subband. The psychoacoustic model's aim is to ensure that for each frequency, the quantization noise introduced by coding more coarsely remains below the masking threshold, and thus inaudible. For any MP3 Frame it may be that some bands contain no signal above the masking threshold (which even may be as low as the ATH or absolute threshold of hearing) in that frequency range and can be completely zeroed, which requires very few bits to encode.

I may be slightly oversimplifying the psychoacoustic model, but I don't think I've made any gross errors that should colour your understanding.

So the overall system we're looking at is something like the following, and will have quite probably feature all three aspects above or at least (b) and if Dolby NR is turned off in the consumer cassette player.

main studio master -> cassette master (Dolby boost & LPF probably applied) -> consumer cassette tape
-> consumer cassette player -> Dolby NR circuit (reverses Dolby boost thereby removing much hiss introduced by the tape material)
-> soundcard ADC to create PCM -> PCM digital audio (encoded as losslessly as FLAC)
-> LAME MP3 encoder -> MP3 file -> PCM lossy audio being played back or analyzed via spectrogram.

We start with a full audio spectrum signal on the studio master with very low noise.

By the end of the first line (consumer cassette tape) we have a reduced signal bandwidth of about 15-16 kHz at most, I'd suggest. In addition to the desired signal we have noise arising from the magnetic materials of the cassette tape.

By the end of the second line Dolby NR circuit output, we have the same 15-16 kHz of signal bandwidth plus some tape noise reduced by the Dolby circuit, plus some broad band noise at a low level from the electrical circuits used.

Essentially the same signal bandwidth, noise bandwidth and noise amplitude will be present in the FLAC file's audio at the end of the third line.

On the fourth line, the LAME encoder will only filter at about 19 or 20kHz, thus preserving the 15-16 kHz signal bandwidth and most of the noise bandwidth before analysis. The resulting MP3 file represents the audio in time frames within which LAME stores what amount to frequency coefficients, quantizing as coarsely as it believes will be inaudible. The coarseness to which it rounds each coefficient, is able to vary across the frequency spectrum by virtue of using sub-bands, each of which can have its own overall gain and bit-depth (which determines the maximum amplitude and relative precision, known as quantization noise). Imagine a coefficient with amplitude of 7, while LAME decides that rounding to the nearest multiple of 32 is acceptable giving the calculated minimum masking level or absolute threshold of hearing in that sub-band. That will round the coefficient down to zero every time. It will still do so if the allowed coarseness reaches 16, but might round up to 8 if the allowed coarseness of quantization is 8, for example.



Looking at spectrogam views of my own tape transfers (from a rather good Walkman WM36 with Dolby B) in years gone by, usually on CoolEdit96 or 2000 (now sold as Adobe Audition), I've noticed some content above 17kHz, but in reality, it's in very dark colours, meaning it's probably 60-80 dB below full scale with a subtle tone at around 19 kHz if I recall correctly, and I don't recall anything like snares or cymbal hits or similar transients spiking above 16kHz at all when I was careful to avoid digital clipping, which is indicative of the low-pass filtering of the intended signal. Most of the hiss I can hear on those Dolby B tape transfers in quiet inter-track sections is surely in the 10-16 kHz range or thereabouts (and probably lower too), and I hear no hiss while reasonably loud music is playing.

If indeed the noise left after Dolby B NR is something like 60-80 dB below full scale, I'd expect any music averaging perhaps -20 dBFS to -14 dBFS to provide enough masking to make all the noise left after Dolby B NR inaudible except for very quiet passages, fade-outs and intentional silences (lead-in/out and inter-track). That's my experience of listening quite carefully to discern noise, including one lightly instrumented duet ballad track mastered intentionally quietly adjacent to a full-on psychedlic rock cover version, which I tried to denoise sensitively, and listened closely to over many repeats.

I'd have thought LAME's excellent psy-model would likely draw roughly the same conclusion about where the noise is audible, and may indeed mark the 16kHz+ sub-bands as containing no audible content (all hiss, since most cassettes have no signal content above 16kHz, only tape noise) during even the quiet passages as well as the loud ones. Only where the intended signal (that on the studio master) is virtually or completely silent, and noise is all that's left, is it likely that there's not enough low-and-mid-frequency content for LAME to be sure that the 16kHz+ sub-band contains nothing above the masking level or ATH level and so will then encode it at non-zero amplitude. This may be partly due to using (by my recollection) a dynamically-varying ATH model, which assumes you might be playing it with more amplification during extended periods of low signal level (which some people will, when trying to discern words or notes in the deep fade out or when using an automatic gain control or a similar DSP like foo_dsp_vlevel with suitably aggressive settings). It may also be due simply to the relatively white noise spectrum, where high frequencies are as prominent as lower frequencies and are those not eliminated entirely by frequency masking effects.

In summary, cassette tape with decent NR is a special case by virtue of both the low noise (but still detectable in 16-bit 44.1kHz PCM) and the restricted signal bandwidth (about 15-16 kHz, say). This may in many cases cause LAME to exhibit just the effects described while behaving exactly as it should in considering human hearing and masking effects without having applied a filter itself. The boundary of the nearest subband to the original signal's low-pass filter may cause the noise to vanish totally and look like a sharp and continuous digital low-pass filter applied by LAME. This apparent effect may then vanish when the genuine signal falls to zero (or to about the same as the noise floor at any rate) and reveal at least some low-level noise content above 16 kHz (however coarsely quantized the 16 kHz+ band might be).

It may be, in fact, that loud transients in the signal (hi-hat, cymbal, snare drum, clicking noises) will show up on the spectrogram as bright vertical lines that actually stop short of the apparent 16kHz cut-off introduced by LAME, thereby indicating that the true musical signal was indeed lowpass-filtered at slightly less than 16 kHz, but within the MP3 sub-band that ends at 16 kHz. A close look at a spectrogram of the original FLACs might reveal this more clearly.

This post has been edited by Dynamic: Oct 11 2009, 18:50
Go to the top of the page
+Quote Post
greynol
post Oct 11 2009, 19:08
Post #17





Group: Super Moderator
Posts: 10241
Joined: 1-April 04
From: San Francisco
Member No.: 13167



QUOTE (Rio @ Oct 10 2009, 20:08) *
It just also got me curious here. Why did a -V0 or 320 LAME encode filter frequencies above 16kHz? Even if LAME is a lossy codec, this should not be the case. A -V2 encode filters at 18.5kHz, -V0 at 20.5, but this at 16kHz?!

Can you ABX a difference? If you can then I think your notion of "should" might carry weight; otherwise...


--------------------
Your eyes cannot hear.
Go to the top of the page
+Quote Post
Rio
post Oct 12 2009, 00:41
Post #18





Group: Members
Posts: 207
Joined: 18-December 06
From: Olongapo
Member No.: 38799



@Dynamic: Thank you for the detailed explanation on cassette tape to MP3. It has become clearer to me when it comes to cassette tape content.

@greynol: I'll ABX if I said "20.5kHz sounds better than 16kHz". Otherwise...


--------------------
"Listen to me...
Never take unsolicited advice..."
Go to the top of the page
+Quote Post
greynol
post Oct 12 2009, 20:24
Post #19





Group: Super Moderator
Posts: 10241
Joined: 1-April 04
From: San Francisco
Member No.: 13167



Your evasion noted; your baseless notion of "should" ignored.


--------------------
Your eyes cannot hear.
Go to the top of the page
+Quote Post
Rio
post Oct 13 2009, 01:23
Post #20





Group: Members
Posts: 207
Joined: 18-December 06
From: Olongapo
Member No.: 38799



When talking about behavior (both the encoder and your personal behavior), there are expectations, therefore the "should" qualifier.

LAME at CBR 320 is expected to filter at 20.5kHz, therefore it "should" filter at
20.5kHz. If it does not, one would think there is something wrong, that's why the OP asked the question, that's why I also asked it.

JAZ and Dynamic was kind and patient enough to enlighten things, while you try to burden by throwing ABX on me.

If I make a quality claim, you expect me that I "should" ABX.

I did not make any quality claims in this thread, ergo expect me that I "should" not ABX.

Therefore, I did not evade. lalala.gif


--------------------
"Listen to me...
Never take unsolicited advice..."
Go to the top of the page
+Quote Post
greynol
post Oct 13 2009, 09:45
Post #21





Group: Super Moderator
Posts: 10241
Joined: 1-April 04
From: San Francisco
Member No.: 13167



QUOTE (Rio @ Oct 12 2009, 17:23) *
LAME at CBR 320 is expected to filter at 20.5kHz

Expected?


--------------------
Your eyes cannot hear.
Go to the top of the page
+Quote Post
odyssey
post Oct 13 2009, 09:50
Post #22





Group: Members
Posts: 2296
Joined: 18-May 03
From: Denmark
Member No.: 6695



Yeah, why would you ever expect a lossy encoder to encode inaudible frequencies? Anyone who expects such thing has miserably misunderstood the concept of lossy encoders.

This post has been edited by odyssey: Oct 13 2009, 09:52


--------------------
Can't wait for a HD-AAC encoder :P
Go to the top of the page
+Quote Post
Rio
post Oct 13 2009, 11:45
Post #23





Group: Members
Posts: 207
Joined: 18-December 06
From: Olongapo
Member No.: 38799



check under the hood while LAME is running... I think it's called polyphase filter...


--------------------
"Listen to me...
Never take unsolicited advice..."
Go to the top of the page
+Quote Post
pdq
post Oct 13 2009, 12:55
Post #24





Group: Members
Posts: 3440
Joined: 1-September 05
From: SE Pennsylvania
Member No.: 24233



Polyphase filter is just the first step in the process. Frequencies that pass the polyphase filter are still not guaranteed to be included.
Go to the top of the page
+Quote Post
PlazzTT
post Oct 13 2009, 14:38
Post #25





Group: Members
Posts: 160
Joined: 17-January 02
Member No.: 1067



Thanks for very interesting answers, I'll upload a small FLAC clip later so you can see what I mean.

(again, I'm not complaining. I can't ABX the LAME encode even at V2, so it's not a problem, some people seem to be interest in the sample though)

This post has been edited by PlazzTT: Oct 13 2009, 14:39
Go to the top of the page
+Quote Post

2 Pages V   1 2 >
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: 20th November 2014 - 22:07