日本語English

PCM Voice Parameters

How to write the YAML file that defines a PCM voice (音色) playing back WAV samples. One file may define multiple voices.

File format

YAML format. Comment lines start with #; blank lines and whitespace-only lines are ignored. Load with one of fileio.LoadPCMVoiceFile / LoadPCMVoiceFileFS / SetPCMVoiceData. Every referenced WAV file is decoded into memory at the same time the YAML itself is parsed (the same WAV file is never decoded twice - its cache is reused).

voiceType: two kinds

oneShot A drum-kit-style voice: an independent WAV sample is assigned to each of several notes. Up to 16 voiceSetting entries per voice. Any loop metadata in the file itself is ignored - it always plays as a one-shot, through to the sample's own natural end. loop / baseNote / envelope are ignored.
long For sustained sounds like a violin. Exactly one voiceSetting. Playback pitch-shifts across the 12-tone scale relative to baseNote depending on the note played. note / volume / pan (on the voiceSetting side) are ignored - the assigned part's own volume/pan are used instead. Supports envelope, LFO, and looped playback.

Common parameters

KeyRange / formatDescription
voiceIDintegerUniquely identifies this voice.
voiceTypeoneShot / longThe voice type. An unrecognized value is treated as a YAML-level error and aborts loading.
looptrue / falseOnly meaningful for long. If true and the WAV file itself contains smpl-chunk loop points, that region is looped; if it has none, the whole file (start to end) is looped instead. If false, playback never loops regardless of what the WAV file itself specifies (always ignored for oneShot).
lfotrue / falseOnly meaningful for long (Phase 8). Ignored for oneShot. Defaults to false if omitted.
lfoDelay / lfoFade / lfoDepth / lfoHz Same as FM voicesDefaults: 0.4 / 0.5 / 30 / 6 respectively. See FM Voice Parameters for details.

voiceSetting

KeyoneShotlongDescription
fileNamerequiredrequiredThe WAV file name (mono, 44.1kHz only). Either an absolute path, or - if just a bare file name - resolved relative to the YAML file's own directory (for LoadPCMVoiceFileFS, an absolute path from fsys's root, or the YAML's own directory within fsys for a bare name).
noterequired (e.g. C1)ignoredThe note name that triggers this sample. Up to 16 per voice, each mapped to a different sample.
baseNoteignoredrequired (e.g. A3)The note this sample plays back at its original (untransposed) pitch. Missing/invalid falls back to A4 with a warning.
volume0-127ignoredThis sample's own volume (each oneShot sample can be mixed independently).
pan-16(left)-16(right)ignoredThis sample's own pan. 0 = center, continuous (e.g. -7 = slightly left).
envelopeignored"attackRate, decay1Rate, sustainLevel, decay2Rate, releaseRate" Same format and meaning as an FM voice's envelope. See FM Voice Parameters.

Example

pcmVoice:
  # oneShot type (drum kit)
  - voiceID: 0
    voiceType: oneShot
    loop: false
    voiceSetting:
      - fileName: kick.wav
        note: C1
        volume: 100
        pan: 0
      - fileName: snare.wav
        note: E1
        volume: 100
        pan: 0
      - fileName: hat1.wav
        note: F#1
        volume: 100
        pan: -16

  # long type (sustained, with looping, envelope, and LFO)
  - voiceID: 1
    voiceType: long
    loop: true
    lfo: true
    lfoDelay: 0.3
    lfoFade: 0.4
    lfoHz: 7
    voiceSetting:
      - fileName: uhh.wav
        baseNote: A3
        envelope: "31, 1, 2, 6, 14"

WAV file requirements

An undefined or invalid value (a minor issue) is logged as a warning and treated as 0, and parsing continues. An unrecognized voiceType, or any WAV file failing to load, is a fatal error that aborts loading.