The BODY chunk is the sound. SoundBox’s description: “The BODY chunk contains samples in word width, using the Motorola notation (MSB, LSB).
Stereo samples are stored with all left channel’s samples first, followed by all right channel’s samples.”
The samples
- Every sample is a signed 16-bit two’s complement word, most significant byte first (Motorola order):
7F FFis 32,767 and80 00is −32,768. - Samples are always 16 bits wide. A sample taken at 12 bits is shifted left by 4 before saving (
asl #4) so that it fills the 16 bits. - Every count in the voice header and in
SEQNcounts samples, not bytes: multiply by two to get an offset in theBODY. - A
BODYholds a whole number of words. The viewer flags an odd length and does not play the odd last byte.
The words can be told from 8-bit data by the form type alone. Some programs write the words little-endian instead (Fasttracker 2 and Awave Studio up to version 11.7, according to OpenMPT’s importer); the byte order is not marked in the file.
Detecting little-endian words
This is detection, not a statement of the format, and it can be wrong. OpenMPT’s importer reads every channel’s words both ways, scales each reading by its largest absolute value (so that 8-bit data stored in 16 bits is not favoured), adds up the squares of the differences between neighbouring samples (starting from 0 for each channel) and takes the reading with the smaller sum, because a real waveform changes slowly and words read in the wrong order jump about; when the two sums are equal it keeps big-endian. The explorer applies the same test to the first 2 million words of each channel, shows the result in a “Byte order” row, flags a body it takes for little-endian, and plays it that way. Both real 16SV files found are big-endian and are not flagged; the same files with every word byte-swapped are recognised and decode to the original samples.
Stereo
With a CHAN chunk of 6 (stereo) the body is the left channel’s words, then the right channel’s words: the channels are not interleaved. SoundBox’s guide gives the
disadvantage: playing a large sample from a hard disk needs time-consuming seeks. CHAN is described on the
8SVX page.
Octaves
The voice header’s counts are in samples, and the octave layout is the 8SVX one: the highest octave first, each following octave twice as long as the one before. A body of n octaves holds
(20 + 21 + … + 2n−1) × (oneShotHiSamples + repeatHiSamples) words, so for 3 octaves of 100 samples: 100 + 200 + 400 = 700 words, 1,400 bytes.
SoundBox itself does not write more than one octave.
Compression
The body is uncompressed: sCompression is 0 (voice header). The delta codes of 8SVX are 4-bit codes of 8-bit samples; SoundFX’s 16-bit delta forms (6-bit and 5-bit codes, sCompression 1 and 2) are not described anywhere found.
8SVX Combined: the LBDY chunk
SoundBox’s other 16-bit scheme is a plain FORM 8SVX, so that “even a standard 8 bit sampler can use the files”. The 16-bit samples are split: the most significant 8 bits go
into the BODY chunk, which stays 8 bits wide, and the least significant 8 bits go into a chunk called LBDY (“LSB BODY”).
“A program that doesn’t recognize the Combined file, only reads the BODY chunk and skips the LBDY chunk … A program supporting Combined file, reads BODY chunk as MSB and LBDY chunk as LSB.”
The guide notes the disadvantage: every sample must be split and joined again, which takes time.
| Chunk | Holds |
|---|---|
BODY | the high byte of every sample (signed, so it is also a valid 8-bit sound) |
LBDY | the low byte of every sample, in the same order, as many bytes as BODY |
The sample is (BODY byte × 256) + LBDY byte. The viewer joins them when LBDY is as long as BODY and the sound is uncompressed;
otherwise it plays the 8-bit BODY and says why (the sizes differ, or the body is compressed). The guide says nothing about how a stereo sound is split; the viewer takes
LBDY in the same order as BODY. A file with the form type 8SVX and an LBDY chunk is read by the
8SVX viewer, which links here for the chunk.
Source: Richard Koerber, SoundBox guide (Aminet mus/misc/SoundBox), sections B.1 “The 8SVX Combined format” and B.2 “The 16SV format”, and its list of supported formats; OpenMPT’s
SampleFormats.cpp for the byte-order remark. The sample files Bluebird.16sv (SoundBox’s sample, shipped with the 16SV datatype) and libsndfile’s svx-pcm16.svx decode sample for sample as FFmpeg decodes them.