Using WavPack Ver 3.97
WavPack consists of two complimentary executable programs, WavPack and WvUnpack. These programs allow you to compress (and restore) stereo and mono audio files in the .WAV format. The audio files must be simple PCM from 16 to 24 bits per sample. The programs are full 32-bit executables and therefore must only be used under Windows (for real DOS applications or with Windows 3.1 use WavPack 3.4 instead). They are initiated from the MS-DOS command line prompt with the following syntax:
Usage: WAVPACK [-options] [@]infile[.wav]|- [[@]outfile[.wv]|outpath]
Options: -bn = enable hybrid compression, 'n' is kbits/second (kbps)
(n = 24-4800) or bits/sample (n = 4-23); otherwise default
operation is pure lossless compression
-c = create correction file (.wvc) for hybrid mode
-d = delete source file if successful (use with caution!)
-e = create self-extracting executable
(WVSELFX.EXE must be in the same directory as WAVPACK.EXE)
-f (or -ff) = fast (or very fast) lossless compression
-jn = joint-stereo override (where applicable, 0=LR/1=MS)
-h = high quality (best compression in all modes, but slower)
-n = calculate average and peak quantization noise (hybrid only)
-rn = raw mode for non-wav files (1=mono/2=stereo)
-sn = noise shaping override (hybrid only, 0=off/1=1st order)
-t = copy input file's time stamp to output file
-y = yes to all warnings (use with caution!)
Usage: WVUNPACK [-options] [@]infile[.wv] [[@]outfile[.wav]|outpath|-]
Options: -d = delete source file if successful (use with caution!)
-t = copy input file's time stamp to output file
-v = verify source data only (no output file created)
-y = yes to overwrite warning (use with caution!)
Wildcards may be used in the input file specification if the output file spec is a valid destination path (or is not specified), and both programs will warn before overwriting any file. If a filename is preceeded with a '@', then that file will be processed as a file list. If a '-' is specified for the input file in WavPack (or the output file in WvUnpack), then stdin (or stdout) will be used instead of a file. The programs will display progress in percentage complete and when finished with each file will give the compression ratio, whether the compression was lossy or lossless, and the processing time. They will also display the progress percentage for the whole batch of files on the title bar which is useful when they are being run minimized.
The compressed file format (.WV) contains all original header information and the compressed audio data for one .WAV file. The file can be used by WvUnpack to restore the original file, or the .WV file can be played directly in Winamp using the supplied plug-in. WvUnpack restores the original file extension if one is not specified; this is handy when using the raw mode to compress non-wav files.
The hybrid mode is a unique feature of WavPack. The default operation of WavPack is pure lossless, which means that the .WV file contains all the information that was in the original .WAV file. The hybrid mode (initiated with -b) allows the user to specify a target bitrate for the output file, either in kilobits per second (kbps) or bits per sample. If the track can be losslessly compressed without exceeding the specified bitrate, then it will be and WavPack will report the compression as lossless. If lossless compression would exceed the specified bitrate, then WavPack will begin carefully discarding the least significant portion of the audio information to stay within the limit. Every effort is made to keep this inaudible, including the use of joint stereo, dynamic bit allocation and noise shaping. WavPack will report this as "lossy" compression. Although the option accepts bitrates as low as 24 kbps, the actual value that WavPack can achieve is usually much higher than that. For example, with CD-audio sampled at 44.1k the lower limit is about 265 kbps.
If the -c option is specified (in addition to the -b option), then WavPack will generate an additional file that will contain the information that was discarded to generate the lossy .WV file. This file will have the same name as the .WV file but will have the extension .WVC (the 'c' is for "correction"). When WvUnpack is used to restore the .WAV file, it will attempt to find the .WVC file in the same directory as the .WV file. If it is found then the decompression will be lossless and will be reported as such, otherwise lossy decompression will be reported (assuming that any information was actually discarded during the original compression). If -c is specified but no actual information is discarded, the correction file will be deleted. The extra overhead involved with having these two files instead of a single pure lossless file is usually less than 1% of the original .WAV file. Note that CRCs are stored for both the lossy and lossless versions, so error detection works correctly whether the .WVC file is used or not.
I have done some informal testing and have found that 320 kbps gives audibly transparent operation in the vast majority of cases (at 44.1k, so this should be scaled up for higher sample rates). This is a reasonable size for keeping music permanently on a hard drive and for sharing, and also happens to be the maximum bitrate for the popular MP3 format. At bitrates above 320 kbps, the measured quality of the hybrid mode rises rapidy (about 1 dB less added noise for each 14 kbps), so WavPack provides an ideal bridge between the complex perceptual encoders and the lossless compressors.
Two options are provided to alter the default configuration of the hybrid compression. WavPack normally uses true-stereo, which means that it processes the two channels separately. However, in some cases (higher bitrates and little stereo information) it can be advantageous to activate joint-stereo in which case WavPack will work on the sum and difference of the two channels instead (sometimes called mid-side). Use the -j1 option to turn on joint-stereo processing if desired. Joint-stereo is the default for some lossless modes and can be turned off with -j0, but this can only change the compression ratio, not the sound. WavPack also uses first-order noise shaping to decrease the audibility of the added quantization noise by trading more noise at higher frequencies for less noise at lower frequencies (where it is more audible). However, the total noise is increased and so this processing is only used by default at higher sampling rates (above 64 kHz). Use the -s option to override this.
WavPack can also be used to create self-extracting archives. In this way it is possible to distribute compressed audio without having the recipient install any other programs (or have any dlls) to unpack the archives. When the .exe file is run (directly or by double-clicking) it extracts the original .wav file into the same directory. If it can't (because the file exists or it is run on a read-only device) then it displays a standard Windows "Extract to" dialog box and allows the user to specify the destination. The self-extracting feature can be used with WavPack's hybrid and raw modes as well as pure lossless. If a .WVC file (with the correct name) is present in the same directory as the executable, then a lossless extraction is automatically performed. The .exe files cannot be unpacked with WvUnpack or played with the Winamp plugin.
For detailed instructions on creating self-extracting WavPack files from existing .WV files, simply run the WvSelfx program. Otherwise, just use the -e option.
ID3v1 and APEv2 Tag Support
WavPack provides limited support for tags. Although it will not create the tags, it will allow you to use another program to append any kind of tag to the end of the .WV file (and the .WVC file, if desired). During decompression, WvUnpack will discard the tag so as not to corrupt the .WAV file. Additionally, if the tag is an ID3v1 tag or an APEv2 tag, the Winamp plugin will display the full artist and title in the playlist and additional items in the info dialog.
WavPack and its associated utilities are free programs; feel free to give them to anyone who may find them useful. There is no warrantee provided and you agree to use them completely at your own risk. Be sure to visit www.wavpack.com for the latest version of WavPack.
- The compression ratio is level dependent; softer files (or softer portions of large files) compress better than loud files. Therefore, if you are going to "normalize" files to a higher level, it is better to do this after the compress/restore cycle.
- Audio files that are stored as stereo but are really mono (or "almost" mono) will compress much better than real stereo files. Also, 20-bit files will compress better than 24-bit files (even if they are not properly identified as such in the header.)
- For "worst case" files (those with very high level, noise, or distortion) WavPack may actually create a .WV file slightly larger than the original .WAV file, and this will be indicated as "negative" compression. Some lossless compression programs (like WinZIP) detect this case and simply store the data without compression. However, since I have not actually seen a real audio file do this, I have decided not to go to the extra trouble of handling such a case and besides, even if this happens, the .WAV file will still be correctly restored.
- The "raw" mode allows WavPack to losslessly compress any file, regardless of format. Because it is optimized for audio, however, the compression percentage for non-audio files will be poor, in fact it will usually be slightly negative. However, if those files contain a significant amount of 16-bit audio data (mono or stereo) then this data will compress much better. I have tested this with Adaptec's .CIF files and it works very well for archiving entire CDs. The program requires the data to be stored in Intel format (LSB first) so it might not work well with Mac audio files which (I believe) are Motorola format. With version 3.96 the raw and hybrid modes are usable together (with a warning) although keep in mind that any non-audio information in the file may be corrupted.