Difference between revisions of "LossyWAV"

From Hydrogenaudio Knowledgebase
Jump to: navigation, search
m (Example drag'n'drop batch file)
(Linux / OS X support: lossyWAV and WINE: caudec.net site deprecated)
(47 intermediate revisions by 15 users not shown)
Line 1: Line 1:
 
{{Software Infobox
 
{{Software Infobox
 
| name = lossyWAV
 
| name = lossyWAV
 +
| logo =
 
| screenshot =  
 
| screenshot =  
 
| caption =  
 
| caption =  
| maintainer = [http://www.hydrogenaudio.org/forums/index.php?showuser=42400 Nick.C]
+
| maintainer = [http://www.hydrogenaud.io/forums/index.php?showuser=42400 Nick.C]
| stable_release = 1.1.0b
+
| stable_release = [https://hydrogenaud.io/index.php/topic,112649 1.4.2]
| preview_release = 1.0.1x RC4
+
| preview_release = -
| operating_system = [[Wikipedia:Microsoft Windows|Windows]]
+
| operating_system = [[Wikipedia:Microsoft Windows|Windows]], [[Wikipedia:Linux|Linux]]
 
| use = [[Wikipedia:Digital signal processing|Digital signal processing]]
 
| use = [[Wikipedia:Digital signal processing|Digital signal processing]]
 
| license = [[Wikipedia:GNU General Public License|GNU GPL]]
 
| license = [[Wikipedia:GNU General Public License|GNU GPL]]
| website = [http://www.hydrogenaudio.org/forums/index.php?showtopic=56129 Hydrogenaudio]
+
| website = [http://www.hydrogenaud.io/forums/index.php?showtopic=107081 1.4.0 release thread]<br />[http://www.hydrogenaud.io/forums/index.php?showtopic=109239 1.5.0 development thread]
 
}}
 
}}
lossyWAV is a new free lossy pre-processor for [[PCM]] audio contained in the [[WAV]] file format. It reduces [[Wikipedia:Audio bit depth|bit depth]] of the input signal, which, when used in conjunction with certain lossless codecs, reduces the bitrate of the encoded file significantly compared to unpreprocessed compression.  
+
lossyWAV is a [[Wikipedia:Free software|free]], [[lossy]] pre-processor for [[PCM]] audio contained in the [[RIFF_WAVE|WAV]] file format. Proposed by [http://www.hydrogenaud.io/forums/index.php?showuser=409 David Robinson], it reduces [[Wikipedia:Audio bit depth|bit depth]] of the input signal, which, when used in conjunction with certain lossless codecs, reduces the bitrate of the encoded file significantly compared to unpreprocessed compression.
 
lossyWAV's primary goal is to maintain [[transparency]] with a high degree of confidence when processing any audio data.
 
lossyWAV's primary goal is to maintain [[transparency]] with a high degree of confidence when processing any audio data.
  
 
==History==
 
==History==
lossyWAV is based on the lossyFLAC idea proposed by [http://www.hydrogenaudio.org/forums/index.php?showuser=409 David Robinson] at Hydrogenaudio, which is a method of carefully reducing the bitdepth of samples, therefore utilising the wasted bits feature of the FLAC lossless codec. The aim is to transparently reduce audio bit depth (by making some lower significant bits (lsb's) zero), consequently taking advantage of FLAC's detection of consistently-zeroed lower significant bits within each single frame and significantly increasing coding efficiency.[http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=55522&view=findpost&p=498179] In this way the user can enjoy audio encoded using the same codec (which may be all important from a hardware compatibility perspective) at a reduced bitrate compared to the lossless version.
+
lossyWAV is based on the lossyFLAC idea proposed by [http://www.hydrogenaud.io/forums/index.php?showuser=409 David Robinson] at Hydrogenaudio, which is a method of carefully reducing the bitdepth of (blocks of) samples which will then allow the FLAC lossless encoder to make use of its wasted bits feature. The aim is to transparently reduce audio bit depth (by making some lower significant bits ([[Wikipedia:Least_significant_bit|lsb]]'s) zero), consequently taking advantage of FLAC's detection of consistently-zeroed lower significant bits within each single frame and significantly increasing coding efficiency.[http://www.hydrogenaud.io/forums/index.php?s=&showtopic=55522&view=findpost&p=498179] In this way the user can enjoy audio encoded using the same codec (which may be all important from a hardware compatibility perspective) at a reduced bitrate compared to the lossless version.
  
[http://www.hydrogenaudio.org/forums/index.php?showuser=42400 Nick Currie] ported the original [[Wikipedia:MATLAB|MATLAB]] implementation to [[Wikipedia:Borland Delphi|Delphi]] (Many thanks [[Wikipedia:CodeGear|CodeGear]] for Turbo Explorer!!) with a liberal sprinkling of [[Wikipedia:IA-32|IA-32]] and [[Wikipedia:x87|x87]] Assembly Language for speed.
+
[http://www.hydrogenaud.io/forums/index.php?showuser=42400 Nick Currie] ported the original [[Wikipedia:MATLAB|MATLAB]] implementation to [[Wikipedia:Borland Delphi|Delphi]] (Many thanks [[Wikipedia:CodeGear|CodeGear]] for Turbo Explorer!) with a liberal sprinkling of [[Wikipedia:IA-32|IA-32]] and [[Wikipedia:x87|x87]] Assembly Language for speed.
  
 
Subsequently, lossyFLAC proved itself to work with other lossless codecs, so the application name was changed to lossyWAV.  
 
Subsequently, lossyFLAC proved itself to work with other lossless codecs, so the application name was changed to lossyWAV.  
  
Since then, Nick has heavily developed and built upon lossyWAV, with valuable tuning performed by [http://www.hydrogenaudio.org/forums/index.php?showuser=25015 Horst Albrecht] at Hydrogenaudio. Although the current lossyWAV implementation has built on David's original method, the method itself still very much belongs to its author.
+
Since then, Nick has heavily developed and built upon lossyWAV, with valuable tuning performed by [http://www.hydrogenaud.io/forums/index.php?showuser=25015 Horst Albrecht] at Hydrogenaudio. Although the current lossyWAV implementation has built on David's original method, the method itself still very much belongs to its author.
  
 
==Indicative bitrate reduction==
 
==Indicative bitrate reduction==
It must be stressed that lossyWAV is a pure variable bit-depth pre-processor in that the overall sample size remains the same after processing but the number of significant bits used for the samples in a codec-block can change on a block-by-block basis. Bits-to-remove from the audio data are calculated on a block-by-block basis (codec-block length = 512 samples, 11.6msec @ 44.1kHz) using overlapping [[Wikipedia:fast Fourier transform|fast Fourier Transform]] (FFT) analyses of at least two lengths (default quality preset (-q 5) = 32, 64 & 1024 [[Wikipedia:Sampling %28signal processing%29|samples]]). After some manipulation, the results of each FFT analysis for a specific codec-block are then grouped and the minimum value used to determine bits-to-remove for the whole codec-block. Bit removal adds [[Wikipedia:white noise|white noise]] to the output, however the level of the added noise associated with the removal of a number of bits has been pre-calculated and the number of bits to remove will depend on the level of the noise floor of the codec-block in question. Each sample in the codec-block is then rounded such that the first <bits-to-remove> lsb's are zero. In this way the wasted bits feature of [[FLAC]] et al is exploited.
+
It must be stressed that lossyWAV is a pure variable bit-depth pre-processor in that the overall sample size remains the same after processing but the number of significant bits used for the samples in a codec-block can change on a block-by-block basis. Bits-to-remove from the audio data are calculated on a block-by-block basis (codec-block length = 512 samples, 11.6msec @ 44.1kHz) using overlapping [[Wikipedia:fast Fourier transform|fast Fourier Transform]] (FFT) analyses of at least two lengths (default quality preset (-q 5) = 32, 64 & 1024 [[Wikipedia:Sampling %28signal processing%29|samples]]). After some manipulation, the results of each FFT analysis for a specific codec-block are then grouped and the minimum value used to determine bits-to-remove for the whole codec-block. Bit removal adds noise to the output, however the level of the added noise associated with the removal of a number of bits has been pre-calculated and the number of bits to remove will depend on the level of the noise floor of the codec-block in question. The added noise is adaptively shaped by default, however the user can select parameters to make the added noise fixed shaped or simply [[Wikipedia:white noise|white noise]]. Each sample in the codec-block is then rounded such that the first <bits-to-remove> lsb's are zero. In this way the wasted bits feature of [[FLAC]] et al. is exploited.
  
 
{| class="wikitable" style="text-align:center"
 
{| class="wikitable" style="text-align:center"
Line 33: Line 34:
 
!--insane
 
!--insane
 
!--extreme
 
!--extreme
 +
!--high
 
!--standard
 
!--standard
 +
!--economic
 
!--portable
 
!--portable
!-q 0
+
!--extraportable
|-
+
!10 Album Test Set
+
| TAK
+
| 820 kbit/s
+
| 615 kbit/s
+
| 532 kbit/s
+
| 447 kbit/s
+
| 359 kbit/s
+
| 266 kbit/s
+
 
|-
 
|-
 
!10 Album Test Set
 
!10 Album Test Set
 
| FLAC
 
| FLAC
 
| 854 kbit/s
 
| 854 kbit/s
| 632 kbit/s
+
| 627 kbit/s
 
| 548 kbit/s
 
| 548 kbit/s
| 463 kbit/s
+
| 477 kbit/s
| 376 kbit/s
+
| 442 kbit/s
| 285 kbit/s
+
| 407 kbit/s
 +
| 353 kbit/s
 +
| 311 kbit/s
 
|-
 
|-
!10 Album Test Set
+
!Nick.C's Full Collection
| Wavpack
+
| FLAC
| 852 kbit/s
+
| 882 kbit/s
| 641 kbit/s
+
| -
| 563 kbit/s
+
| -
| 481 kbit/s
+
| -
| 390 kbit/s
+
| -
| 296 kbit/s
+
| -
 +
| -
 +
| 307 kbit/s
 
|}
 
|}
  
 
==File identification==
 
==File identification==
lossyWAV-processed WAV files are named with a double filename extension, .lossy.wav, to make them instantly identifiable. e.g. ".lossy.flac" would indicate an audio file which was processed using lossyWAV, and subsequently encoded using FLAC.[http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=55522&view=findpost&p=498559]
+
lossyWAV-processed WAV files are named with a double filename extension, .lossy.wav, to make them instantly identifiable. e.g. ".lossy.flac" would indicate an audio file which was processed using lossyWAV, and subsequently encoded using FLAC.[http://www.hydrogenaud.io/forums/index.php?s=&showtopic=55522&view=findpost&p=498559]
  
 
The --correction parameter is used when processing to create a correction file which is named with the .lwcdf.wav double filename extension. When "added" to the corresponding .lossy.wav, using the --merge parameter, the original file will be reconstituted.
 
The --correction parameter is used when processing to create a correction file which is named with the .lwcdf.wav double filename extension. When "added" to the corresponding .lossy.wav, using the --merge parameter, the original file will be reconstituted.
Line 74: Line 72:
 
lossyWAV inserts a variable-length 'fact' chunk into the WAV file immediately after the 'fmt ' chunk. This takes the form:<pre>fact/<size>/lossyWAV x.y.z @ dd/mm/yyyy hh:mm:ss, -q 5</pre>Where the version, date & time and user settings are copied. Additionally, if a lossyWAV 'fact' chunk is found in a file, the processing will be halted (exit code = 16) to prevent re-processing of an already processed file.
 
lossyWAV inserts a variable-length 'fact' chunk into the WAV file immediately after the 'fmt ' chunk. This takes the form:<pre>fact/<size>/lossyWAV x.y.z @ dd/mm/yyyy hh:mm:ss, -q 5</pre>Where the version, date & time and user settings are copied. Additionally, if a lossyWAV 'fact' chunk is found in a file, the processing will be halted (exit code = 16) to prevent re-processing of an already processed file.
  
The -check parameter can be used to determine whether a file has previously been processed without trying to process it, exit code = 16 if already processed; exit code = 0 if not.
+
The --check parameter can be used to determine whether a file has previously been processed without trying to process it, exit code = 16 if already processed; exit code = 0 if not.
  
 
==Quality presets==
 
==Quality presets==
*--insane: (-q 10) Highest quality preset, generally considered to be excessive;
+
*--quality insane: (-q I or -q 10) Highest quality preset, generally considered to be excessive;
*--extreme: (-q 7.5) High quality preset, disc space-saving alternative to lossless archiving for large audio collections, considered to be suitable for transcoding to other lossy codecs;
+
*--quality extreme: (-q E or -q 7.5) Higher quality preset, disc space-saving alternative to lossless archiving for large audio collections, considered to be suitable for transcoding to other lossy codecs;
*--standard: (-q 5) Default preset, generally accepted to be transparent;
+
*--quality high: (-q H or -q 5.0) High quality preset, midway between extreme and standard;
*--portable: (-q 2.5) DAP quality preset for use on a compatible [[Wikipedia:Digital audio player|DAP]]. [http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=56129&view=findpost&p=531316]
+
*--quality standard: (-q S or -q 2.5) Default preset, generally accepted to be transparent;
 +
*--quality economic: (-q C or -q 0.0) Intermediate preset midway between standard and portable;
 +
*--quality portable: (-q P or -q -2.5) DAP quality preset for use on a compatible [[Wikipedia:Digital audio player|DAP]].[http://www.hydrogenaud.io/forums/index.php?s=&showtopic=56129&view=findpost&p=531316]
 +
*--quality extraportable: (-q X or -q -5.0) Lowest quality preset for use on a compatible [[Wikipedia:Digital audio player|DAP]].[http://www.hydrogenaud.io/forums/index.php?s=&showtopic=56129&view=findpost&p=531316]
 +
 
 +
All tuning for version 1.0.0 was performed on quality preset --standard with higher presets being more conservative. For versions 1.1.0, 1.2.0 and 1.3.0, tuning effort has been focused on the lowest quality preset in an effort to achieve an effective compromise between resultant bitrate and perceived quality. Quality preset --standard is generally accepted to be (and from testing so far is) transparent. If you find a track which --standard fails to achieve transparency after processing, please post a sample (no more than 30 seconds) in the development thread.
  
All tuning has been performed on quality preset --standard with higher presets being more conservative. Quality preset --standard is generally accepted to be (and from testing so far is) transparent. If you find a track which --standard fails to achieve transparency after processing, please post a sample (no more than 30 seconds) in the development thread.
+
The upper frequency limit used in the calculation of minimum signal power varies, dependent on quality preset, in the range 15.159kHz to 16.682kHz
  
 
==Supported input formats==
 
==Supported input formats==
Line 94: Line 97:
 
!Encoder parameters
 
!Encoder parameters
 
!Combination name
 
!Combination name
|-
 
! [[Apple Lossless]]
 
| No
 
| &mdash;
 
| &mdash;
 
 
|-
 
|-
 
! [[Free Lossless Audio Codec|FLAC]]
 
! [[Free Lossless Audio Codec|FLAC]]
Line 104: Line 102:
 
| -'''5''' -'''b''' 512 --'''keep-foreign-metadata'''
 
| -'''5''' -'''b''' 512 --'''keep-foreign-metadata'''
 
| lossy'''FLAC'''
 
| lossy'''FLAC'''
|-
 
! [[Lossless Audio|LA]]
 
| No
 
| &mdash;
 
| &mdash;
 
 
|-
 
|-
 
! [[Lossless Predictive Audio Compression|LPAC]]
 
! [[Lossless Predictive Audio Compression|LPAC]]
Line 114: Line 107:
 
| -'''b'''512
 
| -'''b'''512
 
| lossy'''LPAC'''
 
| lossy'''LPAC'''
|-
 
! [[Monkey's Audio]]
 
| No
 
| &mdash;
 
| &mdash;
 
 
|-
 
|-
 
! [[Wikipedia:Audio Lossless Coding|MPEG-4 ALS]]
 
! [[Wikipedia:Audio Lossless Coding|MPEG-4 ALS]]
Line 124: Line 112:
 
| -'''l''' -'''n'''512
 
| -'''l''' -'''n'''512
 
| lossy'''ALS'''
 
| lossy'''ALS'''
|-
 
! [[OptimFROG]]
 
| No
 
| &mdash;
 
| &mdash;
 
 
|-
 
|-
 
! [[TAK]]
 
! [[TAK]]
Line 134: Line 117:
 
| -'''fsl'''512
 
| -'''fsl'''512
 
| lossy'''TAK'''
 
| lossy'''TAK'''
|-
 
! [[Wikipedia:TTA (codec)|TTA]]
 
| No
 
| &mdash;
 
| &mdash;
 
 
|-
 
|-
 
! [[WavPack]]
 
! [[WavPack]]
 
| '''Yes'''
 
| '''Yes'''
| --'''blocksize'''=512
+
| --'''blocksize'''=512 --'''merge-blocks'''
 
| lossy'''WV'''
 
| lossy'''WV'''
 
|-
 
|-
Line 149: Line 127:
 
| &mdash;
 
| &mdash;
 
| lossy'''WMALSL'''
 
| lossy'''WMALSL'''
 +
|-
 +
! [[Apple Lossless]]
 +
| No
 +
| &mdash;
 +
| &mdash;
 +
|-
 +
! [[Lossless Audio|LA]]
 +
| No
 +
| &mdash;
 +
| &mdash;
 +
|-
 +
! [[Monkey's Audio]]
 +
| No
 +
| &mdash;
 +
| &mdash;
 +
|-
 +
! [[OptimFROG]]
 +
| No
 +
| &mdash;
 +
| &mdash;
 +
|-
 +
! [[Wikipedia:TTA (codec)|TTA]]
 +
| No
 +
| &mdash;
 +
| &mdash;
 
|}
 
|}
  
Line 154: Line 157:
  
  
There is also [http://www.hometheaterhifi.com/volume_8_4/dvd-benchmark-part-6-dvd-audio-11-2001.html#Meridian%20Lossless%20Packing%20(MLP)%20in%20a%20Nutshell evidence] &mdash; so-called "Bit Shifting" &mdash; to suggest that lossyWAV may work with [[Wikipedia:Meridian Lossless Packing|MLP]], but this remains untested due to prohibitive prices of encoders.
+
There is also [http://www.hometheaterhifi.com/volume_8_4/dvd-benchmark-part-6-dvd-audio-11-2001.html#Meridian%20Lossless%20Packing%20(MLP)%20in%20a%20Nutshell evidence] &mdash; so-called "Bit Shifting" &mdash; to suggest that lossyWAV may work with [[Wikipedia:Meridian Lossless Packing|MLP]], but this remains untested due to prohibitive prices of encoders. At least one [http://www.hydrogenaud.io/forums/index.php?showtopic=98609&hl= commercial DVD-A] uses constant bit-depth reduction with lower bit-depth on rear channels.
  
 
A comparison of portable media players is [[Wikipedia:Comparison of portable media players#Audio Formats|here]], which shows FLAC and WMA Lossless compatibility among listed players.
 
A comparison of portable media players is [[Wikipedia:Comparison of portable media players#Audio Formats|here]], which shows FLAC and WMA Lossless compatibility among listed players.
Line 166: Line 169:
 
===Application settings===
 
===Application settings===
 
<pre>
 
<pre>
lossyWAV 1.1.0, Copyright (C) 2007,2008 Nick Currie. Copyleft.
+
lossyWAV 1.4.2, Copyright (C) 2007-2016 Nick Currie. Copyleft.
  
 
This program is free software: you can redistribute it and/or modify it under
 
This program is free software: you can redistribute it and/or modify it under
Line 179: Line 182:
 
You should have received a copy of the GNU General Public License along with
 
You should have received a copy of the GNU General Public License along with
 
this program.  If not, see <http://www.gnu.org/licenses/>.
 
this program.  If not, see <http://www.gnu.org/licenses/>.
 +
 +
Process Description:
 +
 +
lossyWAV is a near lossless audio processor which dynamically reduces the
 +
bitdepth of the signal on a block-by-block basis. Bitdepth reduction adds noise
 +
to the processed output. The amount of permissible added noise is based on
 +
analysis of the signal levels in the default frequency range 20Hz to 16kHz.
 +
 +
If signals above the upper limiting frequency are at an even lower level, they
 +
can be swamped by the added noise. This is usually inaudible, but the behaviour
 +
can be changed by specifying a different --limit (in the range 10kHz to 20kHz).
 +
 +
For many audio signals there is little content at very high frequencies and
 +
forcing lossyWAV to keep the added noise level lower than the content at these
 +
frequencies can increase the bitrate of the losslessly compressed output
 +
dramatically for no perceptible benefit.
 +
 +
The noise added by the process is shaped using an adaptive method provided by
 +
Sebastian Gesemann. This method, as implemented in lossyWAV, aims to use the
 +
signal itself as the basis of the filter used for noise shaping. Adaptive noise
 +
shaping is enabled by default.
  
 
Usage  : lossyWAV <input wav file> <options>
 
Usage  : lossyWAV <input wav file> <options>
Line 186: Line 210:
 
Quality Options:
 
Quality Options:
  
-I, --insane        highest quality output, suitable for transcoding;
+
-q, --quality <t>    where t is one of the following (default = standard):
-E, --extreme      high quality output, also suitable for transcoding;
+
    I, insane        highest quality output, suitable for transcoding;
-S, --standard      default quality output, considered to be transparent;
+
    E, extreme      higher quality output, suitable for transcoding;
-P, --portable      good quality output for DAP use. Not considered to be fully
+
    H, high          high quality output, suitable for transcoding;
                    transparent, but considered fit for its intended purpose.
+
    S, standard      default quality output, considered to be transparent;
 +
    C, economic      intermediate quality output, likely to be transparent;
 +
    P, portable      good quality output for DAP use, may not be transparent;
 +
    X, extraportable lowest quality output, probably not transparent.
  
 
Standard Options:
 
Standard Options:
  
-c, --check        check if WAV file has already been processed; default=off.
+
-C, --correction     write correction file for processed WAV file; default=off.
                    errorlevel=16 if already processed, 0 if not.
+
-f, --force         forcibly over-write output file if it exists; default=off.
-C, --correction   write correction file for processed WAV file; default=off.
+
-h, --help           display help.
-f, --force         forcibly over-write output file if it exists; default=off.
+
-L, --longhelp       display extended help.
-h, --help         display help.
+
-M, --merge         merge existing lossy.wav and lwcdf.wav files.
-L, --longhelp     display extended help.
+
-o, --outdir <t>     destination directory for the output file(s).
-M, --merge         merge existing lossy.wav and lwcdf.wav files.
+
-v, --version       display the lossyWAV version number.
-o, --outdir <t>   destination directory for the output file(s).
+
-w, --writetolog    create (or add to) lossyWAV.log in the output directory.
-v, --version       display the lossyWAV version number.
+
 
 +
Advanced Options:
 +
 
 +
-                    take WAV input from STDIN.
 +
-c, --check          check if WAV file has already been processed; default=off.
 +
                    errorlevel=16 if already processed, 0 if not.
 +
-q, --quality <n>    quality preset (-5.0<=n<=10.0); (-5=lowest, 10=highest;
 +
                    default=2.5; I=10.0; E=7.5; H=5.0; S=2.5; C=0.0; P=-2.5;
 +
                    X=-5.0.
 +
--, --stdout        write WAV output to STDOUT.
 +
    --stdinname <t>  pseudo filename to use when input from STDIN.
 +
 
 +
Advanced Quality Options:
 +
 
 +
-A, --altspread [n]  disables 'old' sperading mechanism in favour of 'new'
 +
                    mechanism (default spreading uses both 'old' and 'new'
 +
                    mechanisms). Takes an optional parameter, n, which relates
 +
                    to the proportion of adjacent bins taken into account when
 +
                    calculating spread average for a particular bin (0<=n<=1;
 +
                    default = 0.768544).
 +
-a, --analyses <n>  set number of FFT analysis lengths, (2<=n<=7; default=3,
 +
                    i.e. 32, 64 & 1024 samples. n = 2, remove 32 sample FFT;
 +
                    n > 3 add 16; n > 4, add 128; n > 5, add 256, n > 6, add
 +
                    512) n.b. FFT lengths stated are for 44.1/48kHz audio,
 +
                    higher sample rates will automatically increase all FFT
 +
                    lengths as required.
 +
-D, --dynamic <n>    select minimum_bits_to_keep_dynamic to n bits (default
 +
                    2.71 at -q X and 5.00 at -q I, 1.0 <= n <= 7.0.
 +
    --feedback [n]  enable experimental bit removal / adaptive noise shaping
 +
                    noise limiter. Tuning has been carried out at -q X and
 +
                    should have a negligible effect at -q S. Optional setting
 +
                    (0.0 <= n <= 10.0, default = 0.0) automatically selects
 +
                    the following parameters (0 = least effect, 10 = most):
 +
      r, round <n>  limit deviation from expected added noise due to rounding
 +
                    (-2.0 <= n <= 2.0, default = 0.0).
 +
      n, noise <n>  limit added noise due to adaptive noise shaping
 +
                    (-2.5 <= n <= 7.5, default = 0.0).
 +
      a, aclips <n> number of permissible exceedences of adaptive noise
 +
                    shaping level limit (0 <= n <= 64, default = 32).
 +
      A, alevel <n> adaptive noise shaping level limit (-2.0 <= n <= 2.5,
 +
                    default = 0.0).
 +
      V, verbose    enable more detailed feedback information in output.
 +
-I, --ignore-chunk-sizes.
 +
                    ignore 'RIFF' and 'data' chunk sizes in input.
 +
-l, --limit <n>      set upper frequency limit to be used in analyses to n Hz;
 +
                    (12500 <= n <= 20000*; default=16000).
 +
                    *: for 44.1/48 kHz audio. Upper limit for audio of
 +
                    other sampling rates is limited to sample-rate x 45.35%
 +
    --linkchannels  revert to original single bits-to-remove value for all
 +
                    channels rather than channel dependent bits-to-remove.
 +
    --maxclips <n>  set max. number of acceptable clips per channel per block;
 +
                    (0 <= n <= 16; default = 3,3,3,3,3,2,2,2,2,2,1,1,1,0,0,0).
 +
-m, --midside        analyse 2 channel audio for mid/side content.
 +
    --nodccorrect    disable DC correction of audio data prior to FFT analysis,
 +
                    default=on; (DC offset calculated per FFT data set).
 +
-n, --noskew        disable application of low frequency level reduction prior
 +
                    to determination of bits-to-remove.
 +
    --scale <n>      factor to scale audio by; (0.03125 < n <= 8.0; default=1).
 +
-s, --shaping        modify settings for noise shaping used in bit-removal:
 +
      a, altfilter  enable alternative adaptive shaping filter method.
 +
      A, average    set factor of shape modification above upper calculation
 +
                    frequency limit (0.00000 <= n <= 1.00000)
 +
      c, cubic      enable cubic interpolation when defining filter shape
 +
      e, extra      additional white noise to add during creation of filter
 +
      f, fixed      disable adaptive noise shaping (use fixed shaping)
 +
      h, hybrid    enable hybrid alternative to default adaptive noise shaping
 +
                    method. Uses all available calculated analyses to create
 +
                    the desired noise filter shape rather than only those for
 +
                    1.5ms and 20ms FFT analyses.
 +
      n, nowarp    disable warped noise shaping (use linear frequency shaping)
 +
      o, off        disable noise shaping altogether (use simple rounding)
 +
      s, scale <n>  change effectiveness of noise shaping (0 < n <= 2; default
 +
                    = 1.0)
 +
      t, taps <n>  select number of taps to use in FIR filter (8 <= n <= 256;
 +
                    default = 64)
 +
      w, warp      enable cubic interpolation when creating warped filter
 +
    --static <n>    set minimum-bits-to-keep-static to n bits (default=6;
 +
                    3<=n<=28, limited to bits-per-sample - 3).
 +
-U, --underlap <n>  enable underlap mode to increase number of FFT analyses
 +
                    performed at each FFT length, (n = 2, 4 or 8, default=2).
 +
 
 +
Output Options:
 +
 
 +
    --bitdist        show distrubution of bits to remove.
 +
    --blockdist      show distribution of lowest / highest significant bit of
 +
                    input codec-blocks and bit-removed codec-blocks.
 +
-d, --detail        enable per block per channel bits-to-remove data display.
 +
-F, --freqdist [all] enable frequency analysis display of input data. Use of
 +
                    'all' parameter displays all calculated analyses.
 +
-H, --histogram      show sample value histogram (input, lossy and correction).
 +
    --perchannel    show selected distribution data per channel.
 +
-p, --postanalyse    enable frequency analysis display of output and
 +
                    correction data in addition to input data.
 +
    --sampledist    show distribution of lowest / highest significant bit of
 +
                    input samples and bit-removed samples.
 +
    --spread [full]  show detailed [more detailed] results from the spreading/
 +
                    averaging algorithm.
 +
-W, --width <n>      select width of output options (79<=n<=255).
 +
 
 +
System Options:
 +
 
 +
-B, --below          set process priority to below normal.
 +
    --low            set process priority to low.
 +
-N, --nowarnings    suppress lossyWAV warnings.
 +
-Q, --quiet          significantly reduce screen output.
 +
-S, --silent        no screen output.
 +
 
 +
Special thanks go to:
 +
 
 +
David Robinson      for the publication of his lossyFLAC method, guidance, and
 +
                    the motivation to implement his method as lossyWAV.
 +
 
 +
Horst Albrecht      for ABX testing, valuable support in tuning the internal
 +
                    presets, constructive criticism and all the feedback.
 +
 
 +
Sebastian Gesemann  for the adaptive noise shaping method and the amount of
 +
                    help received in implementing it and also for the basis of
 +
                    the fixed noise shaping method.
 +
 
 +
Tyge Lovset          for the C++ translation initiative.
 +
 
 +
Matteo Frigo and    for libfftw3-3.dll contained in the FFTW distribution
 +
Steven G Johnson    (v3.2.1 or v3.2.2).
 +
 
 +
Mark G Beckett      for the Delphi unit that provides an interface to the
 +
(Univ. of Edinburgh) relevant fftw routines in libfftw3-3.dll.
  
Special thanks:
+
Don Cross            for the Complex-FFT algorithm originally used.</pre>
  
David Robinson      for the publication of his lossyFLAC method, guidance, and
+
===Example drag 'n' drop batch file===
                    the motivation to implement the method as lossyWAV.
+
Horst Albrecht      for ABX testing, valuable support in tuning the internal
+
                    presets, constructive criticism and all the feedback.
+
Sebastian Gesemann  for the noise shaping coefficients and help in using them
+
                    in the lossyWAV noise shaping implementation.
+
Don Cross          for the Complex-FFT algorithm used.</pre>
+
===Example drag'n'drop batch file===
+
 
Simply drag the FLAC files onto this batch file and it will process, recode in FLAC and copy ALL of the tags from the input FLAC file, placing the output lossyFLAC file in the same directory as the input FLAC file. Requires flac.exe and [http://www.synthetic-soul.co.uk/tag/ tag.exe] to be somewhere on the path.  
 
Simply drag the FLAC files onto this batch file and it will process, recode in FLAC and copy ALL of the tags from the input FLAC file, placing the output lossyFLAC file in the same directory as the input FLAC file. Requires flac.exe and [http://www.synthetic-soul.co.uk/tag/ tag.exe] to be somewhere on the path.  
 
<pre>@echo off
 
<pre>@echo off
 
:repeat
 
:repeat
 
if %1.==. goto end
 
if %1.==. goto end
if exist %1 flac -d %1 --stdout --silent|lossywav - --stdout --standard --stdinname %1|flac - -b 512 -o "%~dpn1.lossy.flac" --silent && tag --fromfile %1 "%~dpn1.lossy.flac"
+
if exist "%~1" flac -d "%~1" --stdout --silent|lossywav - --stdout --quality standard ^
 +
  --stdinname "%~1"|flac - -b 512 -o "%~dpn1.lossy.flac" --silent && tag ^
 +
  --fromfile "%~1" "%~dpn1.lossy.flac"
 
shift
 
shift
 
goto repeat
 
goto repeat
 
:end</pre>
 
:end</pre>
  
===Example Foobar2000 converter settings===
+
===lossyWAV and FFTW===
 +
Since version 1.2.0, lossyWAV has been compatible with [[Wikipedia:FFTW|FFTW]] although not dependent on it. Should the user wish to take advantage of the increased processing speed available when using FFTW (from superior FFT implementations), libfftw3-3.dll should be placed in a directory on the host computer which features on the path.
 +
 
 +
===Linux / OS X support: lossyWAV and WINE===
 +
The cause of lossyWAV's WINE incompatibility was found and removed during the development of 1.2.0 and retrospectively amended for 1.1.0b in a maintenance release (1.1.0c). The latest stable version (1.3.0 at the time of writing) is fully supported.
 +
 
 +
<s>[http://caudec.net/ caudec]</s> is a command-line tool that can encode and decode lossyWAV files (lossyFLAC, lossyWV, lossyTAK), using the official binary (lossyWAV.exe) with Wine (see: [http://caudec.net/documentation/windowscodecs/ installation instructions]). Caudec can also test file integrity and compute (and tag) Replaygain data. While it hasn't been tested at the time of writing, it is possible that lossyWAV support in caudec works on OS X as well.
 +
 
 +
===lossyWAV and [[foobar2000]]===
 +
Example [[foobar2000]] converter settings:
 +
 
 
lossyFLAC settings:<pre>Encoder: c:\windows\system32\cmd.exe
 
lossyFLAC settings:<pre>Encoder: c:\windows\system32\cmd.exe
Extension : lossy.flac
+
Extension: lossy.flac
Parameters: /d /c c:\"program files"\bin\lossywav - --standard --silent --stdout|
+
Parameters: /d /c c:\"program files"\bin\lossywav - --quality standard --silent --stdout|c:\"program files"\bin\flac - -b 512 -5 -f -o%d --ignore-chunk-sizes
            c:\"program files"\bin\flac - -b 512 -5 -f -o%d
+
Format is: lossless or hybrid
Format is : lossless or hybrid
+
Highest BPS mode supported: 24</pre>
Highest BPS mode supported: 24 </pre>
+
  
 
lossyTAK settings:<pre>Encoder: c:\windows\system32\cmd.exe
 
lossyTAK settings:<pre>Encoder: c:\windows\system32\cmd.exe
Extension : lossy.tak
+
Extension: lossy.tak
Parameters : /d /c c:\"program files"\bin\lossywav - --standard --silent --stdout|
+
Parameters: /d /c c:\"program files"\bin\lossywav - --quality standard --silent --stdout|c:\"program files"\bin\takc -e -p2m -fsl512 -ihs - %d
            c:\"program files"\bin\takc -e -p2m -fsl512 -ihs - %d
+
 
Format is: lossless or hybrid
 
Format is: lossless or hybrid
 
Highest BPS mode supported: 24</pre>
 
Highest BPS mode supported: 24</pre>
  
 
lossyWV settings:<pre>Encoder: c:\windows\system32\cmd.exe
 
lossyWV settings:<pre>Encoder: c:\windows\system32\cmd.exe
Extension : lossy.wv
+
Extension: lossy.wv
Parameters: /d /c c:\"program files"\bin\lossywav - --standard --silent --stdout|
+
Parameters: /d /c c:\"program files"\bin\lossywav - --quality standard --silent --stdout|c:\"program files"\bin\wavpack -hm --blocksize=512 --merge-blocks -i - %d
            c:\"program files"\bin\wavpack -hm --blocksize=512 --merge-blocks -i - %d
+
Format is: lossless or hybrid
Format is : lossless or hybrid
+
 
Highest BPS mode supported: 24</pre>
 
Highest BPS mode supported: 24</pre>
  
There is a known problem within foobar2000 (although more likely to do with cmd.exe itself) when running an executable within the cmd.exe command line from a path which includes spaces. The suggested fix for this is to enclose the element of the path which contains spaces within double quotation marks ("), e.g. c:\"program files"\directory_where_executable_is\executable_name
+
lossyWMALSL* settings:<pre>Encoder: c:\windows\system32\cmd.exe
 +
Extension: lossy.wma
 +
Parameters: /d /c c:\"program files"\bin\lossywav - --quality standard --silent --stdout|c:\"program files"\bin\wmaencode.exe - %d --codec lsl --ignorelength
 +
Format is: lossless or hybrid
 +
Highest BPS mode supported: 24</pre>
 +
 
 +
Enclose the element of the path containing spaces within double quotation marks ("), e.g. C:\"Program Files"\directory_where_executable_is\executable_name. This is a Windows limitation.
 +
 
 +
lossyWMALSL conversion uses WMAEncode.exe by lvqcl found [http://www.hydrogenaud.io/forums/index.php?s=&showtopic=90519&view=findpost&p=767754 here].
 +
 
 +
===lossyWAV and EAC===
 +
:''For example settings, see [[EAC and LossyWAV]].''
 +
 
 
==Frequently asked questions==
 
==Frequently asked questions==
 
*'''Question:''' Why is the ".wav" file extension used?
 
*'''Question:''' Why is the ".wav" file extension used?
Line 251: Line 417:
  
 
*'''Question:''' Why create a processor which means that I cannot be sure that a lossless file is truly lossless?
 
*'''Question:''' Why create a processor which means that I cannot be sure that a lossless file is truly lossless?
*'''Answer:''' Unless one creates the lossless file personally, one can '''never''' be completely sure that the file is indeed lossless. e.g. If a WAV file is encoded to mp3 and then transcoded to a lossless codec, how can this pre-processing be easily determined?
+
*'''Answer:''' Unless one creates the lossless file personally, one can '''never''' be completely sure that the file is indeed lossless. E.g. a lossless file you receive could be transcoded from [[MP3]] without your knowledge. To distinguish a lossyWAV file from lossless files it is recommended to use the extension .lossy.EXT where EXT is the original extension e.g. .lossy.flac
  
 
*'''Question:''' Is it [[Variable Bitrate|VBR]]?
 
*'''Question:''' Is it [[Variable Bitrate|VBR]]?
Line 267: Line 433:
 
*'''Question:''' Will it ever have a [[Constant Bitrate|CBR]] mode?
 
*'''Question:''' Will it ever have a [[Constant Bitrate|CBR]] mode?
 
*'''Short answer:''' No.
 
*'''Short answer:''' No.
 +
 +
*'''Question:''' Will it low-pass filter my audio?
 +
*'''Short answer:''' No. The frequency limit is for the analysis only. LossyWAV cannot low-pass filter your audio.
  
 
*'''Question:''' Why should I use this?
 
*'''Question:''' Why should I use this?
 
*'''Answer:'''
 
*'''Answer:'''
 
:*high quality
 
:*high quality
:*extremely low chance of audible [[artifact|artifacts]]
+
:*extremely low chance of audible [[artifact]]s
 
:*reasonable [[bitrate]]s
 
:*reasonable [[bitrate]]s
 
:*usable with unmodified, established lossless formats.
 
:*usable with unmodified, established lossless formats.
  
 
==External links==
 
==External links==
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=55522&st=0 Original lossyFLAC thread] - Introduction of the concept by David Robinson (Replay Gain developer) and initial development;
+
*[http://www.hydrogenaud.io/forums/index.php?showtopic=55522 Original lossyFLAC thread] - Introduction of the concept by David Robinson (Replay Gain developer) and initial development
 
+
----
 
+
*[http://www.hydrogenaud.io/forums/index.php?showtopic=109239 lossyWAV 1.5.0 development thread]
*[http://www.hydrogenaudio.org/forums/index.php?showtopic=56129 lossyWAV Development thread] - Conversion of the original Matlab script to Delphi and evolution of the method;
+
*[http://www.hydrogenaud.io/forums/index.php?showtopic=107081 lossyWAV 1.4.0 release thread] - Release of version 1.4.0 on 02 Oktober 2014
*[http://www.hydrogenaudio.org/forums/index.php?act=ST&f=32&t=63225 lossyWAV 1.0.0 release thread] - Release of version 1.0.0b on 12 May 2008;
+
----
 
+
*[http://www.hydrogenaud.io/forums/index.php?showtopic=96635 lossyWAV 1.3.1 Delphi to C++ translation thread]
 
+
----
*[http://www.hydrogenaudio.org/forums/index.php?act=ST&f=32&t=63254 lossyWAV 1.1.0 development thread] - Latest release candidate and beta version in the first post;
+
*[http://www.hydrogenaud.io/forums/index.php?showtopic=81002 lossyWAV 1.3.0 development thread]
*[http://www.hydrogenaudio.org/forums/index.php?s=&showtopic=64617&view=findpost&p=576670 lossyWAV 1.1.0 release thread] - Release of version 1.1.0 on 12 July 2008;
+
*[http://www.hydrogenaud.io/forums/index.php?showtopic=90104 lossyWAV 1.3.0 release thread] - Release of version 1.3.0 on 06 August 2011
 
+
----
 +
*[http://www.hydrogenaud.io/forums/index.php?showtopic=65499 lossyWAV 1.2.0 development thread]
 +
*[http://www.hydrogenaud.io/forums/index.php?showtopic=77042 lossyWAV 1.2.0 release thread] - Release of version 1.2.0 on 16 December 2009
 +
----
 +
*[http://www.hydrogenaud.io/forums/index.php?showtopic=63254 lossyWAV 1.1.0 development thread]
 +
*[http://www.hydrogenaud.io/forums/index.php?showtopic=64617 lossyWAV 1.1.0 release thread] - Release of version 1.1.0 on 12 July 2008
 +
----
 +
*[http://www.hydrogenaud.io/forums/index.php?showtopic=56129 lossyWAV Development thread] - Conversion of the original MATLAB script to Delphi and evolution of the method
 +
*[http://www.hydrogenaud.io/forums/index.php?showtopic=63225 lossyWAV 1.0.0 release thread] - Release of version 1.0.0b on 12 May 2008
  
*[http://wiki.hydrogenaudio.org/index.php?title=LossyWAV lossyWAV wiki entry at hydrogenaudio.org]
 
 
[[Category:Software]]
 
[[Category:Software]]
[[Category:Encoder/Decoder]]
 
[[Category:Lossy]]
 

Revision as of 11:09, 24 May 2019

lossyWAV

Developer(s) Nick.C
Release information
Initial release {{{released}}}
Stable release 1.4.2
Preview release -
Compatibility
Operating system Windows, Linux
Additional information
Use Digital signal processing
License GNU GPL
Website 1.4.0 release thread
1.5.0 development thread

lossyWAV is a free, lossy pre-processor for PCM audio contained in the WAV file format. Proposed by David Robinson, it reduces bit depth of the input signal, which, when used in conjunction with certain lossless codecs, reduces the bitrate of the encoded file significantly compared to unpreprocessed compression. lossyWAV's primary goal is to maintain transparency with a high degree of confidence when processing any audio data.

History

lossyWAV is based on the lossyFLAC idea proposed by David Robinson at Hydrogenaudio, which is a method of carefully reducing the bitdepth of (blocks of) samples which will then allow the FLAC lossless encoder to make use of its wasted bits feature. The aim is to transparently reduce audio bit depth (by making some lower significant bits (lsb's) zero), consequently taking advantage of FLAC's detection of consistently-zeroed lower significant bits within each single frame and significantly increasing coding efficiency.[1] In this way the user can enjoy audio encoded using the same codec (which may be all important from a hardware compatibility perspective) at a reduced bitrate compared to the lossless version.

Nick Currie ported the original MATLAB implementation to Delphi (Many thanks CodeGear for Turbo Explorer!) with a liberal sprinkling of IA-32 and x87 Assembly Language for speed.

Subsequently, lossyFLAC proved itself to work with other lossless codecs, so the application name was changed to lossyWAV.

Since then, Nick has heavily developed and built upon lossyWAV, with valuable tuning performed by Horst Albrecht at Hydrogenaudio. Although the current lossyWAV implementation has built on David's original method, the method itself still very much belongs to its author.

Indicative bitrate reduction

It must be stressed that lossyWAV is a pure variable bit-depth pre-processor in that the overall sample size remains the same after processing but the number of significant bits used for the samples in a codec-block can change on a block-by-block basis. Bits-to-remove from the audio data are calculated on a block-by-block basis (codec-block length = 512 samples, 11.6msec @ 44.1kHz) using overlapping fast Fourier Transform (FFT) analyses of at least two lengths (default quality preset (-q 5) = 32, 64 & 1024 samples). After some manipulation, the results of each FFT analysis for a specific codec-block are then grouped and the minimum value used to determine bits-to-remove for the whole codec-block. Bit removal adds noise to the output, however the level of the added noise associated with the removal of a number of bits has been pre-calculated and the number of bits to remove will depend on the level of the noise floor of the codec-block in question. The added noise is adaptively shaped by default, however the user can select parameters to make the added noise fixed shaped or simply white noise. Each sample in the codec-block is then rounded such that the first <bits-to-remove> lsb's are zero. In this way the wasted bits feature of FLAC et al. is exploited.

lossyWAV Test Set (16 bit / 44.1kHz) Codec lossless --insane --extreme --high --standard --economic --portable --extraportable
10 Album Test Set FLAC 854 kbit/s 627 kbit/s 548 kbit/s 477 kbit/s 442 kbit/s 407 kbit/s 353 kbit/s 311 kbit/s
Nick.C's Full Collection FLAC 882 kbit/s - - - - - - 307 kbit/s

File identification

lossyWAV-processed WAV files are named with a double filename extension, .lossy.wav, to make them instantly identifiable. e.g. ".lossy.flac" would indicate an audio file which was processed using lossyWAV, and subsequently encoded using FLAC.[2]

The --correction parameter is used when processing to create a correction file which is named with the .lwcdf.wav double filename extension. When "added" to the corresponding .lossy.wav, using the --merge parameter, the original file will be reconstituted.

Combinations of lossyWAV with each specific encoder are referred to as lossyX, where X is an abbreviation of the lossless codec name. Combination names are listed in the "known supported codecs" section below.

lossyWAV inserts a variable-length 'fact' chunk into the WAV file immediately after the 'fmt ' chunk. This takes the form:
fact/<size>/lossyWAV x.y.z @ dd/mm/yyyy hh:mm:ss, -q 5
Where the version, date & time and user settings are copied. Additionally, if a lossyWAV 'fact' chunk is found in a file, the processing will be halted (exit code = 16) to prevent re-processing of an already processed file.

The --check parameter can be used to determine whether a file has previously been processed without trying to process it, exit code = 16 if already processed; exit code = 0 if not.

Quality presets

  • --quality insane: (-q I or -q 10) Highest quality preset, generally considered to be excessive;
  • --quality extreme: (-q E or -q 7.5) Higher quality preset, disc space-saving alternative to lossless archiving for large audio collections, considered to be suitable for transcoding to other lossy codecs;
  • --quality high: (-q H or -q 5.0) High quality preset, midway between extreme and standard;
  • --quality standard: (-q S or -q 2.5) Default preset, generally accepted to be transparent;
  • --quality economic: (-q C or -q 0.0) Intermediate preset midway between standard and portable;
  • --quality portable: (-q P or -q -2.5) DAP quality preset for use on a compatible DAP.[3]
  • --quality extraportable: (-q X or -q -5.0) Lowest quality preset for use on a compatible DAP.[4]

All tuning for version 1.0.0 was performed on quality preset --standard with higher presets being more conservative. For versions 1.1.0, 1.2.0 and 1.3.0, tuning effort has been focused on the lowest quality preset in an effort to achieve an effective compromise between resultant bitrate and perceived quality. Quality preset --standard is generally accepted to be (and from testing so far is) transparent. If you find a track which --standard fails to achieve transparency after processing, please post a sample (no more than 30 seconds) in the development thread.

The upper frequency limit used in the calculation of minimum signal power varies, dependent on quality preset, in the range 15.159kHz to 16.682kHz

Supported input formats

  • WAV: 9-bit to 32-bit integer; 1 to 8 channels; sample rate ≥ 32kHz PCM. Very high sample rates (>48kHz) have not been extensively tested. Tunings have been focussed on 16-bit, 44.1kHz samples (i.e. CD PCM).

Codec compatibility

Codec Supported Encoder parameters Combination name
FLAC Yes -5 -b 512 --keep-foreign-metadata lossyFLAC
LPAC Yes -b512 lossyLPAC
MPEG-4 ALS Yes -l -n512 lossyALS
TAK Yes -fsl512 lossyTAK
WavPack Yes --blocksize=512 --merge-blocks lossyWV
WMA Lossless Yes lossyWMALSL
Apple Lossless No
LA No
Monkey's Audio No
OptimFROG No
TTA No
  • Combinations of lossyWAV with each specific encoder are referred to as lossyX, where X is an abbreviation of the lossless codec name.


There is also evidence — so-called "Bit Shifting" — to suggest that lossyWAV may work with MLP, but this remains untested due to prohibitive prices of encoders. At least one commercial DVD-A uses constant bit-depth reduction with lower bit-depth on rear channels.

A comparison of portable media players is here, which shows FLAC and WMA Lossless compatibility among listed players. Any player supported by Rockbox can use FLAC or WavPack files after installing Rockbox.

Important note

NB: when encoding using a lossless codec, please ensure that the block size of the lossless codec matches that of lossyWAV (default = 512 samples). If this is not done then the lossless encoding of the processed WAV file will (almost certainly) be larger than it would otherwise have been. This is achieved by adding the "Encoder Parameters" in the table above to the command line of the lossless codec in question.

Bonus feature

Another, possibly not obvious, feature of lossyWAV is that the processed output can be "transcoded" from one lossless codec to another lossless codec with absolutely no loss of quality whatsoever. This is solely due to the fact that lossyWAV output is designed to be losslessly encoded - something that lossless codecs do very well indeed.

Using lossyWAV

Application settings

lossyWAV 1.4.2, Copyright (C) 2007-2016 Nick Currie. Copyleft.

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful,but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program.  If not, see <http://www.gnu.org/licenses/>.

Process Description:

lossyWAV is a near lossless audio processor which dynamically reduces the
bitdepth of the signal on a block-by-block basis. Bitdepth reduction adds noise
to the processed output. The amount of permissible added noise is based on
analysis of the signal levels in the default frequency range 20Hz to 16kHz.

If signals above the upper limiting frequency are at an even lower level, they
can be swamped by the added noise. This is usually inaudible, but the behaviour
can be changed by specifying a different --limit (in the range 10kHz to 20kHz).

For many audio signals there is little content at very high frequencies and
forcing lossyWAV to keep the added noise level lower than the content at these
frequencies can increase the bitrate of the losslessly compressed output
dramatically for no perceptible benefit.

The noise added by the process is shaped using an adaptive method provided by
Sebastian Gesemann. This method, as implemented in lossyWAV, aims to use the
signal itself as the basis of the filter used for noise shaping. Adaptive noise
shaping is enabled by default.

Usage   : lossyWAV <input wav file> <options>

Example : lossyWAV musicfile.wav

Quality Options:

-q, --quality <t>    where t is one of the following (default = standard):
    I, insane        highest quality output, suitable for transcoding;
    E, extreme       higher quality output, suitable for transcoding;
    H, high          high quality output, suitable for transcoding;
    S, standard      default quality output, considered to be transparent;
    C, economic      intermediate quality output, likely to be transparent;
    P, portable      good quality output for DAP use, may not be transparent;
    X, extraportable lowest quality output, probably not transparent.

Standard Options:

-C, --correction     write correction file for processed WAV file; default=off.
-f, --force          forcibly over-write output file if it exists; default=off.
-h, --help           display help.
-L, --longhelp       display extended help.
-M, --merge          merge existing lossy.wav and lwcdf.wav files.
-o, --outdir <t>     destination directory for the output file(s).
-v, --version        display the lossyWAV version number.
-w, --writetolog     create (or add to) lossyWAV.log in the output directory.

Advanced Options:

-                    take WAV input from STDIN.
-c, --check          check if WAV file has already been processed; default=off.
                     errorlevel=16 if already processed, 0 if not.
-q, --quality <n>    quality preset (-5.0<=n<=10.0); (-5=lowest, 10=highest;
                     default=2.5; I=10.0; E=7.5; H=5.0; S=2.5; C=0.0; P=-2.5;
                     X=-5.0.
--, --stdout         write WAV output to STDOUT.
    --stdinname <t>  pseudo filename to use when input from STDIN.

Advanced Quality Options:

-A, --altspread [n]  disables 'old' sperading mechanism in favour of 'new'
                     mechanism (default spreading uses both 'old' and 'new'
                     mechanisms). Takes an optional parameter, n, which relates
                     to the proportion of adjacent bins taken into account when
                     calculating spread average for a particular bin (0<=n<=1;
                     default = 0.768544).
-a, --analyses <n>   set number of FFT analysis lengths, (2<=n<=7; default=3,
                     i.e. 32, 64 & 1024 samples. n = 2, remove 32 sample FFT;
                     n > 3 add 16; n > 4, add 128; n > 5, add 256, n > 6, add
                     512) n.b. FFT lengths stated are for 44.1/48kHz audio,
                     higher sample rates will automatically increase all FFT
                     lengths as required.
-D, --dynamic <n>    select minimum_bits_to_keep_dynamic to n bits (default
                     2.71 at -q X and 5.00 at -q I, 1.0 <= n <= 7.0.
    --feedback [n]   enable experimental bit removal / adaptive noise shaping
                     noise limiter. Tuning has been carried out at -q X and
                     should have a negligible effect at -q S. Optional setting
                     (0.0 <= n <= 10.0, default = 0.0) automatically selects
                     the following parameters (0 = least effect, 10 = most):
       r, round <n>  limit deviation from expected added noise due to rounding
                     (-2.0 <= n <= 2.0, default = 0.0).
       n, noise <n>  limit added noise due to adaptive noise shaping
                     (-2.5 <= n <= 7.5, default = 0.0).
       a, aclips <n> number of permissible exceedences of adaptive noise
                     shaping level limit (0 <= n <= 64, default = 32).
       A, alevel <n> adaptive noise shaping level limit (-2.0 <= n <= 2.5,
                     default = 0.0).
       V, verbose    enable more detailed feedback information in output.
-I, --ignore-chunk-sizes.
                     ignore 'RIFF' and 'data' chunk sizes in input.
-l, --limit <n>      set upper frequency limit to be used in analyses to n Hz;
                     (12500 <= n <= 20000*; default=16000).
                     *: for 44.1/48 kHz audio. Upper limit for audio of
                     other sampling rates is limited to sample-rate x 45.35%
    --linkchannels   revert to original single bits-to-remove value for all
                     channels rather than channel dependent bits-to-remove.
    --maxclips <n>   set max. number of acceptable clips per channel per block;
                     (0 <= n <= 16; default = 3,3,3,3,3,2,2,2,2,2,1,1,1,0,0,0).
-m, --midside        analyse 2 channel audio for mid/side content.
    --nodccorrect    disable DC correction of audio data prior to FFT analysis,
                     default=on; (DC offset calculated per FFT data set).
-n, --noskew         disable application of low frequency level reduction prior
                     to determination of bits-to-remove.
    --scale <n>      factor to scale audio by; (0.03125 < n <= 8.0; default=1).
-s, --shaping        modify settings for noise shaping used in bit-removal:
       a, altfilter  enable alternative adaptive shaping filter method.
       A, average    set factor of shape modification above upper calculation
                     frequency limit (0.00000 <= n <= 1.00000)
       c, cubic      enable cubic interpolation when defining filter shape
       e, extra      additional white noise to add during creation of filter
       f, fixed      disable adaptive noise shaping (use fixed shaping)
       h, hybrid     enable hybrid alternative to default adaptive noise shaping
                     method. Uses all available calculated analyses to create
                     the desired noise filter shape rather than only those for
                     1.5ms and 20ms FFT analyses.
       n, nowarp     disable warped noise shaping (use linear frequency shaping)
       o, off        disable noise shaping altogether (use simple rounding)
       s, scale <n>  change effectiveness of noise shaping (0 < n <= 2; default
                     = 1.0)
       t, taps <n>   select number of taps to use in FIR filter (8 <= n <= 256;
                     default = 64)
       w, warp       enable cubic interpolation when creating warped filter
    --static <n>     set minimum-bits-to-keep-static to n bits (default=6;
                     3<=n<=28, limited to bits-per-sample - 3).
-U, --underlap <n>   enable underlap mode to increase number of FFT analyses
                     performed at each FFT length, (n = 2, 4 or 8, default=2).

Output Options:

    --bitdist        show distrubution of bits to remove.
    --blockdist      show distribution of lowest / highest significant bit of
                     input codec-blocks and bit-removed codec-blocks.
-d, --detail         enable per block per channel bits-to-remove data display.
-F, --freqdist [all] enable frequency analysis display of input data. Use of
                     'all' parameter displays all calculated analyses.
-H, --histogram      show sample value histogram (input, lossy and correction).
    --perchannel     show selected distribution data per channel.
-p, --postanalyse    enable frequency analysis display of output and
                     correction data in addition to input data.
    --sampledist     show distribution of lowest / highest significant bit of
                     input samples and bit-removed samples.
    --spread [full]  show detailed [more detailed] results from the spreading/
                     averaging algorithm.
-W, --width <n>      select width of output options (79<=n<=255).

System Options:

-B, --below          set process priority to below normal.
    --low            set process priority to low.
-N, --nowarnings     suppress lossyWAV warnings.
-Q, --quiet          significantly reduce screen output.
-S, --silent         no screen output.

Special thanks go to:

David Robinson       for the publication of his lossyFLAC method, guidance, and
                     the motivation to implement his method as lossyWAV.

Horst Albrecht       for ABX testing, valuable support in tuning the internal
                     presets, constructive criticism and all the feedback.

Sebastian Gesemann   for the adaptive noise shaping method and the amount of
                     help received in implementing it and also for the basis of
                     the fixed noise shaping method.

Tyge Lovset          for the C++ translation initiative.

Matteo Frigo and     for libfftw3-3.dll contained in the FFTW distribution
Steven G Johnson     (v3.2.1 or v3.2.2).

Mark G Beckett       for the Delphi unit that provides an interface to the
(Univ. of Edinburgh) relevant fftw routines in libfftw3-3.dll.

Don Cross            for the Complex-FFT algorithm originally used.

Example drag 'n' drop batch file

Simply drag the FLAC files onto this batch file and it will process, recode in FLAC and copy ALL of the tags from the input FLAC file, placing the output lossyFLAC file in the same directory as the input FLAC file. Requires flac.exe and tag.exe to be somewhere on the path.

@echo off
:repeat
if %1.==. goto end
if exist "%~1" flac -d "%~1" --stdout --silent|lossywav - --stdout --quality standard ^
  --stdinname "%~1"|flac - -b 512 -o "%~dpn1.lossy.flac" --silent && tag ^
  --fromfile "%~1" "%~dpn1.lossy.flac"
shift
goto repeat
:end

lossyWAV and FFTW

Since version 1.2.0, lossyWAV has been compatible with FFTW although not dependent on it. Should the user wish to take advantage of the increased processing speed available when using FFTW (from superior FFT implementations), libfftw3-3.dll should be placed in a directory on the host computer which features on the path.

Linux / OS X support: lossyWAV and WINE

The cause of lossyWAV's WINE incompatibility was found and removed during the development of 1.2.0 and retrospectively amended for 1.1.0b in a maintenance release (1.1.0c). The latest stable version (1.3.0 at the time of writing) is fully supported.

caudec is a command-line tool that can encode and decode lossyWAV files (lossyFLAC, lossyWV, lossyTAK), using the official binary (lossyWAV.exe) with Wine (see: installation instructions). Caudec can also test file integrity and compute (and tag) Replaygain data. While it hasn't been tested at the time of writing, it is possible that lossyWAV support in caudec works on OS X as well.

lossyWAV and foobar2000

Example foobar2000 converter settings:

lossyFLAC settings:
Encoder: c:\windows\system32\cmd.exe
Extension: lossy.flac
Parameters: /d /c c:\"program files"\bin\lossywav - --quality standard --silent --stdout|c:\"program files"\bin\flac - -b 512 -5 -f -o%d --ignore-chunk-sizes
Format is: lossless or hybrid
Highest BPS mode supported: 24
lossyTAK settings:
Encoder: c:\windows\system32\cmd.exe
Extension: lossy.tak
Parameters: /d /c c:\"program files"\bin\lossywav - --quality standard --silent --stdout|c:\"program files"\bin\takc -e -p2m -fsl512 -ihs - %d
Format is: lossless or hybrid
Highest BPS mode supported: 24
lossyWV settings:
Encoder: c:\windows\system32\cmd.exe
Extension: lossy.wv
Parameters: /d /c c:\"program files"\bin\lossywav - --quality standard --silent --stdout|c:\"program files"\bin\wavpack -hm --blocksize=512 --merge-blocks -i - %d
Format is: lossless or hybrid
Highest BPS mode supported: 24
lossyWMALSL* settings:
Encoder: c:\windows\system32\cmd.exe
Extension: lossy.wma
Parameters: /d /c c:\"program files"\bin\lossywav - --quality standard --silent --stdout|c:\"program files"\bin\wmaencode.exe - %d --codec lsl --ignorelength
Format is: lossless or hybrid
Highest BPS mode supported: 24

Enclose the element of the path containing spaces within double quotation marks ("), e.g. C:\"Program Files"\directory_where_executable_is\executable_name. This is a Windows limitation.

lossyWMALSL conversion uses WMAEncode.exe by lvqcl found here.

lossyWAV and EAC

For example settings, see EAC and LossyWAV.

Frequently asked questions

  • Question: Why is the ".wav" file extension used?
  • Answer: The ".wav" file extension is used because lossyWAV is a digital signal processor and not a codec. No decoding is required for any program to play a WAV file which has been processed with lossyWAV as it remains compliant with the RIFF WAVE format.
  • Question: Why create a processor which means that I cannot be sure that a lossless file is truly lossless?
  • Answer: Unless one creates the lossless file personally, one can never be completely sure that the file is indeed lossless. E.g. a lossless file you receive could be transcoded from MP3 without your knowledge. To distinguish a lossyWAV file from lossless files it is recommended to use the extension .lossy.EXT where EXT is the original extension e.g. .lossy.flac
  • Question: Is it VBR?
  • Short answer: Yes.
  • Question: Do I need to re-process to change lossless codecs?
  • Short answer: No.
  • Question: Is it transparent?
  • Short answer: At preset --standard, almost certainly.
  • Question: Is it lossless?
  • Short answer: No.
  • Question: Will it ever have a CBR mode?
  • Short answer: No.
  • Question: Will it low-pass filter my audio?
  • Short answer: No. The frequency limit is for the analysis only. LossyWAV cannot low-pass filter your audio.
  • Question: Why should I use this?
  • Answer:
  • high quality
  • extremely low chance of audible artifacts
  • reasonable bitrates
  • usable with unmodified, established lossless formats.

External links