Skip to content

Preset Class

spessasus edited this page Aug 8, 2024 · 6 revisions

Preset class

Represents a singe SoundFont2 preset.

Methods

getSamplesAndGenerators

Returns the samples and their generators for the given midiNote.

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
        sample: Sample // the sample object
    },

    /*...*/

    {
        instrumentGenerators: [Generator, /*...*/ Generator],
        presetGenerators: [Generator, /*...*/ Generator],
        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