← Back to Docs
  • index.html
  • Clayground
  • Clayground.Sound
  • SynthInstrument
  • Clayground 2026.2
  • SynthInstrument QML Type

    Real-time oscillator voice with ADSR, pitch envelope, and LFO. More...

    Import Statement: import Clayground.Sound

    Detailed Description

    SynthInstrument owns an internal audio engine and one oscillator instrument. Call triggerNote() to fire a note; tweak the patch via properties. It can also bake() a note to a WAV on disk for later reuse as a SampleInstrument source.

    Properties

    One of "sine", "square", "triangle", "sawtooth", "noise".

    ADSR envelope, all in seconds.

    Pitch envelope: slide from pitchStart semitones above the trigger frequency to pitchEnd over pitchTime seconds. Set all to 0 for a flat pitch.

    LFO in Hz/semitones targeting "pitch", "volume", or "none".

    Post-mix volume, 0..1.

    Read-only. Number of voices currently rendering.

    Methods

    Fire a note. midiNote 69 is A4. Returns true on success.

    Same as triggerNote() but specifies pitch in Hz.

    Render one note with the current patch into a WAV under the app cache directory and return its absolute path. Repeated bakes of the same inputs hit the cache and return the same filename.

    Returns a QVector<float> of audio samples (destructive: advances the live engine). Primarily for tests.

    See also SampleInstrument and SongPlayer.