The shdr sub-chunk lists all samples in the smpl sub-chunk and any referenced ROM samples. It is always a multiple of 46 bytes, with one record for each sample plus a terminal record (spec 7.10). If it is missing or its size is not a multiple of 46 the file should be rejected as structurally unsound.
The record
| Offset | Size | Field | Type | Meaning |
|---|---|---|---|---|
| 0 | 20 | achSampleName | CHAR[20] | The name, in ASCII, with unused terminal characters filled with zero bytes. Names are case sensitive and should be unique; samples with the same name are kept, preserved or renamed |
| 20 | 4 | dwStart | DWORD | The index, in sample data points, from the beginning of the sample data field to the first data point of this sample |
| 24 | 4 | dwEnd | DWORD | The index to the first of the set of 46 zero-valued data points that follow this sample |
| 28 | 4 | dwStartloop | DWORD | The index to the first data point in the loop |
| 32 | 4 | dwEndloop | DWORD | The index to the first data point following the loop: the point “equivalent to” the first loop data point |
| 36 | 4 | dwSampleRate | DWORD | The sample rate in hertz at which the sample was acquired or most recently converted |
| 40 | 1 | byOriginalPitch | BYTE | The MIDI key number of the recorded pitch (60 is middle C, 261.62 Hz) |
| 41 | 1 | chPitchCorrection | CHAR | A pitch correction in cents to apply on playback |
| 42 | 2 | wSampleLink | WORD | For a left or right sample, the header index of its partner |
| 44 | 2 | sfSampleType | SFSampleLink | The type of the sample, and whether it is in RAM or ROM |
The record is 46 bytes (spec 4.4 and 7.10). In the explorer’s Structure tab each field of each record is a node.
Start, end and loop points
All four are indexes in data points from the beginning of the sample data field, so a data point is two bytes of smpl (and one of sm24). They must all lie within the sample data in the bank or in the sound ROM. To let a variety of hardware reproduce the data, a sample has a minimum length of 48 data points, a loop a minimum size of 32 and there must be a minimum of 8 valid points before dwStartloop and after dwEndloop. Thus dwStart must be less than dwStartloop − 7, dwStartloop less than dwEndloop − 31 and dwEndloop less than dwEnd − 7. If these are not met, the sound may optionally not be played, if the hardware cannot support artifact-free playback (spec 7.10). The eight points around the start and end of the loop should be identical for a portable loop (spec 6.3, 7.10).
The generators of an instrument zone can move these points by address offsets.
Rate, pitch and correction
- Sample rate. Values above 50,000 or below 400 may not be reproducible by some hardware and should be avoided. A value of zero is illegal; if an illegal or impractical value is found, the nearest practical value should be used (spec 7.10).
- Original pitch. The default “root key” of the sample: a MIDI key-on of that number reproduces the sound at its original pitch. For unpitched sounds 255 is the conventional value; values from 128 to 254 are illegal. Whenever an illegal value or 255 is found, 60 is used (spec 7.10).
- Pitch correction. The correction to apply, not the error: if the sound is 4 cents sharp, the value is −4 (spec 7.10).
Sample types and links
| Value | Name | Meaning |
|---|---|---|
| 1 | monoSample | A mono sample in the bank’s sample data |
| 2 | rightSample | The right half of a stereo pair |
| 4 | leftSample | The left half of a stereo pair |
| 8 | linkedSample | A sample in a circularly linked list; not fully defined in SoundFont 2 (it “will ultimately support a circularly linked list of samples using wSampleLink”) |
| 32769 | RomMonoSample | 0x8001: a mono sample in sound ROM |
| 32770 | RomRightSample | 0x8002: a right sample in sound ROM |
| 32772 | RomLeftSample | 0x8004: a left sample in sound ROM |
| 32776 | RomLinkedSample | 0x8008: a linked sample in sound ROM |
Bit 15 is set if the sample is in ROM and clear if it is in the bank; the four least significant bits are set exclusively to say mono, right, left or linked (spec 4.5 and 7.10). A sample flagged as ROM in a file with no valid irom sub-chunk makes the file structurally defective, to be rejected at load time.
- For a mono sample
wSampleLinkis undefined, conventionally zero, and ignored whatever its value. - For a left or right sample it is the header index of the associated right or left sample. Both are played entirely synchronously, with their pitch controlled by the right sample’s generators. All non-pitch generators apply as normal; in particular the panning of the two samples is done with the pan generator. A left-right pair is always found within the same instrument, and no instrument should be designed in which more than one instance of a particular stereo pair can be active (spec 7.10).
Terminal record and orphans
The terminal sample record is never referenced and is conventionally all zero except achSampleName, which should be “EOS”, end of samples. All samples in smpl are typically referenced by an instrument, but a file with “orphaned” samples need not be rejected, and applications may ignore or filter them out (spec 7.10).
In the explorer
The Samples tab lists every header (number, name, type, points, rate, root key, correction, loop, and the number of instrument zones that use it) with a Show button that opens the header’s facts and its waveform. The explorer reports a start after the end, an end or a loop point beyond the sample data, a loop that starts after it ends or lies outside the sample, a sample or loop below the minimum sizes, fewer than eight points before or after the loop, a non-zero point among the 46 after the sample, a rate of zero or outside 400 to 50,000, an original pitch from 128 to 254, an undefined sample type, a ROM sample with no irom, a left or right sample whose link does not exist or is not the opposite channel, a name used twice, bytes after a name’s terminating zero, a terminal sample that is not named EOS or not zero, and the compressed flag, which belongs to SF3.
Source: SoundFont Technical Specification 2.04, sections 4.4, 4.5, 6.3 and 7.10.