Manual: SFZ Implementation

From OpenMPT Wiki
Jump to navigation Jump to search

It is possible to load SFZ instruments through the Instrument Editor.

SFZ is a loosely standardized text-based instrument format with external sample files, and is the recommended format for instrument interchange with other applications. OpenMPT tries to support as many SFZ opcodes as possible, including some that are specific to other vendors; its sampler only supports a fraction of the features of a full-fledged SFZ player, though.

The following SFZ opcodes are supported:

<control>[edit]

  • default_path: The default path to search sample files in.
  • note_offset: Global transposition in semitones.
  • octave_offset: Global transposition in octaves.

<global>, <master>, <group>, <region>[edit]

  • sample: The sample filename, relative to the SFZ file or default_path, if specified. This can also be one of the following values to generate a synthesized sample: *sine, *square, *triangle / *tri, *saw, *silence, *noise.
  • lokey: The lowest key this region is mapped to, either as a MIDI note index (0 to 127, 60 is middle-C) or scientific pitch designation (C, C#/Db, D, D#/Eb, E, F, F#/Gb, G, G#/Ab, A, A#/Bb or B, followed by an octave number; 4 is the middle octave, so C4 is middle-C).
  • hikey: The highest key this region is mapped to, in the same format as lokey.
  • pitch_keycenter: The pitch at which the sample is played at its original sample rate, in the same format as lokey. Alternatively, sample uses root note information from the sample file if present.
  • key: Sets lokey, hikey and pitch_key_center to the specified value, which is in the same format as lokey.
  • bend_up / bendup: Sets the MIDI pitch-bend depth in cents.
  • pitchlfo_fade: Sets the sample auto-vibrato sweep in seconds (approximately).
  • pitchlfo_depth: Sets the sample auto-vibrato depth.
  • pitchlfo_freq: Sets the sample auto-vibrato rate.
  • volume: Sets the sample global volume, ranging from -144dB to +6dB.
  • amplitude: Sets the sample global volume, ranging from 0 to 100.
  • pan: Sets the sample pan position, ranging from -100 (left) to +100 (right).
  • transpose: Transposes the region up or down by the specified amount of semitones.
  • tune: Detunes the sample by the specified amount of cents, ranging from -100 to +100.
  • end: Trims the sample to the specified length.
  • offset: Starts playing the sample at the specified offset. OpenMPT completely removes any leading waveform data.
  • loop_start / loopstart: Start of the sample loop.
  • loop_end / loopend: End of the sample loop.
  • loop_mode / loopmode: One of the following sample loop modes:
    • loop_continuous: Normal sample loop.
    • one_shot: Treated like loop_continuous.
    • loop_sustain: Sustain loop.
    • no_loop: Disable loop completely.
  • loop_type / looptype: One of the following sample loop types:
    • forward: Normal forward loop.
    • backward: Reverse loop.
    • alternate: Ping-pong loop.
  • loop_crossfade / loopcrossfade: Crossfades the loop start and end. The fade length is specified in seconds.
  • cutoff: Sets the filter cutoff frequency in Hz.
  • fil_random: Random cutoff variation in cents.
  • resonance: Sets the filter resonance in dB.
  • fil_type / filtype: One of the following filter types:
    • lpf_1p / lpf_2p / lpf_4p / lpf_6p: All treated as internal two-pole low-pass filter.
    • hpf_1p / hpf_2p / hpf_4p / hpf_6p: All treated as internal two-pole high-pass filter.
  • polyphony: The allowed maximum polyphony for this sample. Only a value of 1 is supported, in which case the Duplicate Note Check is set to Note Cut.
  • phase: Setting this to invert inverts the sample phase.
  • Envelopes: ampeg_… (volume envelope), fileg_… (filter envelope), pitcheg_…: (pitch envelope):
    • …eg_start: Start level of the envelope, ranging from -100 to +100.
    • …eg_delay: Delay, in seconds, until the attack phase of the envelope starts.
    • …eg_attack: Duration of the attack phase in seconds.
    • …eg_hold: Duration of the hold phase in seconds.
    • …eg_decay: Duration of the decay phase in seconds.
    • …eg_sustain: Sustain level of the envelope, ranging from -100 to +100.
    • …eg_release: Duration of the release phase in seconds.
    • …eg_depth: The depth of the envelope in cents. Only applies to pitch and filter envelopes.
  • global_label: Sets the instrument name (global region only).
  • region_label: Sets the sample name.
  • Flex EGs: eg01_… through eg99_…:
    • …timeX: Time of the X-th envelope point in seconds, relative to the previous envelope point.
    • …levelX: Level of the X-th envelope point, between -1 and +1.
    • …points: Number of points in the envelope.
    • …sustain: The index of the sustain point, 0 being the first.
    • …amplitude / …ampeg: Specifies how much the envelope influences the amplitude, 100 being the full volume range.
    • …pan: Specifies how much the envelope influences the panning, 100 being the full pan range.
    • …pitch: Specifies how much the envelope influences the pitch, in cents.
    • …cutoff: Specifies how much the envelope influences the filter cutoff, in cents.

Miscellaneous[edit]

  • #define macros are supported. Macro names must start with a $, e.g. #define $duration 0.5
  • Other SFZ files can be included into the current file via #include "filename.sfz"
  • Sample files can be of any type supported by OpenMPT’s sample editor (WAV, FLAC, Ogg, Opus, MediaFoundation codecs, etc.)
  • Loop points are read from sample files (as far as they are supported by OpenMPT) if a region’s loop_mode is set but no loop points are provided.