18.2 The ADPCM Tools: tabledesign, vadpcm_enc, vadpcm_dec

The ic tool requires wavetables to be compressed in ADPCM format before they are included in a sound bank. ADPCM compression is accomplished using the tabledesign, vadpcm_enc, and vadpcm_dec. These tools are described below.

Note: The format described is used only as an interchange format between the compression tools and the instrument compiler. It is not used to store compressed sound data on the ROM.


18.2.1 tabledesign

tabledesign reads an AIFC or AIFF sound file and produces a code book, which is used by the ADPCM encoder. The codebook is a table of prediction coefficients which the coder selects from to optimize sound quality. The procedure used to design the codebooks is based on an adaptive clustering algorithm.

Command line options are described in the following table to call tabledesign

tabledesign [-s book_size] [-f frame_size][-I refine_iter] aifcfile

Command-line options are described in Table 18-2

Table 18-2 tabledesign Command Line Options
Command Line Option Function
-s<value> value is the base 2 log of the number of entries in the table. Currently up to 8 entries are supported, so the value can range from 0 to 3. The default value for this parameter is 2, giving 4 entries. This seems to be adequate for most sounds.
-f<value> value is the size of the frames (in samples) used to estimate predictors. Since the ADPCM encoder operates on frames of 16 samples, this number should be a multiple of 16. The default value is 16. The main benefit of increasing the frame size is that design time is reduced.
-I<value> value is the number of iterations used in the refinement step of the clustering algorithm. The default value is 2. Increasing this parameter increases design time, with some possible improvement in quality. The default is adequate for most sounds.


18.2.2 vadpcm_enc

vadpcm_enc encodes AIFC or AIFF sound files and produces a compressed binary file, which is used by ic to prepare banks of sounds. The encoding algorithm is based on a switchedADPCM algorithm which uses a codebook to define a table of prediction coefficients. Coefficients from the table are selected adaptively by vadpcm_enc during encoding to give the best sound quality. The Nintendo 64 compressed sound format currently supports a single loop point, which should be defined in the input file's Instrument Chunk. The codebook and loop-point definitions are embedded in the final output file.

The vadpcm_enc tool is invoked as follows:

vadpcm_enc -c codebook [-t] [-l minLoopLength] aifcFile codedFile
Table 18-3 vadpcm_enc Command Line Options
Command Line Option Function
-c<filename> Define a file that contains the prediction coefficient codebook constructed by tabledesign(), to specify a filename.
-t Truncate the encoded file after the loop end point. The portion of the sound after the loop end-point is never used in audio playback.
-l<value> Set the minimum loop length in the encoded file

Note: The efficiency of wavetable synthesis is dependent on the length of loops. Longer loop lengths can be synthesized more efficiently. A minimum loop length can be set in the ADPCM encoder. The currently defined default minimum loop length is 800 samples. This default length can be changed (see above), with the absolute minimum being 16 samples. Loops shorter than the minimum loop length are repeated until the total loop length is larger than the minimum length. If possible loops should be longer than a single audio frame which is equal to the (SampleRate)/(Frame Rate).


18.2.3 vadpcm_dec

vadpcm_dec decodes a sound file that has been encoded in the Nintendo 64 ADPCM format using vadpcm_enc, and writes it to standard output as raw mono 16-bit samples.

The vadpcm_dec tool is invoked as follows:

vadpcm_dec [-l] codedFile
Table 18-4 vadpcm_dec Command Line Options
Command Line Option Function
-l If the sound has a loop, play the loop repeatedly until a key is pressed on the standard input.