The shdr sub-chunk of an SF3 file has the layout of SF2: 46-byte records, one for each sample and a terminal record. Two things change: bit 4 of the sample type, and the meaning of four fields for a compressed sample (FluidSynth RFC, “Additional flag for sfSampleType field in SHDR” and “Breaking Change: Interpretation of sample data index fields in SHDR”).
The record
| Offset | Size | Field | PCM sample | Compressed sample (0x10 set) |
|---|---|---|---|---|
| 0 | 20 | achSampleName | The name, ASCII, zero-filled | |
| 20 | 4 | dwStart | Index in data points of the first point | Byte offset of the first byte of the compressed stream, from the start of the smpl data |
| 24 | 4 | dwEnd | Index of the first of the 46 zero points after the sample | The end of the stream: the RFC says the last byte; the files here use the byte after it (see Ogg samples) |
| 28 | 4 | dwStartloop | Index of the first data point in the loop | The same, in decoded data points, counted from the start of this sample |
| 32 | 4 | dwEndloop | Index of the first point after the loop | The same, in decoded data points, counted from the start of this sample |
| 36 | 4 | dwSampleRate | The sample rate in hertz | |
| 40 | 1 | byOriginalPitch | The MIDI key number of the recorded pitch; 255 for unpitched | |
| 41 | 1 | chPitchCorrection | The pitch correction in cents (signed) | |
| 42 | 2 | wSampleLink | The index of the partner of a left or right sample | |
| 44 | 2 | sfSampleType | 1, 2, 4, 8, or those with 0x8000 for ROM | The same with 0x10 added: for example 0x11 is a compressed mono sample |
If the 0x10 flag is not set, the rules of SF2 apply (RFC). The sample types are the same as in SF2: 1 mono, 2 right, 4 left, 8 linked, with bit 15 for ROM.
The compressed flag
sfSampleType |= 0x10 marks a sample that has received any kind of encoding or compression; “the flag does not necessarily indicate OGG Vorbis compression”, and the application must identify the encoding when it decodes the sample. A sample is invalid when the compression is unknown, not supported or broken, or the sample is not mono (RFC).
Sample links
MuseScore’s converted files leave wSampleLink at 0 in every header; software such as Polyphone writes it correctly, and the RFC recommends that it be preserved for future editing (RFC, “Sample Links”). The explorer does not report a left or right sample whose link is 0 in an SF3 file, and checks every other link: that it points at a sample and that the partner is the opposite channel.
Other rules
The SF2 rules for names, sample rate (zero is illegal; above 50,000 or below 400 may not play), original pitch (128 to 254 illegal; 255 means unpitched and 60 is used), pitch correction and the terminal record named “EOS” apply to SF3 as written for SF2 (SF2 spec 7.10). The SF2 minimums for the length of a sample (48 points), a loop (32) and the points around it apply to PCM samples; the RFC does not say whether they apply to a decoded sample, and the SF3 files read here do not meet them (MuseScore’s tool writes loops relative to the sample start, s->loopstart -= s->start when it reads). The explorer applies the minimums to PCM samples only. FluidSynth applies none of the ordering minimums: after decoding a compressed sample it only corrects a loop that is outside the sample or runs backwards (it swaps a reversed pair and moves a point that lies outside the sample to the sample’s start or end: fluid_sample_sanitize_loop in fluid_sfont.c, called from fluid_defsfont.c), and a MuseScore forum report (musescore.org/en/node/89216, read through the Wayback Machine) shows the loop end of an SF3 being coded relative to the sample start, so that it can equal the sample’s length.
In the explorer
The Samples tab lists the headers with their decoded lengths; for a compressed sample Show gives the byte range of its stream, its Vorbis channel count, rate and Ogg page count, the loop in decoded points and the waveform. See the Ogg samples page for the problems reported for a stream, and SF2 for those of a PCM sample.
Source: FluidSynth’s SoundFont3 RFC; sftools sfont.cpp (readSample and writeSmpl); SoundFont Technical Specification 2.04, sections 4.4, 4.5 and 7.10.