home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best Objectech Shareware Selections
/
UNTITLED.iso
/
boss
/
musi
/
misc
/
044
/
compraw.doc
next >
Wrap
Text File
|
1992-11-08
|
10KB
|
219 lines
Program: COMPRAW.ZIP (freeware)
Date: 8 November 1992
Version: 1.00
Files: COMPRAW.EXE
COMPRAW.DOC
COMPRAW.PAS
Copyright (c) 1992 François Jalbert (jalbert@IRO.UMontreal.CA)
A few more copyright notices so everybody is happy:
Sound-Blaster (c) 1989-1991 Creative Labs Inc
Turbo-Pascal 5.0 (c) 1988 Borland International
LZEXE 0.91 (c) 1989 Fabrice Bellard
PKZIP 1.1 (c) 1989-1990 PKWARE Inc
LHA 2.13 (c) 1988-1991 Haruyasu Yoshizaki
ARJ 2.20 (c) 1990,91 Robert K Jung
Warning! This documentation contains extended characters!
Description:
───────────
This program will help lossy compress and decompress 8-bit unsigned raw sound
files. Extensive attention has been paid to efficiency and to robustness. Both
DOS style and UNIX style syntax is supported.
Justification:
─────────────
Since I bought a Sound-Blaster 2.0, I have been sampling various sounds and I
soon discovered the need to lossy [de]compress samples to save disk space.
The Sound-Blaster supports in hardware a proprietary type of .VOC lossy sound
compression which is not understood by anybody else, i.e. it is relatively
useless.
I monitored SIMTEL for about one year, but no freeware/shareware lossy raw
sound [de]compression ever appeared on it.
So I began contemplating various ways to [de]compress sound using approximate
dictionary techniques. I looked at the source code of precursors of LHA. I read
a book on data compression techniques. I even began preliminary Pascal
programming and got the I/O buffering stuff running. But it was all very
complicated and I somehow found ways to delay.
A few days ago, Mark Cox, the renowned author of MODPLAY, mentioned to me that
simply zeroing out the least significant bits of raw sounds should be of use
somehow. What a simple and wonderful idea! COMPRAW was born, and 2 days later,
this small project was successfully completed.
Feel free to pass along and share copies of my work. If you have any comments
or suggestions, I would be very happy to hear from you. My internet e-mail
address can be found at the top of this brief document.
Operation:
──────────
The syntax is: COMPRAW <infile> <outfile> /<rate> < /c | /d >
where each of the four parameters must be supplied.
<infile> Input raw sound file
<outfile> Output raw sound file
/<rate> 8 to <rate> compression ratio from 7 (low) to 1 (high)
< /c | /d > Compression or Decompression flag
Functional description:
───────────────────────
Compression is done in two steps:
1) Use COMPRAW /C to log scale and simplify the raw sound.
2) Use LHA (say) to compress the simplified raw sound file.
Decompression is also done in two steps:
1) Use LHA (say) to decompress, yielding the simplified raw sound file.
2) Use COMPRAW /D to spline and log unscale, yielding the rebuilt raw sound.
COMPRAW compression of the raw sound involves two steps:
1) The raw sound is scaled according to a simple log 2 scale. This was
required because most of the information lies around 80H.
2) The scaled raw sound is subjected to a zeroing of the requested number
of least significant bits. Compression rates of 8:7 (poor) to 8:1 (high)
are supported.
Here is 8:1 COMPRAW compression of already log scaled raw sound:
FF──────────────────────── FF────────────────────────
* *
* *
* *** *
* * **** ***** ******
*
*
* *
80──────────────────────── ==> 80────────────────────────
* *
*
* *
* ****** ***
*
*
*
00──────────────────────── 00────────────────────────
Once COMPRAW compression is done, your favorite compression utility will have
no difficulty compressing and decompressing the simplified raw sound file. I
decided that rather than spend hours redoing what's already available, it was
better to let expert programs such as LHA do their magic. I also tried to pack
the simplified raw sound to make long continuous chains of bits, but this
hinders severely LHA and simply does not pay off.
COMPRAW decompression of the simplified raw sound involves two steps:
1) A simple spline is built in such a way that if the splined raw sound was
COMPRAW compressed again (without log scaling), it would be identical to
the original simplified raw sound.
2) The splined raw sound is unscaled according to the simple log 2 scale.
Here is 8:1 COMPRAW decompression of simplified raw sound:
FF──────────────────────── FF────────────────────────
**** ***** ****** *** * ****
* * *
* * * *
80──────────────────────── ==> 80────────────────────────
* * * *
* *
****** *** ** *
00──────────────────────── 00────────────────────────
The loss of information is obvious, but at least the nasty staircases are gone.
They are the ones responsible for the hissing background noise in the
simplified raw sound if it were simply log unscaled.
Benchmarks:
───────────
Of course, the first question that comes to one's mind is: How well does such a
combo COMPRAW-LHA perform?
Well, first of all, I tried PKZIP, ARJ and LHA on various 8KHz simplified raw
sound. PKZIP was the fastest, but compressed poorly. ARJ and LHA are very
close, with LHA slightly better. This is all version dependent and I am sure
that the picture could be completely different in a year or two. But for now, I
would recommend LHA, or if you require multi-volume capability, ARJ.
For the following comparison, I will use LHA. Here is a typical 8KHz raw sound
file and how LHA compresses it. This is our reference.
8TO8 RAW 902950 11-08-92 12:00p
8TO8 LZH 622553 11-08-92 12:01p
Now, I use COMPRAW with 8:5, 8:4, 8:3 and 8:2 rates. The simplified raw sound
is as big as the original raw sound, but when compressed...
8TO5 LZH 378372 11-08-92 12:02p
8TO4 LZH 264439 11-08-92 12:03p
8TO3 LZH 164358 11-08-92 12:04p
8TO2 LZH 94152 11-08-92 12:05p
The space required is respectively 61%, 42%, 26% and 15% of what it would have
been without COMPRAW. These are typical values.
Sound quality wise, 8:5 sounds as good as the original, 8:4 is very similar,
8:3 is definitely different, with some low v