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: lossyWAV 1.3.0 Development Thread (Read 201083 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

lossyWAV 1.3.0 Development Thread

Reply #200
The audio above the upper limit used to determine the low points in the frequency spectrum is still processed but does not influence the calculation of bits-to-remove from each coded block.
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)

lossyWAV 1.3.0 Development Thread

Reply #201
Is --limit then meant as a kind of psy trick since we don't hear HF very well?
I remember there was a parameter which made LossyWav remove bits more from HF. It was then dropped (I can't find the name of it). Is there something similar in recent versions? Also would LossyWav benefit from checking bits-to-remove against ATH curve? Thanks

lossyWAV 1.3.0 Development Thread

Reply #202
--limit isn't a psy trick, it's just the frequency limit for the energy analysis (searching the frequency area with lowest energy - the lowest energy found is used to determine the number of bits to remove).
There must be such an analysis limit because in the extreme HF area chance is very high to find a frequency area with very low energy making bits to remove zero or close to zero for no good reason.

--limit is 16 kHz by default when not using -t, when using -t it's a tiny bit lower (roughly 15.3 kHz).

--limit has nothing to do with frequency range, --limit is kind of a short name for --analysislimit.
lame3995o -Q1.7 --lowpass 17

lossyWAV 1.3.0 Development Thread

Reply #203
--limit isn't a psy trick, it's just the frequency limit for the energy analysis (searching the frequency area with lowest energy - the lowest energy found is used to determine the number of bits to remove).
There must be such an analysis limit because in the extreme HF area chance is very high to find a frequency area with very low energy making bits to remove zero or close to zero for no good reason.


So --limit exist because ultimately in the extreme HF area, like 20kHz, music is very faint or non-existent and LossyWav has to go for the lowest common denominator in frequency spectrum (i.e. local noise floor). Is this correct?

The audio above the upper limit ... does not influence the calculation of bits-to-remove from each coded block.

so for frequencies above --limit, which are HF and less audible, LossyWav can 'zero' too many bits from a high energy HF part, because it has no way of knowing about it?

lossyWAV 1.3.0 Development Thread

Reply #204
1) Yes, limit exists because there is no point in limiting the bits-to-remove by taking into account audio that you cannot* hear;

2) Yes, because the calculation disregards the portion of the frequency spectrum between the (upper-calculation-)limit frequency and Nyquist, more loss will probably occur in the high frequencies than if they had been taken into account during the calculation of the lowest energy portion of the spectrum.

* Unless you have exceptional hearing, are young or are a bat / dog / etc.
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)

lossyWAV 1.3.0 Development Thread

Reply #205
Thanks Nick.
Quote
2) Yes, because the calculation disregards the portion of the frequency spectrum between the (upper-calculation-)limit frequency and Nyquist, more loss will probably occur in the high frequencies than if they had been taken into account during the calculation of the lowest energy portion of the spectrum.

So in effect --limit it is a kind of psy trick too. You agree? Would it not be better by design then if LossyWav checked audibility of noise floor against ATH? If current noise floor is below what we can hear anyway then Lossywav can be more aggressive/efficient. Maybe then --limit would not be needed because many HF parts would be disregarded by this. Sorry if this sounds dumb.
Also when LossyWav 'zeroes' bits can it also 'one' bits in block?  Lossywav could check which (zero-ing or one-ing) better fits for this block and achieve better compression, or alternatively, modify less bits. Again, sorry if this is nonsense.

lossyWAV 1.3.0 Development Thread

Reply #206
If by psy trick you mean "ignore what you (probably) can't hear" then yes.

There is no real psy-model as such in lossyWAV.

The bit removal process at its simplest rounds off LSBs. Next, there is fixed noise shaping (optimised for 44.1kHz and 48kHz using SebastianG's filter coefficients) - this uses the round off values and noise-shapes the output. Finally there is adaptive noise shaping (in beta) which uses SebastianG's frequency warped method to "hide" the added noise behind the signal itself, again using the round off values as primary input.

I don't know if making the LSBs all ones would work - I'll try it and see what happens.
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)

lossyWAV 1.3.0 Development Thread

Reply #207
If by psy trick you mean "ignore what you (probably) can't hear" then yes.

yes , exactly

Quote
There is no real psy-model as such in lossyWAV.

I know but i don't like --limit in place of it.

Quote
The bit removal process at its simplest rounds off LSBs. Next, there is fixed noise shaping (optimised for 44.1kHz and 48kHz using SebastianG's filter coefficients) - this uses the round off values and noise-shapes the output. Finally there is adaptive noise shaping (in beta) which uses SebastianG's frequency warped method to "hide" the added noise behind the signal itself, again using the round off values as primary input.

I'd need to read up on what noise shaping does and why is it important. Now I don't get the point of it.

Quote
I don't know if making the LSBs all ones would work - I'll try it and see what happens.

Great! Happy I was able to contribute an idea. Theoretically in (nearly) 50% of cases one-ing LSBs would be better. AFAIK, FLAC and others code each block separately so 0/1 decision should be on block-basis then.

lossyWAV 1.3.0 Development Thread

Reply #208
If you don't like --limit then use --limit 20000.

I will not remove it - I have no interest in ultrasonic content.
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)

lossyWAV 1.3.0 Development Thread

Reply #209
If you don't like --limit then use --limit 20000.

I will not remove it - I have no interest in ultrasonic content.

No, sorry I did not intend to sound negative. I am totally amazed by your persistent work on improving Lossywav. I would welcome a replacement for --limit, that is all. Unless there is one, it has to do. Lossywav has to cut corners somewhere and it's better if it does in it HF. That is why I asked in a previous post about this parameter that shifted noise to HF.

lossyWAV 1.3.0 Development Thread

Reply #210
There may be some confusion - at one time I misnamed a pair of parameters as --lowpass / --highpass when they should have been named --lowlimit and --highlimit or something like that, as they were parameters to set the lower and upper frequency limits of the calculation to find the lowest energy portion of the spectrum.

It occurs to me that the fixed noise shaping method used in lossyWAV shifts the added noise into the high frequency portion of the output - maybe that is what you are remembering.
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)

lossyWAV 1.3.0 Development Thread

Reply #211
It occurs to me that the fixed noise shaping method used in lossyWAV shifts the added noise into the high frequency portion of the output - maybe that is what you are remembering.

Probably that's the one:) Thanks for all the help with explaining.

lossyWAV 1.3.0 Development Thread

Reply #212
I don't know if making the LSBs all ones would work - I'll try it and see what happens.

Since that is only one LSB different from making them all zero, I don't see the point.

If, OTOH, you could make them all the same value within a block, and select the value that minimized the added noise, then that would be worthwhile.

lossyWAV 1.3.0 Development Thread

Reply #213
If, OTOH, you could make them all the same value within a block, and select the value that minimized the added noise, then that would be worthwhile.

That was the idea. If the situation is like this:

1 0 1 1
0 1 0 1
1 1 0 0
1 0 1 1
0 1 1 0
1 1 1 1
1 1 0 1
0 1 0 1

Then '0's marked in red would be better replaced by '1's

lossyWAV 1.3.0 Development Thread

Reply #214
Would it not be better by design then if LossyWav checked audibility of noise floor against ATH?
It's a possible development, and it sounds like it should help, but might not in reality...

Firstly, decent lossy codecs have a floating ATH that adapts to the loudness of the signal. Lame didn't use to, but has done for a while. Without it, encoding a quiet track and then turning it up reveals coding artefacts. So, if you use ATH data, you have to tie it in some way to the incoming audio signal. That's another thing to tune.

Secondly, lossyWAV doesn't usually have audible artefacts at very high frequencies, even when you force it to add more noise. If you make it go wrong, the audible problems are usually at mid-frequencies. Sometimes an ATH model will add less noise than the simple hard limit, sometimes more. If what's there already is transparent, then adding less noise is pointless. If what's there already is transparent, then adding more noise is risky.

So, it could be done - and if ever lossyWAV had a psychoacoustic model it probably should be done. But a simple cut-off serves quite well.

You can't have no cut off - if you analyse everything out to 22.05kHz, you'll find lots of CDs have a very low noise floor above 20kHz, and lossyWAV wouldn't touch these at all.

Cheers,
David.

lossyWAV 1.3.0 Development Thread

Reply #215
If, OTOH, you could make them all the same value within a block, and select the value that minimized the added noise, then that would be worthwhile.
Over 512 samples it's hard to see it could make a noticeable difference except in exceptional circumstances.

The LSBs that are thrown away are essentially random. Simplistically, if they weren't, they wouldn't be being thrown away.

(That is simplistic - it's easy to create or manipulate a signal so that they're not random at all but will all be thrown away - but not so easy to record such a signal with a microphone!).

Cheers,
David.

lossyWAV 1.3.0 Development Thread

Reply #216
I am so impressed by how -q -2 -t -A 96 sounds and even when I change it to -q 0. What does the -t and -A 96 switches do? If I have 24 bit files that I would like to use, should I change any parameter? Regards

lossyWAV 1.3.0 Development Thread

Reply #217
Glad you're enjoying it. Using -q 0 instead of -q -2 in that set of parameters will increase quality a bit. No additional commands are required for 24bit.

[edit] -A 96 enables adaptive noise shaping using a 96 tap FIR filter; -t enables alternative internal presets. [/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)

lossyWAV 1.3.0 Development Thread

Reply #218
[edit]-A 96 enables adaptive noise shaping using a 96 tap FIR filter;[/edit]

Oh ok, so the original LossyWav already implements ANS. Well, I hope you don't mind that I experimented a little on my own w.r.t. ANS.

Cheers and a happy and productive new year!
SG

lossyWAV 1.3.0 Development Thread

Reply #219
No problems Sebastian - I am intrigued by your "simple psychoacoustic model" though....
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)

 

lossyWAV 1.3.0 Development Thread

Reply #220
No problems Sebastian - I am intrigued by your "simple psychoacoustic model" though....

I simply compute the average power spectral density of the signal for each of 64 non-uniformly placed subbands with bandwidths ranging from 100 Hz (lower bands) to 1 kHz (higher bands). The levels are in dB relative to the level of noise from a rectangular dither (+/- 1/2 LSB). From these 64 levels I compute tolerable noise levels by subtracting a frequency-dependent signal-to-noise ratio. (Currently 42 dB for frequencies below 500 Hz and 12 dB for frequencies above 4 kHz). These SNRs can be adjusted via the commandline parameter. However, they are restricted to be no smaller than 6 dB so the noise is always at least 6 dB lower than the signal. The noise levels are also restricted to be no lower than -10 dB. To avoid high jumps in noise levels from one subband to another, some noise levels are decreased so that the difference between neighbouring bands is at most 5 dB. Finally, I use quadratic B-Splines to "interpolate" the noise levels to a smooth curve. From this curve, the noise shaping filter parameters as well as the bits2remove value is determined.

lossyWAV 1.3.0 Development Thread

Reply #221
lossyWAV beta 1.2.2x attached to post #1 in this thread.
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)

lossyWAV 1.3.0 Development Thread

Reply #222
Thanks Nick for your great efforts.
Somewhat OT and nothing fancy, but I made a lossyFLAC script that also integrates well with dBpoweramp:
Code: [Select]
@echo off
REM Encode WAV to FLAC via lossyWAV - by tycho 2011

set dir=%~dp0
if "%~1"=="" (
  echo Usage: %~nx0 lossywav_args @ flac_args
  echo.
  echo    ex: %~nx0 track01.wav --standard @ -5 -o track01.lossy.flac
  goto :eof
)
set lw_args=
set fl_args=
:lw_loop
  shift
  if "%~0"=="" goto run
  if "%~0"=="@" goto fl_loop
  set lw_args=%lw_args% %0
goto lw_loop
:fl_loop
  shift
  if "%~0"=="" goto run
  set fl_args=%fl_args% %0
goto fl_loop

:run
"%dir%lossyWAV.exe" %lw_args% --silent --stdout | "%dir%flac.exe" - -b 512 -f %fl_args%
Simple standalone usage: lossyFLAC.cmd  file.wav @ -o file.lossy.flac
Note that lossyWAV arguments should be placed before the @, and flac args after. Also, lossyWAV.exe and flac.exe must be present in the same folder as lossyFLAC.cmd.

If you know how to configure command line encoders using the dBpoweramp CLI plugin, it should be easy to integrate this. Basically, the encoder location is set to "encoder\LossyFLAC\lossyFLAC.cmd", and arguments to e.g. "- --standard @ -5 -o [outfile]". encoder.txt should contain: .lossy.flac (I prefer .[L].flac).
[edit: minors, script untouched]

lossyWAV 1.3.0 Development Thread

Reply #223
lossyWAV beta 1.2.2y attached to post #1 in this thread.
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)

lossyWAV 1.3.0 Development Thread

Reply #224
lossyWAV beta 1.2.2z attached to post #1 in this thread. This is release candidate #1 for lossyWAV 1.3.0.
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)