Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: FLAC vs. LZMA - one major difference (Read 10693 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

FLAC vs. LZMA - one major difference

Hello.

Imagine a 22.05 kHz .wav or .aif music file that was upsampled to 44.1 kHz using a non-interpolation method.

Say, the values have changed in that manner:

1 2 3 4 5 6 ...  -->  1 1 2 2 3 3 4 4 5 5 6 6 ...

This way treble is produced out of the lower frequencies, gaining a heights replication that looks somewhat like this:


FFT-display


Windows Media Player

If using this method, LZMA zip will notice the double-values and compress down to somewhat 50% of original size - FLAC won't.



Why? Would be cool if FLAC could detect this and save the data.

Re: FLAC vs. LZMA - one major difference

Reply #1
1. Is there an important reason to upsample the original signal?
If the playback hardware only supports higher samplerates and you use foobar for example you can use a plugin to upsample on the fly. Flac will outperform LZMA in that case like you see in the screenshot.
2. Have you tried different methods like -e -p modes etc. and different blocksizes?

11KHz (22KHz rate) is not suitable for music either. Is this speech recording?

You could consider a lossy compression like Opus. It converts to 48KHz. Even the highest bitrates in Opus are lower than any lossless codec.

Re: FLAC vs. LZMA - one major difference

Reply #2
Thanks for the answer.

Yes, the major reason for upsampling is the gain of treble.

Could you be so friendly to tell me the name of that upsampling plugin for foobar?

>> Have you tried different methods like -e -p modes etc. and different blocksizes?

No. I'm not really firm in those matters. FLAC would have to search for double-values basically all-the-time. Is there a switch for such? I didn't know this was an option, only use FLAC via frontend software.

>> 11KHz (22KHz rate) is not suitable for music either. Is this speech recording?

Well. This depends on what quality you replay your media. Cheap audio equipment might make-up the loss of information. Also, i think FLAC should cover this some way no matter if "music has to be 44k or higher". What if I want to upsample 44 kHz to 88 kHz or higher? Same question then.

>> You could consider a lossy compression like Opus. It converts to 48KHz. Even the highest bitrates in Opus are lower than any lossless codec.

I will give that a try really soon. But what benefit would i make from converting to 48 kHz? This was not part of the topic, i think.

/edit: I checked Opus. It's a lossy codec, only. So it's no option for the topic asked.
The question was why lossless codecs do not cover the double/triple/quadripel/...-value matter when ZIP/LZMA does. Just wondered about the size difference...

Re: FLAC vs. LZMA - one major difference

Reply #3
> Yes, the major reason for upsampling is the gain of treble.
Have you actually listened to your "upsampled" file?

As you can see in your spectrogram images, Doubling values mirrors all the frequencies above Nyquist and causes massive distortion. No upsampler does this and no real upsampling is done this way.

Actual upsampling is a neutral operation, and it's pointless if you don't intend to do anything with the file.

Re: FLAC vs. LZMA - one major difference

Reply #4
Have you actually listened to modern music these days?

And you never experienced traces of simple upsampling in its treble section?

Apart from that again i accept and recognize hydrogenaudio is far above my knowledge. But that experience is not what i came here for.

>> As you can see in your spectrogram images, Doubling values mirrors all the frequencies above Nyquist and causes massive distortion

You can SEE that in the images? Because of the mirror axis??

>> No upsampler does this and no real upsampling is done this way.

Partially yes, it is. I agree, one should use more complex and clever algorithms in professional production, but still, it is. If you want to put it down i will keep an eye open for proofs. I've seen that mirror appearances in the WMP Spectral analyser before, in professional productions.

Again, I agree i's a rather "cheap" way and should be avoided. No offense.


Re: FLAC vs. LZMA - one major difference

Reply #5
Doubling all the samples mirrors frequencies about the old Nyquist rate. You don't need an FFT to see that.

Why are you doing this? If the goal is to generate a fake high frequency extension of a lowpass file, there are plenty of plugins and enhancer plugins that will do a far more convincing job than mirroring the spectrum. 

Re: FLAC vs. LZMA - one major difference

Reply #6
Quote
You don't need an FFT to see that.

Okay. You suppose it, i ask: What do i need to see that?

Quote
Why are you doing this? If the goal is to generate a fake high frequency extension of a lowpass file, there are plenty of plugins and enhancer plugins that will do a far more convincing job than mirroring the spectrum.

Why am i doing this? Two simple words you might know about: the first is J.O.B. but more important the second is called F.U.N.

/edit/

We're planning to set up a little radio station. 10-20 listeners per hour is the goal. Our VST-plugin-based sound setup is producing powerful treble but we found it more aesthetic to cut off the 12 kHz plus frequencies and replace them with that upsampled treble i was talking 'bout. Then, to reduce the distortion, we cut the 15.5 kHz plus freqs and compress to mp3 128k. It sounds better than you might expect, though we did not test on large and expensive equipment yet.

\edit\

It would have been helpful if you recommended at least one filter or a search site for it. You might have noticed i am not into the slang from around here.

"convincing job" ... connvincing for what? If i used those filters i'd bet my ass the 50% compression ratio would be impossible to keep for both flac and zip.

Wy are we talking about how i mix my music rather than why flac is particualary weaker than ZIP ? If the answer is "you're too old fashioned or too dumb to understand flac, which is for the modern smart, only" then my response would be: "fine. I'll take the 60 minutes to write a simple .zip player and the 5 more hours to make it look good."

But honestly I already took 2 hours in this forums. It starts to piss me off that the holy elite here is demonstrating its taste rather than helping or saying "i can't hep" - which would be not to answer.

Sorry if i am rude now, but it seems to me this place is not te friendly helps-ya-out-with-audio place unless you studied 5 years in accoustical physics or something like that.

If it is, just let us believe it with flac not needing to compress anyway it can, rather quick and effective and i guess ...

- assumming the whole file was stretched by factor n is rubbish because it was an old fashioned hardware way not used anymore today (for the non-believers: video games of 10-20 years ago were doing this stretch with their music by default)
- assuming much double values might be found inside a random signal is too optimistic (happens to few).

That could sum it up and we can friendly go our each ways. Have a nice day. (Still, feel free to add something. I meant no serious offense.)

Re: FLAC vs. LZMA - one major difference

Reply #7
Using -e -p really could be interesting. Since you are not even trying to apply it in a way i don't know what you expect!?
Is troll-adiposity coming from feederism?
With 24bit music you can listen to silence much louder!

Re: FLAC vs. LZMA - one major difference

Reply #8
Will give them switches a try.

We asked ourselves whether storing .aif/.wav and converting real-time OR storing .zip OR storing flac would be the way to keep our archive.

What we plan to do:

- apply ordinary sound processing (radio style: few dynamic, high stereo range, quality reduction)
- convert down to 22 or 24 kHz
- reconvert to 44.1 kHz
- apply lowpass filter above 15.5 kHz
- convert to MP3 128k

The source already has the first three steps in it - so the matter was how to store sources best.

The soft and less dynamic treble version is what we want. It makes the listener kind of "distanced" to the sound, but that is what shall differ our sound from the CD versions which are straight "in your ear!" ^^

/edit/

Using -e -p really could be interesting.

I am sorry, it didn't do it. See the results of my console:

Code: [Select]
>flac "44100.wav" -e -p

flac 1.3.1, Copyright (C) 2000-2009  Josh Coalson, 2011-2014  Xiph.Org Foundatio
n
flac comes with ABSOLUTELY NO WARRANTY.  This is free software, and you are
welcome to redistribute it under certain conditions.  Type `flac' for details.

44100.wav: WARNING: skipping unknown chunk 'PAD ' (use --keep-foreign-metadata t
o keep)
44100.wav: wrote 123027425 bytes, ratio=0,866

That 'PAD' stuff should not matter at all.

\edit\
//edit//

Results in comparation:

44100 Hz wav
138.802 KB
flac normal parameters
120.311 KB
flac with parameters -e -p
120.144 KB

\\edit\\


Re: FLAC vs. LZMA - one major difference

Reply #10
Who is "we" so I can know to stay as far away as possible?

We don't play yours rude type of trash music anyway. You won't have to bother to ever hearing it.

BTW would a short sample be legal here? I am not firm with US american or international copyright restrictions. 10 seconds samples would be prepared...

Re: FLAC vs. LZMA - one major difference

Reply #11
Imagine a 22.05 kHz .wav or .aif music file that was upsampled to 44.1 kHz using a non-interpolation method.

Say, the values have changed in that manner:

1 2 3 4 5 6 ...  -->  1 1 2 2 3 3 4 4 5 5 6 6 ...
This is called zero-order hold, a very simple "upsampling" method.

A signal sampled at 44.1 kHz means that information above 22.05 kHz is lost. You cannot restore that information.

Here is what zero-order hold will do in the frequency domain:


In case you have no clue what's going on: the original frequency response was a flat line from 0 Hz - 22.05 kHz.
Just upsampling with zeros (1 2 3 ... -> 1 0 2 0 3 0 ...) mirrors the frequency response around 22.05 kHz. This means a tone at 1 kHz will be mirrored to 44.1-1 = 43.1 kHz.

 Zero-order hold additionally acts as a very poor low-pass filter that will audibly roll-off the frequency response, with nulls at multiples of 22.05 kHz.



If you still don't understand:
Generate a sweep from 100 Hz to 22.05 kHz, then do your 2x upsampling to 88.2 kHz. If you look at the spectrum of that file, you will see energy of the sweep from 100 Hz to 22.05 kHz, but you will see this energy mirrored as a downward sweep from 44 kHz to 22.05 kHz. The frequency response of these sweeps will of course be changes as in my plot above.

Again even simpler: a sweep will turn into two sweeps with what you're doing.


Why is this a horrible idea? You're producing quite some energy in the ultra sound range that could actually damage downstream equipment.
You're also significantly rolling off the frequency response in the audible range. This is especially bad if your sampling rate is lower (relative to 44.1 kHz).


As for samples being legal: read the ToS you have already agreed to during registration.
"I hear it when I see it."

Re: FLAC vs. LZMA - one major difference

Reply #12
This is called zero-order hold, a very simple "upsampling" method.

This is NOT what i did or intended.

I didn't algorithmize 1 2 3 -> 1 0 2 0 3 0 but 1 2 3 -> 1 1 2 2 3 3 and i stated that.
Quote
In case you have no clue what's going on

Please read me exactly before indicating i had no clue of what i did.

Quote
As for samples being legal: read the ToS you have already agreed to during registration.

That was two years ago ... my gosh you guys keep me for a fool... i know it's illegal to share copyrighted material! I asked if it was OKAY, at least that was the intention of it. 10 seconds .... my god, that's as bad as sharing 1000 mp3 files on the web ...

Forget this copyright matter. Forget my question. I will note hydrogenaud.io is filled with wannabe-teachers and so-called experts, professionals, academic... but not of thoughtful men and women.

/edit/ And btw i made no double-blind tests which are the condition to supply samples stated in the ToS. But that was not the topic, as well.
\edit\

Forget me. I'm off.

Re: FLAC vs. LZMA - one major difference

Reply #13
Quote
You don't need an FFT to see that.

Okay. You suppose it, i ask: What do i need to see that?

An FFT will absolutely show it, but this effect is very well known, so most people are aware of it.  If you need to convince yourself, take a look at the FFTs you posted.

Quote
Why are you doing this? If the goal is to generate a fake high frequency extension of a lowpass file, there are plenty of plugins and enhancer plugins that will do a far more convincing job than mirroring the spectrum.

Why am i doing this? Two simple words you might know about: the first is J.O.B. but more important the second is called F.U.N.

/edit/

We're planning to set up a little radio station. 10-20 listeners per hour is the goal. Our VST-plugin-based sound setup is producing powerful treble but we found it more aesthetic to cut off the 12 kHz plus frequencies and replace them with that upsampled treble i was talking 'bout. Then, to reduce the distortion, we cut the 15.5 kHz plus freqs and compress to mp3 128k. It sounds better than you might expect, though we did not test on large and expensive equipment yet.

This is a really bad idea.  The distortion you're hearing is the bass frequencies mirrored to treble, which is probably why you find the need to lowpass out all but 3.5 kHz of the ZOH frequencies.  Usually the way the effect you are describing is done (and you can likely find many VST plugins that will do this) is to take lower frequencies and shift them higher without mirroring.  The reason this works is that if you do it correctly, you reconstruct a lot of the harmonics that were naturally there, whereas with mirroring, they end up at the wrong frequencies, which will sound bad.

The broader question I have though is why you think removing the true treble frequencies in the music is a good idea.  Usually if you want to boost them, you start with what you have and amplify it rather than throwing it away. 


This is called zero-order hold, a very simple "upsampling" method.

This is NOT what i did or intended.

I didn't algorithmize 1 2 3 -> 1 0 2 0 3 0 but 1 2 3 -> 1 1 2 2 3 3 and i stated that.

FWIW, that is exactly what zero order hold is.  If you do 1 2 3 -> 1 1 2 2 3 3 then you are doing zero order hold.  See:

https://en.wikipedia.org/wiki/Zero-order_hold

That was two years ago ... my gosh you guys keep me for a fool... i know it's illegal to share copyrighted material! I asked if it was OKAY, at least that was the intention of it.

FWIW, that link, explains that it would be legal to share those copyrighted clips due to fair use.  You may want to read it after all.

Sorry if i am rude now, but it seems to me this place is not te friendly helps-ya-out-with-audio place unless you studied 5 years in accoustical physics or something like that.

I don't think it is fair to fault other people for being more knowledgeable.  If you don't want help from knowledgeable people, then do not ask for it. 


Re: FLAC vs. LZMA - one major difference

Reply #14
This is NOT what i did or intended.

I didn't algorithmize 1 2 3 -> 1 0 2 0 3 0 but 1 2 3 -> 1 1 2 2 3 3 and i stated that.
You didn't understand my post.
1 2 3 .. -> 1 1 2 2 3 3 ... is called zero-order hold.
I have explained this very clearly.


Please read me exactly before indicating i had no clue of what i did.
I perfectly understood you, but you didn't. I was trying to educate you on the basics of digital audio. A lot of people don't understand them or don't know how to interpret such plots.


That was two years ago ... my gosh you guys keep me for a fool... i know it's illegal to share copyrighted material! I asked if it was OKAY, at least that was the intention of it. 10 seconds .... my god, that's as bad as sharing 1000 mp3 files on the web ...
Are you mad?
The ToS allows you to share samples. You again did not read...  Why do you think I posted a link to the ToS?


Forget this copyright matter. Forget my question. I will note hydrogenaud.io is filled with wannabe-teachers and so-called experts, professionals, academic... but not of thoughtful men and women.

/edit/ And btw i made no double-blind tests which are the condition to supply samples stated in the ToS. But that was not the topic, as well.
\edit\

Forget me. I'm off.
I will, but if you ever come back I expect an apology.
"I hear it when I see it."

Re: FLAC vs. LZMA - one major difference

Reply #15
Well.... That escalated quickly ;-)

For me, this resampling in a binary way was interesting to read, even though I know how this works. You took the time and effort to explain in every way possible.

Maybe he expected an approval from you instead of a link to the TOS.

Re: FLAC vs. LZMA - one major difference

Reply #16
Indeed it did.
But i will say in this case Nash got very negative as soon as people where trying to technically explain to him what was going on.
But it really lost the chain was when a certain moderator once again comes in to beat people over the head, when they are searching for knowledge. It has been the trend with this moderator for at the last couple of newcomers that are posting.

Looking at how slow hydrogen audio is going on these days compare to its prime years i really don't believe that's is the proper way to handle things.

I joined HA  back in the days because it was a place of enlightenment and knowledge.  now its seems more like a religious crusade where  people with less technical knowledge are crucified rather than explained why they are wrong.

Comments like "Who is "we" so I can know to stay as far away as possible?" has no progression value what so ever as it adds no knowledge or information into the debate and only serves to degrade other people.
And this is from a moderator... thats it just shamefull in my eyes.

I think certain HA staff members need to reevaluate what HA has of purpose.
Sven Bent - Denmark

Re: FLAC vs. LZMA - one major difference

Reply #17
But it really lost the chain was when a certain moderator once again comes in to beat people over the head, when they are searching for knowledge. It has been the trend with this moderator for at the last couple of newcomers that are posting.
I disagree. This "certain moderator" does not appear to have made much difference in this thread. I am confident that it would have taken the same course without him.

And how do you know nhash was seeking knowledge? He didn't seem capable of handling it once it was coming.

Quote
Looking at how slow hydrogen audio is going on these days compare to its prime years i really don't believe that's is the proper way to handle things.
I don't see much fault here. I am all for having some patience with newbies, but if they are outing themselves as pompous and short-fused ignoramuses, there is no point in making it comfortable for them. Their departure will not leave HA worse off.

Re: FLAC vs. LZMA - one major difference

Reply #18
I was being dead serious. If there are companies out there who honestly believe this is a competent way to process and deliver a product, I'd like to know who they are so that I know not to waste my time and money on them.

Re: FLAC vs. LZMA - one major difference

Reply #19
But i will say in this case Nash got very negative as soon as people where trying to technically explain to him what was going on.

He was actually still reading after greynol's post, but as soon as he saw the wikipedia link to what he thought was his idea, he lost interest in the discussion.  I suspect he believed his zero order hold interpolator was a new, revolutionary idea for audio processing, which is why he got extremely defensive/agitated when xnor told him that it was already a well-known concept. 

Re: FLAC vs. LZMA - one major difference

Reply #20
Well, the main thing I like about HA is that there is a strict non bullshit rule. This can sometimes be a pain in the ass when it comes to opinions, but it's better than without.

On other forums people claim the most ridiculous stuff. If I go there and claim the sound gets better when you apply milk and honey to the speaker cables there will be people that seriously consider that. Could be a chance that THEY in turn will claim which honey is the best for a smooth and open sound.

I like the more practical approach, thats why I play from my laptop with Foobar (eeeuw..) via Wifi (Ugh) to my Raspberry PI > Hifiberry > DAC > AMP. Those people will then cry about horrendous jitter. Well. there isn't anything :) (Oops, did I just make a claim there).

Smooth ice sometimes

Re: FLAC vs. LZMA - one major difference

Reply #21
Could you be so friendly to tell me the name of that upsampling plugin for foobar?
http://www.foobar2000.org/components/view/foo_dsp_multiresampler
but...
I will note hydrogenaud.io is filled with wannabe-teachers and so-called experts, professionals, academic... but not of thoughtful men and women.
The plugin is created by an HA admin, do you still want to use it?

Re: FLAC vs. LZMA - one major difference

Reply #22
I do not endorse it as an HA admin, but merely as a tinkerer. It was created to show off my low latency resampler. It was never meant to be used seriously if you're after speed and quality at the same time. For that, I endorse the SoX resampler component, as it uses a high quality and also fast library, and was not designed for extremely low latency with support for varying pitches.

The Speex resampler may also be a good choice, but I'm not sure how well it handles low latency with varying pitches, as it was designed for a steady stream, while my resampler was designed for use in synthesizers.


Re: FLAC vs. LZMA - one major difference

Reply #24
I'm sorry, was your issue ever fixed by either BASSMIDI (possibly not my version) or by XMPlay's MIDI plug-in?