The pgen sub-chunk lists the generators of every preset zone and igen those of every instrument zone. Each is always a multiple of four bytes long and holds one or more generators for each zone (except a global zone that holds only modulators) plus a terminal record (spec 7.5, 7.9). A generator sets or offsets one synthesis parameter, or sets a range; the generators page lists every generator.
The record
| Offset | Size | pgen field | igen field | Type | Meaning |
|---|---|---|---|---|---|
| 0 | 2 | sfGenOper | sfGenOper | SFGenerator | The generator type: an enumeration two bytes long. Unknown or undefined values are ignored |
| 2 | 2 | genAmount | genAmount | genAmountType | The value of the generator |
The record is struct sfGenList { SFGenerator sfGenOper; genAmountType genAmount; } for presets and sfInstGenList for instruments (spec 4.4, 7.5, 7.9).
The value: genAmountType
genAmountType is a union of three forms over the same two bytes (spec 4.5, 7.5):
| Form | Layout | Used by |
|---|---|---|
ranges | BYTE byLo then BYTE byHi | The range generators: keyRange (43) and velRange (44), a minimum and maximum MIDI key number or velocity |
wAmount | WORD, unsigned | An unsigned value: the index generators instrument (41) and sampleID (53), and generators whose value is a count or flag set such as exclusiveClass |
shAmount | SHORT, signed | Most generators |
The specification says the generators with a range specify a range of MIDI key numbers or velocities, others an unsigned WORD, and most a signed SHORT; it does not give a column saying which generator uses which form. The explorer reads the range generators as ranges, the two index generators and exclusiveClass as unsigned and the rest as signed.
Order and uniqueness within a zone
- The zone’s
wGenNdxpoints to its first generator. Unless the zone is global, the last generator is the instrument generator (inpgen) or the sampleID generator (inigen), whose value points at the instrument or sample the zone uses. Generators after it are ignored. - If a key range generator exists in the zone it is always the first generator. If a velocity range generator exists, it is preceded only by a key range generator. A key range that is not first, or a velocity range preceded by another generator, is ignored.
- All generators in a zone must have a unique type. If a second has the same type as an earlier one in the same zone, the first is ignored.
- Generators in
pgenare relative: they are added to the instrument-level values. Generators inigenare absolute: each replaces the default for its generator. See hierarchy and precedence. - A non-global list that does not end in an instrument (sampleID) generator makes the zone ignored. An instrument generator value equal to or greater than the terminal instrument, or a sampleID value equal to or greater than the terminal sample, makes the file structurally unsound and to be rejected.
- If the sub-chunk is missing or its size is not a multiple of four bytes, the file should be rejected as structurally unsound.
(Spec 7.3, 7.5, 7.7, 7.9.)
In the explorer
Every generator of a zone appears in the Generators table of the preset or instrument it belongs to, with its name, number, decoded value with its unit and a status: used, ignored with the reason, or superseded by a later generator of the same type. The Generators tab counts how often each generator is used. The explorer reports a generator number the specification does not define, a reserved one, an instrument-only generator in a preset zone, an instrument generator in an instrument zone and the reverse, a key or velocity range that is misplaced, runs backwards or goes above 127, a repeated generator, an instrument-level value outside the range of the summary table, and an instrument or sampleID that does not exist.
Source: SoundFont Technical Specification 2.04, sections 4.4, 4.5, 7.5, 7.9, 8.5 and 9.4.