home *** CD-ROM | disk | FTP | other *** search
- ############################################################################
- # #
- # SampleLoader module #
- # #
- #==========================================================================#
- # #
- # by David Radford #
- # #
- #==========================================================================#
- # #
- # These files are a part of !CompUtils and may not be distributed #
- # separately other than as laid down in the !ReadMe file. #
- # #
- ############################################################################
-
- Overview
- ========
-
- This directory contains a module which allows you to decompress samples
- using simple *commands. The module is not really a very practical way of
- adding support of compressed samples to a multitasking application, since it
- would be yet ANOTHER module loaded into the RMA. However, for games and
- other single-tasking applications it would be perfectly okay providing you
- remember to kill it off after you have finished with it.
-
-
- The *commands
- =============
-
- There are three *commands:
-
-
- *LoadSampleBufferSize <size>
- ----------------------------
-
- This command attempts to claim a block of memory from the RMA to use as a
- source buffer during decompression. <size> is given as a number of bytes,
- and the default base is base 10. The minimum value is 16 bytes (but it
- isn't really sensible to go below 256 bytes), and the maximum is 40960 (40K).
- The module automatically claims a 2048-byte buffer (2K) when first loaded,
- and this may well be sufficient for most needs. Increasing the buffer size
- *should* speed up loading from floppy discs.
-
-
- *LoadSampleType 0|1
- -------------------
-
- This command allows you to choose the output format of all subsequent
- samples. 0 is logarithmic (VIDC format), and 1 is linear signed. The default
- value is 0.
-
-
- *LoadSample <filename> <load address> [<sample ID> [<header address>]]
- ----------------------------------------------------------------------
-
- This is the main command. In its most simple form, it takes the file given
- and decompresses to the specified address. (The default base for the address
- is base 16, ie. hexadecimal.) Be sure that you have enough memory spare to
- load the sample. Remember that the file size of a compressed sample is far
- smaller than the size of the actual decompressed sample! On a normal file,
- the <sample ID> parameter is ignored if given.
-
- As well as standard compressed files, the module also supports library
- files. These consist of several compressed samples all lumped together into
- one file. The format of these files is given in a later section of this
- document.
-
- Since library files can hold many samples, each sample is given a unique
- sample ID. When a library file is accessed by the module, it attempts to
- load the sample referenced by <sample ID>. If the parameter is omitted, the
- first sample in the library is used instead. An error is generated if the ID
- didn't match any of the samples (the test is case-insensitive).
-
- The header and table of entries in a library can be separated from the main
- library and stored somewhere in a separate file. This has the advantage that
- it may be more readily accessable from another program, and it also stops
- people pinching samples from your library, since only the first sample can
- be recovered without the list of file offsets. If you do this, the header
- must have been loaded into some area of memory before using the *command.
- The address can then be passed in hexadecimal as <header address>.
-
- Note that the decompressed sample is stored as raw 8-bit data. The sample
- period information is omitted.
-
-
- Libraries
- =========
-
- The filetype for a library is &FFD (Data) though this may change in the
- future. The basic layout of a standard library is:
-
- 1) Header
- 2) Table of entries
- 3) Compressed sample data
-
- The first two of these can be held in a separate file from the third, should
- you so desire.
-
- The header is 12 bytes long:
-
- +0 Four byte text string ("LIBR") identifying this as a library.
- +4 Number of entries in table
- +8 Length of each entry
-
- This is immediately followed by the table. Each entry is currently 24 bytes
- long, but this could increase in the future, so make sure you use the value
- in the header when reading the file.
-
- +0 Sample ID. Up to ten characters, followed by a <CR>.
- +12 Offset into library file of the associated sample data.
- +16 The length of the compressed sample data.
- +20 The length of the original sample.
-
- Libraries are supported by the SamplePlayer module (part of !Player) from
- version 1.23 onwards.
-
-
- Producing libraries
- ===================
-
- At the moment there is no fancy multitasking program to construct library
- files. There is, however, a simple basic program which performs the task
- called 'BuildLib'. You'll find it in the same directory as this !Help file.
- Details of the library to be created are passed to BuildLib in a text file,
- the name of which is held at the start of the program (currently
- RAM:$.TextFile). You can change this if you wish. If you want your library
- to hold more than 100 samples, you should also increase the value of
- maxentries% in the following line.
-
- Each piece of information in the text file contains a single piece of
- information. Spaces at the start and ends of lines are ignored, so this can
- be used to increase readability. The format of the text file is as follows:
-
- 1) Prefix for list of samples
- 2) Output filename of main library
- 3) Output filename of library header
- 4) List of samples for inclusion, one per line.
-
- If the filename for the library header is a blank line, the header will be
- included in the main library as normal. Each sample in the list has the
- prefix added to the start before use. The ID used for the sample is the
- leafname of the sample.
-
-
- Using the module with your own programs
- =======================================
-
- The module uses ExpCode to do all its dirty work, so the same conditions of
- use that apply to Expand and ExpCode also apply to the module. Basically,
- don't tamper with it, don't pretend you wrote it, and if you use it, you
- must mention the author somewhere in the credits. See the !ReadMe file in
- the main directory for more information on copyright details and contact
- addresses.
-
-
- (c) David Radford
-
-
-