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.4.2 Development (was 1.5.0) (Read 598699 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #375
The crux of the implementation will end up being the definition of "sufficiently" in terms of difference in signal strength between mid and side.

I've already modified the code to calculate the RMS of the mid and side channel sample values of stereo audio all the time, and added a check to see if the difference would trigger the adaptive-linkchannels step in the bit-removal process.

A new parameter "--adaptivelink" has been added to the WIP for the next beta to change the behaviour of the new automatic adaptive channel linking for stereo audio. It currently takes a parameter (-3.0 <=n <= 8.0, default = 2.0) which sets the ratio between mid and side channel strength above which the bits to remove will be set to be the same for both channels. It can be disabled using "--adaptivelink off". Below is a table showing the effects on resultant bitrate on my 55 sample test set of the new --adaptivelink parameter over its range with --linkchannels and --adaptive off added for reference. All runs were conducted with "-q U -s W x -A -a 6 --scale 0.25" as the remainder of the parameters. The parameter relates to the difference in the log2 of the rms of the samples in each channel (or virtual channel).

Lo/Hi-3.0-2.0-1.00.01.02.03.04.05.06.07.08.0
-3.0245.1245.1244.9242.9237.4233.0231.1230.7230.6230.5230.5230.5
-2.0-245.1244.9242.9237.4233.0231.2230.7230.6230.5230.5230.5
-1.0--245.1243.1237.7233.3231.4230.9230.8230.8230.8230.8
0.0---245.1239.6235.2233.3232.9232.8232.7232.7232.7
1.0----245.1240.7238.8238.4238.2238.2238.2238.2
2.0-----245.1243.2242.8242.6242.6242.6242.6
3.0------245.1244.7244.5244.5244.5244.5
4.0-------245.1245.0244.9244.9244.9
5.0--------245.1245.0245.0245.0
6.0---------245.1245.1245.1
7.0----------245.1245.1
8.0-----------245.1
Table updated to show resultant bitrates of my 55 sample test set (770.6kbps lossless FLAC) following processing with the stated lo and hi values in --adaptivelink.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #376
Please find attached a new beta release of lossyWAV. Removed as superseded.

lossyWAV beta 1.4.3m, 10/12/2025 (expires 31/03/2026)

N.B.: the executable is 64-bit only.

  • New parameter "--adaptivelink <lo hi> / off". Adds check for stereo audio where relative signal strength of the mid and side virtual channels are compared and, if the ratio is above hi or below lo, the bits to remove for left and right audio channels will be the same, i.e. the lower of the bits to remove calculated for the channels. Adaptivelink is automatically applied for stereo audio but can be disabled using "--adaptivelink off". Lo and hi are valid in the range -3.0 < n < 8.0 and lo must be less than or equal to hi. Defaults are -2.0 and 2.0 respectively.

Usage: at the lowest quality presets it is recommended to scale input by 0.25, losslessly shifting the sample "down" by two bits (within an expanded sample container, if the bitdepth is 16-bit - foobar2000 can change bitdepth on the fly when decoding input files to pipe to lossyWAV for processing) - this is particularly recommended when weighted shaping is selected. The input scaling gives the noise shaping method headroom to work in and resultant bitrates of losslessly encoded lossyWAV output tends to be lower overall.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #377
Thanks, will give it a try. For the record, I just fine-tuned exhale's low-frequency psychoacoustic bit allocation, based on this plot. This could also apply to LossyWAV; will send you the details.

Update: --adaptivelink -1.1 1.1 works for me... and especially the Suspend.wav which was critical. The rate on Kamedo2's 20-sample set increases by only 1-2 kbps with this setting.

Chris
If I don't reply to your reply, it means I agree with you.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #378
Please find attached a new beta release of lossyWAV. Removed as expired.

lossyWAV beta 1.4.3n, 05/01/2026 (expires 31/03/2026)

N.B.: the executable is 64-bit only.

  • Change to "--adaptivelink <lo hi> / off" parameter; range of validity remains the same, defaults are now lo = -1.1 and hi = 1.1
  • Previous removal of the check of alt-average during the determination of bits to remove when weighted shaping method and experimental shaping gain curve are selected has been reverted. Now when weighted shaping method and experimental shaping gain curve are selected a modified variant of the alt-average check is performed.

Usage: at the lowest quality presets it is recommended to scale input by 0.25, losslessly shifting the sample "down" by two bits (within an expanded sample container, if the bitdepth is 16-bit - foobar2000 can change bitdepth on the fly when decoding input files to pipe to lossyWAV for processing) - this is particularly recommended when weighted shaping is selected. The input scaling gives the noise shaping method headroom to work in and resultant bitrates of losslessly encoded lossyWAV output tends to be lower overall.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #379
When I convert 32-bit float music files using lossyWAV and subject them to ABX tests against the originals, very noticeable issues are heard (sizzle, hissing, pops...). I'm not sure if LossyWAV actually supports 32-bit float conversion (as usual, I only used the default settings). However, the process completes without any warnings during the conversion phase.

Sample music: https://soundcloud.com/outertone/crusadope-back-in-time-32bit-outertone-free-release

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #380
lossyWAV does not support 32-bit float. Not sure why there was no error. Please post a sample (30 seconds or less) of the source file to that the header can be examined.


Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #382
Thanks for advising that lossyWAV was not throwing an error when non-integer PCM was selected as an input file. The bug has been fixed and will be included in the next Beta.

If you seek to reduce significant bits of floating point audio then you may find a previous project of mine useful: https://hydrogenaudio.org/index.php/topic,90770.25.html

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #383
It's not important. Thank you also for the information about your previous project.
Below is a test I did with lossyWAV. Again, thanks to @Porcus for the relevant test music. Compression results are better when FLAC is used as "-b 512" in this test, but the speed loss is more noticeable.

Total 1,915,809,594 bytes (12 tracks, 24 bit, 2 ch, 96.0 khz)
Code: [Select]
FLAC -8 (-b 512) -> 317,271,421 bytes  27.685s   4.812s
FLAC -5 (-b 512) -> 317,763,446 bytes   6.553s   4.803s
HALAC (normal)   -> 325,493,443 bytes   2.662s   2.905s
FLAC -8 (default)-> 332,940,950 bytes  12.587s   3.784s
FLAC -5 (default)-> 334,934,310 bytes   4.765s   3.676s
WAVPACK (high)   -> 422,790,502 bytes  31.636s  16.958s // default
WAVPACK (high)   -> 393,544,400 bytes  28.639s  18.139s // blocksize=512
OPTIMFROG (high) -> 493,764,226 bytes  66.879s  56.158s

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #384
It's only just dawned on me that the block size used in the lossless compression above is incorrect for 96kHz audio processed with lossyWAV - it should be 1024 not 512.

As well as that WavPack has a "--merge-blocks" parameter that will merge consecutive blocks with the same redundancy, i.e. zeroed bits at the "bottom" of the samples in the block.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #385
It's only just dawned on me that the block size used in the lossless compression above is incorrect for 96kHz audio processed with lossyWAV - it should be 1024 not 512.

Would you say that the block size should be 1024 for anything above 48 kHz?
caudec -c wvh -q fx4 -B 5 -P ~/Music/lossless -L ~/Music/lossy

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #386
From the nWav unit in the code:
Code: [Select]
    Global.Codec_Block.duration = OneOver[100];
    Global.Codec_Block.bits = std::max(8, nRoundEvenInt32(nlog2(Global.Codec_Block.duration * Global.sample_rate)));
    Global.Codec_Block.Size = PowersOf.TwoInt[Global.Codec_Block.bits];
    Global.Codec_Block.Size_recip = PowersOf.TwoX[TWO_OFFSET - Global.Codec_Block.bits];
    Global.Codec_Block.bit_shift = Global.Codec_Block.bits - 9;
    Global.Codec_Block.duration = double(Global.Codec_Block.Size) / Global.sample_rate;

The codec block size relates to c.10ms of audio (rounded to a power of two number of samples), i.e.:

@ 44.1kHz > 441 samples > 9 bits > 512 samples > 11.61ms
@ 48.0kHz > 480 samples > 9 bits > 512 samples > 10.67ms
@ 88.2kHz > 882 samples > 10 bits > 1024 samples > 11.61ms
@ 96.0kHz > 960 samples > 10 bits > 1024 samples > 10.67ms
etc.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #387
Total 1,915,809,594 bytes (12 tracks, 24 bit, 2 ch, 96.0 khz)
Code: [Select]
FLAC -8 (-b 512) -> 317,271,421 bytes  27.685s   4.812s
FLAC -5 (-b 512) -> 317,763,446 bytes   6.553s   4.803s
HALAC (normal)   -> 325,493,443 bytes   2.662s   2.905s
FLAC -8 (default)-> 332,940,950 bytes  12.587s   3.784s
FLAC -5 (default)-> 334,934,310 bytes   4.765s   3.676s
WAVPACK (high)   -> 422,790,502 bytes  31.636s  16.958s // default
WAVPACK (high)   -> 393,544,400 bytes  28.639s  18.139s // blocksize=512
OPTIMFROG (high) -> 493,764,226 bytes  66.879s  56.158s
I didn't know such a thing existed in LossyWAV. When HALAC switches to LossyWAV mode, it automatically locks the block size to 512. And it ignores block sizes entered as parameters.
Now I skipped this and tried the block size as 1024 and the results are below. I may add the "khz" sensitive form to the next version.
Code: [Select]
FLAC -8      : 308,758,405 bytes  18.634s   4.481s // block_size 1024
FLAC -5      : 309,764,795 bytes   5.541s   4.476s // block_size 1024
HALAC -normal: 310,723,761 bytes   2.356s   2.856s // block_size 1024
WAVPACK -hx  : 352,913,408 bytes  86.562s  16.485s // block_size 1024
WAVPACK -h   : 360,985,944 bytes  36.981s  17.496s // block_size 1024

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #388
LossyWav is a great tool for streaming music via Bluetooth from a smartphone. With microSD cards disappearing from the vast majority of high-end mobile phones (though fortunately not from DAPs), coupled with their limited storage (512GB or 1TB at best), LossyWav stands out as the best alternative for saving space and avoiding transcoding at the same time. And I suspect the Bluetooth codec will have no trouble handling the added noise...

I even think it can make the Bluetooth codec's job easier by providing it with a pre-processed file where the less essential information has already been filtered out.

In my case, I use it in Insane mode, since I already get enough space savings for my needs. It's a gem.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #389
In light of discussion in this thread, I am considering removing the ability to create correction files / merge lossy and correction files from lossyWAV.

As correctly observed in the thread, while WavPack enjoys the ability as a codec to create lossy / correction file pairs and, crucially, automatically reintegrate them for playback and conversion from lossless, lossyWAV as a DSP does not.

Removing creation and re-integration from correction files would reduce code complexity and allow more easy moves to, for example, changing bits-per-sample on the fly between input to and output from lossyWAV.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #390
In light of discussion in this thread, I am considering removing the ability to create correction files / merge lossy and correction files from lossyWAV.

As correctly observed in the thread, while WavPack enjoys the ability as a codec to create lossy / correction file pairs and, crucially, automatically reintegrate them for playback and conversion from lossless, lossyWAV as a DSP does not.

Removing creation and re-integration from correction files would reduce code complexity and allow more easy moves to, for example, changing bits-per-sample on the fly between input to and output from lossyWAV.
Hard approve on my end. LossyWAV's correction file function has always been a bit tacky in use when I toyed with it, and would very much require the "magic sauce" WavPack employs for more proper utilization of such.

It also shows in the best way to use each: WavPack is for people who want the flexibility, whereas LossyWAV is taken advantage of by people who expressly don't care for the original to some extent. I also trust your reasoning when it comes to why you want it gone, so if you go for it despite possible disapproval from others, I'll still accept it with no complaint.
Just an on-and-off enthusiast hyperfixated on time-domain lossy codecs/preprocessors.

If I get anything wrong, you're always welcome to correct me; I will never react badly to responses made in good faith.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #391
Please find attached a re-release of lossyWAV (re-released due to the expiry of the previous beta).

lossyWAV beta 1.4.3n, 01/04/2026 (expires 30/06/2026)

N.B.: the executable is 64-bit only.

Change to "--adaptivelink <lo hi> / off" parameter; range of validity remains the same, defaults are now lo = -1.1 and hi = 1.1
Previous removal of the check of alt-average during the determination of bits to remove when weighted shaping method and experimental shaping gain curve are selected has been reverted. Now when weighted shaping method and experimental shaping gain curve are selected a modified variant of the alt-average check is performed.

Usage: at the lowest quality presets it is recommended to scale input by 0.25, losslessly shifting the sample "down" by two bits (within an expanded sample container, if the bitdepth is 16-bit - foobar2000 can change bitdepth on the fly when decoding input files to pipe to lossyWAV for processing) - this is particularly recommended when weighted shaping is selected. The input scaling gives the noise shaping method headroom to work in and resultant bitrates of losslessly encoded lossyWAV output tends to be lower overall.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #392
Further to my previous post where I stated that I am considering removing the ability to create correction files (and subsequently merge them with lossy files to re-create a lossless audio version) - I have removed these features in the WIP version for the next Beta.

With the removal of the correction / merge features there is no compelling reason now to retain the "fact" chunk that lossyWAV inserts into processed audio files, N.B. but only if those files are written as files, i.e. the "fact" chunk is not inserted into processed audio written to stdout.

Therefore I am going to remove the creation / insertion of 'fact' chunks from lossyWAV completely. This will further simplify the code.

Regarding outputting to a sample type of a different bits-per-sample than the input sample type I have made significant progress with this implementation and am working on output to integer and floating point samples of 8 bits, 16 bits, 24 bits, and 32-bits in length.

One reason for adding changing bits-per-sample for output is to avoid the need to modify bits-per-sample of the input to lossyWAV prior to processing to allow lossless scaling by powers of two smaller than one, e.g. 16-bit PCM will be able to be converted and scaled to 24-bit PCM within lossyWAV and won't rely on sample bit-depth expansion to be performed prior to processing.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #393
Sounds great! Will this become a 1.5.0 after all?

Thanks very much and Happy Easter!

Chris
If I don't reply to your reply, it means I agree with you.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #394
My thoughts on development of the 1.4.3<char> beta versions is that it's leading up to the release of 1.4.4 (in the same way that beta versons 1.4.1<char> were based on release 1.4.0 and led to release 1.4.2). However 1.5.0 might be better.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #395
With the removal of the correction / merge features there is no compelling reason now to retain the "fact" chunk that lossyWAV inserts into processed audio files, N.B. but only if those files are written as files, i.e. the "fact" chunk is not inserted into processed audio written to stdout.

Therefore I am going to remove the creation / insertion of 'fact' chunks from lossyWAV completely. This will further simplify the code.
Hi Nick.
I guess when the "fact" tag in lossyWAV is removed, we will no longer have direct information about whether the wav file we have is lossless or lossy. It may be necessary to find an accurate and rapid way to detect this. However, some operations that need to be done specifically for lossyWAV in HALAC may need to be done more indirectly.

For example; Let's want to compress a group of lossyWAV processed files with different Sample Rate values. In this case, it is more accurate to determine the ideal block size for each file. This of course also applies to other codecs. In the final version of HALAC, which I have not published, this is done automatically. And in "-normal" mode, it offers a compression ratio close to "FLAC -8" at the ideal block size, but is 7x/10x faster. If it is not known for certain that it is lossyWAV, it is difficult to obtain this efficiency.

Of course, lossyWAV is your work and we respect your decisions on this matter.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #396
One way to tell if an integer PCM file has been processed with lossyWAV is to "OR" all of the samples in a block and see how many zeroed LSBs there are.

Regarding block size in lossyWAV it's as previously discussed, i.e. it's related to sample-rate.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #397
If the LSB control gives accurate results under all conditions, there is no problem. HALAC has already been doing this (SHIFT_SELECTION) since the beginning, but the order of operations is different. Just changing the order of operations is enough.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #398
One way to tell if an integer PCM file has been processed with lossyWAV is to "OR" all of the samples in a block and see how many zeroed LSBs there are.

Regarding block size in lossyWAV it's as previously discussed, i.e. it's related to sample-rate.
People at least want to know whether the audio data they're using is lossy or lossless. Okay, let's forget about the conversion details. I want to know too.  Normal users never check the bits for that. Lossywav might not be the only thing causing the bit changes. That's not exactly the right approach.

Re: lossyWAV 1.4.2 Development (was 1.5.0)

Reply #399
In which case one of few solutions is to rip the audio from CD oneself.

Just because audio is contained in a WAV file, or encoded using a lossless codec, has never meant that it is guaranteed to be lossless.

Also noting that lossyWAV does not insert the (soon to be removed) 'fact' chunk when piping output, e.g. directly to a lossless codec while avoiding an intermediate WAV file.