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: Dense newbie question about LossyWAV (Read 11336 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Dense newbie question about LossyWAV

I read the wiki and several threads here, but I'm still not clear on the following two questions:

1.  If LossyWAV is not lossless, what exactly is lost?
2.  How does the audio signal produced by LossyWav differ from the original audio signal?

Sorry for my poor English, I'm a product of the U.S. education system.

Thanks!

Dense newbie question about LossyWAV

Reply #1
Hi there,

1) lossyWAV exploits a feature of FLAC, Wavpack, TAK and some other lossless codecs whereby the signal is encoded more efficiently when one (or more) lower significant bits (LSBs) are *always* zero for a particular block of audio being processed. What lossyWAV does is to add (an acceptable level of) noise to the signal by rounding to a calculated number of LSBs (i.e. bits-to-remove) for the audio block in question (which will be affected dependent on quality setting). This is dynamic and can change from block to block. The added noise caused by rounding off a number of LSBs is pre-calculated and the number of bits-to-remove is determined by an algorithm which includes the use of FFT analyses of at least two lengths (5msec and 20msec by default for 44.1kHz audio).

2) The difference is merely the rounding error for the number of bits removed for each codec-block.

The analysis is channel independent and different numbers of bits-to-remove can be removed from each channel.

[edit] Clarity. [/edit]
lossyWAV -q X -a 4 -s h -A --feedback 2 --limit 15848 --scale 0.5 | FLAC -5 -e -p -b 512 -P=4096 -S- (having set foobar to output 24-bit PCM; scaling by 0.5 gives the ANS headroom to work)

Dense newbie question about LossyWAV

Reply #2
It kinda looks like this:

Dense newbie question about LossyWAV

Reply #3
A slightly less technical explanation, possibly inaccurate (someone correct me if it is): All that's being lost are the bits that provide the lowest-amplitude (quietest) variations in the signal. Strategically zeroing those bits makes the quietest sounds (already probably masked by the loud sounds) be totally silent. Having all n LSBs zeroed in every sample in a block (1 block = 4096 samples by default, in FLAC) results in a huge space savings in that block, because of the way FLAC happens to handle that kind of signal. There's no need for the codec to store data for reconstructing 16-bit samples if the lowest n bits are all zero; it can instead just deal with 16-minus-n-bit samples, and then shift them after decoding. (Well, that's in effect; I don't pretend to know what actually goes on in the encoder). n will vary from block to block depending on how much noise/inaccuracy would be introduced by zeroing more bits. The goal is to zero as many as possible while keeping the imprecision below an audible threshold, the standard target being the signal's noise floor. For most music you're not going to be losing any musical signal. I'm curious to know if anyone has actually found any ABX-able examples yet.

 

Dense newbie question about LossyWAV

Reply #4
So how different would the reconstructed LossyWAV file look from the original?

Dense newbie question about LossyWAV

Reply #5
So how different would the reconstructed LossyWAV file look from the original?

Do you listen with your eyes?  0.5% different, 5% different, 50% different...who cares, as long as the difference isn't audible?

Dense newbie question about LossyWAV

Reply #6
Just curious how close the reconstructed signal is to the original.

Dense newbie question about LossyWAV

Reply #7
Try processing a file and use the --correction parameter. This will produce two files - the processed audio and a correction file that can be reintegated with the processed audio to recreate the original. Have a look at the correction file to get a feel for the difference between the original and the processed audio.
lossyWAV -q X -a 4 -s h -A --feedback 2 --limit 15848 --scale 0.5 | FLAC -5 -e -p -b 512 -P=4096 -S- (having set foobar to output 24-bit PCM; scaling by 0.5 gives the ANS headroom to work)

Dense newbie question about LossyWAV

Reply #8
There isn't a "reconstructed signal," the result of LossyWAV processing is uncompressed audio, just like the input.

LossyWAV adds white noise to the audio, the amount of noise depending on how much the program calculates it can add without being audible (the threshold being adjustable via the quality setting.)

Dense newbie question about LossyWAV

Reply #9
Toldja I was dense.  But I think I understand better now.  Thanks everybody!

Dense newbie question about LossyWAV

Reply #10
Let's see if this explanation is easier to understand:

The output of lossywav is the same signal as input, plus some dynamically added noise. As if lossywav controlled a volume knob which inputs noise, and decided to add more or less noise depending on the analisys it does (the analisys is done each 512 samples, which is around 10 milliseconds).

I recommend you to encode something at the minimum quality settings of losssywav ( -q 0 , or even -q -2 (minus 2)), and listen to the original and the output. In some cases it is possible that you won't hear the difference even in this extreme setting. You will simply hear more background noise.


The technical details are that it isn't really adding (white) noise, but reducing the bit width precision of the signal and doing noise shaping to reduce the effects of quantization distortion. The reason it does it this way, like Nick mentioned, is to exploit the features of some lossless codecs that can encode this type of signals with a lower bitrate.


A slightly less technical explanation, possibly inaccurate (someone correct me if it is)


Well.. yes.. it's innacurate. It can lead to think that it removes sounds depending on its amplitude.
Also, 1 FLAC block is 4096 at -8, but lossywav uses smaller blocks. That's why increasing from flac -5 to flac -8 doesn't help much with lossywav signals.

Dense newbie question about LossyWAV

Reply #11
Seems a bit odd to name an algorithm after a container format—using such logic, µ-law might also be called lossyWAV. 'Block Precision Formatting' or somesuch might be a better name.

Dense newbie question about LossyWAV

Reply #12
In retrospect, it may have been better to use a name such as lossyPCM. However as lossyWAV was first released a little over three years ago it's a bit too late to change the name....
lossyWAV -q X -a 4 -s h -A --feedback 2 --limit 15848 --scale 0.5 | FLAC -5 -e -p -b 512 -P=4096 -S- (having set foobar to output 24-bit PCM; scaling by 0.5 gives the ANS headroom to work)

Dense newbie question about LossyWAV

Reply #13
After all, it's *.lossy.wav 

Dense newbie question about LossyWAV

Reply #14
A slightly less technical explanation [...] Strategically zeroing those bits makes the quietest sounds (already probably masked by the loud sounds) be totally silent.

I'm really no expert, but I don't think this is correct. It has nothing to do with silent sounds or loud sounds. Your explanation suggests, that a file which is loud from beginning to end without any silent parts, would not benefit from lossyWAV which AFAIK is not the case. Rather than affecting the amplitude or "quiet sounds" I *think* what happens is that with lossyWAV you lose a little bit of precision (LSBs) which results in an (allegedly) tiny amount of added noise. During this process it might happen that "almost silence" is changed to "absolute silence", but if that is the case I think this is only a side benefit and not the core idea of lossyWAV. Corrections welcome.

Seems a bit odd to name an algorithm after a container format—using such logic, µ-law might also be called lossyWAV.

+1

Dense newbie question about LossyWAV

Reply #15
A slightly less technical explanation [...] Strategically zeroing those bits makes the quietest sounds (already probably masked by the loud sounds) be totally silent.

I'm really no expert, but I don't think this is correct. It has nothing to do with silent sounds or loud sounds. Your explanation suggests, that a file which is loud from beginning to end without any silent parts, would not benefit from lossyWAV which AFAIK is not the case. Rather than affecting the amplitude or "quiet sounds" I *think* what happens is that with lossyWAV you lose a little bit of precision (LSBs) which results in an (allegedly) tiny amount of added noise.

That's absolutely correct.
Quote
During this process it might happen that "almost silence" is changed to "absolute silence", but if that is the case I think this is only a side benefit and not the core idea of lossyWAV. Corrections welcome.

That won't happen, removing bits will always add noise, as you've said above. However, lossyWAV will treat "almost silence" very carefully and probably keep most of the bits, because when there is no louder signal to mask the added noise, it's more likely that you will notice it.

Dense newbie question about LossyWAV

Reply #16
By quietest sounds, I didn't mean quiet passages in the music, but rather just the tiny variations in amplitude provided by the LSBs. But you're right, it's not the best analogy.

Dense newbie question about LossyWAV

Reply #17
By quietest sounds, I didn't mean quiet passages in the music, but rather just the tiny variations in amplitude provided by the LSBs.

That still holds a misconception: by removing the "tiny variations" within the LSBs, you'll always add noise. Bear in mind that a given frequency component consists of hundreds or thousands of samples, so you can't draw any conclusion by looking at a single sample.

Dense newbie question about LossyWAV

Reply #18
By quietest sounds, I didn't mean quiet passages in the music, but rather just the tiny variations in amplitude provided by the LSBs. But you're right, it's not the best analogy.


Yeah but it can't make them silent, it'll just make them noisier.

Dense newbie question about LossyWAV

Reply #19
Thanks for correcting my mistaken simplifications, guys. I am not too proud to admit I was wrong. I was wrong.