Skip to content

Preset Class

spessasus edited this page Oct 15, 2024 · 6 revisions

Preset class

Represents a singe SoundFont2 preset.

Methods

getSamplesAndGenerators

Returns the samples and their generators (and modulators) for the given midiNote. The name is kept from the time that SpessaSynth did not support modulators.

const samplesAndGenerators = preset.getSampleAndGenerators(midiNote);
  • midiNote - the note to get generators from. Ranges from 0 to 127.

The returned value is as follows:

const samplesAndGenerators = [
    {
        instrumentGenerators: [Generator, /*...*/ Generator], // only the instrument generators, local replace global
        presetGenerators: [Generator, /*...*/ Generator], // only the preset generators, local replace global
        modulators: [Modulator, /*...*/ Modulator], // summed and replaced modulators, ready to use
        sample: Sample // the sample object
    },

    /*...*/

    {
        instrumentGenerators: [Generator, /*...*/ Generator],
        presetGenerators: [Generator, /*...*/ Generator],
        modulators: [Modulator, /*...*/ Modulator], // summed and replaced modulators, ready to use
        sample: Sample
    }
];

More info about the Generator class is here

Properties

presetName

The preset's name as string.

console.log(preset.presetName); // for example: "Drawbar Organ"

bank

The preset's bank number. Used in MIDI Bank Select controller.

console.log(preset.bank); // for example: 0

program

The preset's MIDI program number. Used in MIDI Program Change message.

console.log(preset.program); // for example: 16