home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 55
/
Amiga_Dream_55.iso
/
RISCOS
/
APPS
/
MUSIC
/
0-N
/
COMPRE.ZIP
/
!Compress
/
!Help
< prev
next >
Wrap
Text File
|
1996-04-02
|
23KB
|
508 lines
############################################################################
# #
# Sample Compressor v. 1.26 #
# #
#==========================================================================#
# #
# by David Radford #
# #
#==========================================================================#
# #
# This program is freeware: it may be copied #
# freely as long as no profit is made in the process #
# #
############################################################################
Overview
========
This application allows you to compress (and subsequently decompress)
Armadeus-format sample files. A separate program is available from public
domain libraries, etc. to play back compressed samples directly, and even
play back sequences of compressed samples. Also, a library of compression
routines is provided by !CompUtils so you can even add support for
compressed samples to your own programs.
Related programs
================
The following packages may also be of interest to you. None of them are
necessary to use !Compress, but they are all freely available from my web
page so you can download them from there if you would like a copy.
!Player - Plays back compressed samples directly from disc.
!CompUtils - The raw compression/decompression code for your own use.
!HeapMan - The memory manager used in !Compress.
Why compress samples?
=====================
Samples take up an enormous amount of room. Good quality samples (from
20.833KHz upwards) take up at least 20K for each second. Assuming the
maximum capacity of a standard floppy disc is 780K, then the largest sample
to be stored on disc is 39 seconds. If you want longer samples you have to
reduce the quality. On the other hand, if you compress the data, you can
store much longer samples on a disc. Of course, if you only have a 1
Megabyte machine you would have problems trying to take a sample longer than
780K anyway. Another use of compressed samples is to save space on a hard
disc. Bulletin boards sysops/users may find this particularly useful, as
less disc space is wasted by these files, and download/upload times are
greatly reduced.
Games are another area that can benefit from compressed samples, allowing
either more samples or more code to be crammed onto the disc.
How to use !Compress
====================
!Compress is pretty intuitive, so the best way to learn to use it is to
actually try it out. Play around with it for a while. You'll soon get the
hang of it. Most of your questions can be answered using Acorn's !Help
application. You can skip most of the rest of this section - it sounds far
more complicated than it actually is. Okay...
To compress an Armadeus file drag it to the icon on the icon bar, or any
window belonging to !Compress. A save dialogue box will then appear showing
a compressed sample file (type &350 - 'CSample'). This is a 'permanent'
save box - it stays on the screen until you drag the icon to a directory
display or discard the file by clicking on the box's quit icon. Alter the
filename if desired and drag the file icon to a suitable directory display.
The application will then compress the file and save it under the new name.
By the way, a file is *not* loaded when you drag it to !Compress - !Compress
just remembers the file's name and reads the data straight from the disc
when it needs it. This allows you to compress/decompress files that are
physically too large to fit in memory, which can be useful if you're in the
habbit of sampling straight to disc (which is becoming more commonplace
these days). !Compress can only cope with samples of less than 256Mb. If you
want to compress a sample larger than this (what *have* you been doing?!)
you'll have to split it up into chunks of slightly under 256Mb and compress
each chunk separately.
When you drag the file from the save box to an appropriate directory
!Compress does not necessarily start compressing the file immediately.
Instead the source filenames (along with their respective destination
filenames) are added to a queue of files to be processed. When !Compress is
not busy doing anything important it takes a file from the queue and
processes it. In fact, it behaves a little like !Printers in background
mode, except that !Printers makes a copy of the file to be processed whereas
!Compress works directly on the original. For this reason it is not possible
to overwrite the original file with the output from !Compress.
!Compress allows you to decompress a file in exactly the same way as above.
The output at present is always in Armadeus format (8-bit linear signed) but
this will have to change in future versions when 16-bit support is added.
Can anyone suggest a suitable format? One already in use, that is.
The compression/decompression is done mainly in the background. During the
operation the icon on the icon bar changes to an hourglass. It stays like
this until all the files on the queue have been processed, so you can always
tell when !Compress is busy. You can still add files to the queue regardless
of how busy it is.
File selections, directories and libraries
==========================================
If you drag a selection of files from a directory to !Compress, a save box
will pop up allowing you to save them in one directory, compressing or
decompressing them in the process. In fact, whenever !Compress has a save
box open you can drag extra files in to add them to the selection. Every
item will be stored in the same directory, determined by the save box. As
soon as you drag the directory icon out to a suitable disc, !Compress
transfers the names of the selected files to its internal queue and the save
box disappears.
!Compress can also handle directories. If you drag a directory to !Compress
then the moment it is added to the queue the whole directory (and any
sub-directories) will be scanned for Armadeus files or compressed samples
which will be added to the queue. The output of a directory is another
directory holding the processed files, maintaining the directory structure
where appropriate.
!Compress can decompress sample libraries, though at the moment it can't
produce new ones. These files have to have a filetype of &352 rather than
Data (&FFD) in order to be recognised. This should change in the future. The
output for a sample library is a directory containing Armadeus files, one
for each sample in the library.
The status window
=================
The status window can be displayed by clicking Select over the icon on the
icon bar. (Clicking with Adjust will open the choices window.)
The status window is in two parts: the upper part gives information on the
file currently being processed, and the lower part controls the queue. You
can hide the top part by means of the toggle size icon. Having the top half
invisible or hidden by another window can lead to noticable speed increases,
since there is no need for the Wimp to keep updating the screen as
information changes.
(Incidentally, the toggle size icon can be used to hide or reveal the upper
part of the window. The 'full-size/half-size' information is saved along
with all the other choices when you choose 'Save choices' from the icon bar
menu.)
The queue management section is the most important part of this window. The
'Current file' box gives the name of the file currently being processed, and
'Next file' is the name of the file at the head of the queue (ie. the next
to be processed). Three buttons are provided (and duplicated in the menu) to
control the queue. These are:
Abort - Abandons the file currently being processed (if there is one), then
gives you the option of clearing the queue as well.
Pause - Pauses all processing. Files can still be added to the queue while
paused. 'Pause' changes to 'Continue' - clicking again restarts the
queue.
Skip - Only appears when activity is paused *and* no file is in the middle
of being processed. It causes the first file in the queue to be
discarded. Normally only present after an error has occurred.
If an error occurs during processing, the current file is abandoned and
returned to the front of the queue. The queue is then paused. The 'Pause'
button is labelled 'Retry'. The functions of the buttons become:
Abort - Discards the remainder of the queue.
Skip - Discards the file that caused the error (ie. the one at the head of
the queue) then restarts processing.
Retry - Attempts to process the offending file again.
The choices window
==================
This window can be opened by clicking Adjust over the icon on the icon bar,
or choosing 'Choices...' from the icon bar menu.
Format
------
Specifies the format in which future compressed samples will be stored.
Changing this will have no effect on files already in the queue, but all
files added to the queue from then on will be compressed using the new
format. For a full description of the pros and cons of each Type, see below.
Resolution
----------
Specifies the resolution to be used when compressing samples. Changing this
will not affect any files already in the queue. By reducing the resolution,
some detail is thrown away, but this can lead to significant improvements in
compression. For example, a good quality 8-bit sample that is only going to
be played through the internal speaker can be reduced to 7-bits with no
appreciable loss.
There is no point in using a resolution greater than that of the source
file, so using 12-bits when the original was only 8-bits is only going to
work against you. Note that when decompressing the resolution gets rounded
up to the nearest multiple of 8, thus 7-bits becomes 8-bits and 12-bits
becomes 16-bits. Documentation therefore uses '16-bit' to refer to all
resolutions from 9 to 16, and '8-bit' for 8 downwards.
Not all sample Types support 16-bit samples, so it may be that everything
above 8-bits will be greyed out.
Data
----
You can use this option to determine the raw data format used for storing
the compressed sample: Linear or Logarithmic. Linear is the standard format,
but Logarithmic may lead to slight improvements in compression. Logarithmic
causes a minor drop in quality and only works to a maximum of 8-bits. Not
all sample Types support logarithmic data, but they all support linear.
Scale to max volume
-------------------
Scales samples to full volume before compressing them. It determines the
maximum amplitude of the sample and attempts to scale it up to 127 if it
can. It's only really of use when compressing a large number of samples and
loading each into a sample editor would be very tedious and time consuming.
Normally you would have this option switched off.
Fast processing
---------------
Speeds up processing but slows down the rest of the desktop.
Thresholds
----------
!Compress can optionally apply thresholds to the start and end of a sample
before compressing it. This can be useful for stripping off any 'silence'
before or after the main sound, thus tidying it up slightly. Of course,
it's always preferable to do this sort of thing by hand in a sample editor
such as Armadeus, DSEdit, SFXED, etc. Thresholding is intended mainly for
people who want to compress a large number of samples and trimming them all
by hand would be both tedious and unacceptably time-consuming.
To apply the threshold to the start of the sample, select the 'Start' icon.
To apply the threshold to the end of the sample as well (or instead) then
select the 'End' icon. Now specify a threshold value in the 'Level' box. If
the box is empty or contains 0, thresholding will not be performed. Valid
threshold levels are in the range 1-127.
For example, to strip off *absolute* silence use a threshold of 1. However,
even the best of samplers would have been unable to completely eliminate all
noise, so a more realistic threshold would be 2.
When thresholding is enabled, the sample is scanned from the start or the
end (or both) until the amplitude of the sample reaches or exceeds the value
in the 'Level' box. This point then becomes the new start or end of the
sample. The function is normally used for removing unwanted quiet patches at
the start and/or end of samples.
NB - If scaling is enabled, thresholding is performed BEFORE scaling.
Blocks per group
----------------
This is a performance tweak for sample Types 1-3. See the description of
Type 1 below. The smaller the value, the greater the adaptability of the
compression algorithm, but the greater the overheads.
Header size
-----------
This is a performance tweak for sample Types 1-3. See the description of
Type 1 below. The larger the value, the larger the overheads, but more
compression methods can be brought to bear on the sample.
Compression Types
=================
There now follows a brief description of each compression algorithm, or
Type. It will help you to determine the best Type for your needs. 'Lossless'
means that the data is unmodified by the compression process, whereas
'lossy' means there may be slight degradation. Both cases only apply to
linear output - logarithmic compression is always lossy.
Type 0
------
The very first algorithm. Samples of this Type will hopefully be obsolete,
because it isn't all that good. !Compress only really supports output of
this Type in case you have any programs which can only read this Type, so
its use should be discouraged.
This is mainly lossless, but there may be slight adjustments to some bytes.
Both linear and logarithmic data is supported, but only up to 8 bits. 0-15
zero bytes may be added to the end of the sample to pad it out to a multiple
of 16.
Type 1
------
The successor to Type 0. This is an adaptive alogithm that periodically
switches between three different compression methods depending on which
would give the best compression. There is room for a fourth method though
none such exists. If one is added at a later date it will be classed as
Type 3.
The 'blocks per group' field in the choices window controls how often
!Compress is allowed to switch between methods. A 'group' is the data
between two such switches, so a high value here makes switching less
frequent and makes the algorithm less adaptable. However, each group
requires a header of either one or two bits, so increasing 'blocks per
group' means that fewer of these bits need to be added. The header size can
be set to either 1 or 2 bits, but setting it to 1 causes !Compress to
consider only 2 of the available 3 compression methods. It's all a case of
swings and roundabouts. The default settings are usually adequate.
This is mainly lossless, but there may be tiny adjustments to some bytes
(very, very rarely). These will be completely inaudible so shouldn't be a
problem. Both linear and logarithmic data is supported, but only up to 8
bits. 0-15 zero bytes may be added to the end of the sample to pad it out to
a multiple of 16.
Type 2
------
Identical to Type 1, but with a compressed table that may shorten a file by
a handful of bytes compared with Type 1. This is therefore the current
standard, but is 8-bit only.
Type 3
------
Not yet created. Essentially Type 2 with the fourth compression method added
(see Type 1 for a information).
Type 4
------
A 16-bit ADPCM algorithm. It has a fixed compression ratio of 25% for 16-bit
samples, or 50% for 8-bit ones. To be more precise, it stores all samples
at a resolution of 4-bits, but the nature of the algorithm means that the
expected drop in quality does not occur. There is a slight drop of course,
but it is so small as to be unnoticable.
Type 4 is lossy (rather like JPEG), linear-only, and can support up to the
full 16-bits. There is absolutely no point in selecting a resolution lower
than this since it reduces quality and has no effect on the compression
ratio.
Note that you can usually get better compression by using Type 2 or 6 at a
resolution of 7-bits, but the quality of a Type 4 sample compressed from
a 16-bit source may well be higher. Type 4 is also much simpler (and
therefore probably quicker) and uses smaller coders/decoders.
Type 5
------
Not yet available. Basically Type 4 with entropy coding as an output stage.
In other words, it can be considered as Type 4 followed by Type 6 to make it
even smaller. The compression ratio is therefore variable, but lower than
Type 4 for pretty much all of the time.
Type 6
------
A more recent alternative to Type 2. For those in the know it is simply a
case of entropy coding the sample deltas. Compression is roughly the same,
but the statistics tend to vary a lot with different resolutions and data
formats. The decompressor is a little slower than the Type 2 version, making
it less desirable if speed is critical, such as for realtime playback on a
lower-end machine from direct from floppy.
The advantage of Type 6 is that it is completely lossless. Both linear and
logarithmic data is supported, but only up to 8-bits. 16-bit support may be
added at a later date, in which case the 16-bit format will be assigned
a new Type.
History
=======
No, this isn't the first release of !Compress, but it is the first for a
year or two, and it is the first to have a history list. Unfortunately I
can't remember all the differences between 1.25 and previous versions, so
you'll have to have a play if you're upgrading. Sorry. I'll keep a proper
history from now on.
Possible future upgrades
------------------------
- 16-bit input and output from !Compress will be added as soon as I find a
suitable alternative to Armadeus files.
- Type 5 support will be added when I get the time.
- Type 3 support might get added if I can think of a way of improving Type 2
significantly.
- App-to-app file transfer might be possible, but I don't have any modern
sample editors to test this on so I can't guess.
- Dragging a file into !Compress with Ctrl down opens a window displaying
info on the file (eg. Type, sample period, size, compression ratio, etc).
- Dragging a file in with Shift held down adds the file to the queue, but
when finished the source file is deleted.
- A complete overhaul of the front end that allows multiple operations at
once, so that a Filer-style status window could be used, and !Compress
would then blend into the desktop a lot more. Also no need for a messy
queue system.
- A 'best format' option will be added, possibly with a separate control
window. Files compressed in this format will be compressed in each format
in turn, writing the output to !Scrap. Then the smallest one generated
gets copied to the output. Thus you can ensure the best possible
compression ratio.
Version 1.26
------------
- Silly window opening problems fixed. There is a flaw in Risc OS when it
comes to toggling windows to full size.
- Type 4 support added. Program changed internally to support 16-bit sample
data. However, no raw 16-bit file format has been decided on to replace
Armadeus files.
Version 1.25
------------
- File processing queue added. Previously only single files or single
directories could be compressed.
- Can decompress an entire library, though extracting single files and
modifying libraries is not yet possible.
- Compression now makes use of code from !CompUtils rather than the messy
hack used before.
- Multiple Type support added for both decompression and compression.
- Tentative 16bit support added (though not yet visible) for when I can find
a suitable 16bit alternate to Armadeus files.
- Interactive help supported (including menu help).
- RISC OS 3.10 and up only (sorry about this, but things must move on)
- The source file is not loaded directly into memory, but read from the disc
in chunks. This disposes of the need for virtual memory if your
requirements are excessive.
- !Compress now uses the small version of HeapMan for all memory management.
(Contact me if you are interested in a copy. It's a freeware sliding heap
system with the emphasis on memory efficiency for medium-to-large blocks.
Static blocks are supported as well. I haven't released it yet because I'm
bored with writing all the documentation for it. So many projects never
get released because I *hate* writing the docs.)
- 3D templates to replace the naff, stodgy ones used before.
- Should work perfectly with any desktop font that isn't more than about
20% wider than the system font.
- The 'enhanced' term has disappeared in favour of 'Linear/Logarithmic'. The
former term had its origins in the very first version of !Compress, which
was only intended for producing files for !Player. 'Enhanced' no longer
has any meaning in the current context.
- Performance information for samples of Types 1 and 2 is now adjustable
(group size and header size).
- The choices can now be saved as the default settings. Delete the 'Choices'
file to reset them (do this before passing the program on). Don't get
confused and delete the 'Default' file instead, or you'll be right up the
gumtree!
The author
==========
If you want to send me comments, suggestions, bug reports, etc. (or just
want a chat) you can contact me at any of the following addresses:
Email: radford@argonet.co.uk
Fidonet: David Radford at 2:250/219.6
Snail: David Radford
64 Molyneux Road,
Westhoughton,
Bolton,
Lancs.
BL5 3EU
Web: http://www.argonet.co.uk/users/radford/
Email is preferred. It's the easiest to forward on, and harder for me to
forget to send a reply (I'm very easily distracted!). Updates will be made
available via my web pages, so check there if you're looking for the
latest version.
Please mention the version number of !Compress in any correspondance - your
problems may be the result of using an ancient version of the program. I
regularly find people uploading versions 3 years old to bulletin boards,
which really annoys me, especially if I've just uploaded the latest version
there already.
Copyright notice
================
This application with all its contents is the copyright of David Radford. It
may be freely distributed by individuals, P.D. libraries, magazine discs,
etc. provided it is copied in whole and unaltered. (Please delete the
Choices file if one is present before passing this program on.) Distribution
of this application with any commercial program is prohibited unless
permission is obtained from me beforehand.
(c) David Radford 1991-1996