Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Presets

File: Rhapsodist/Core/Includes/Presets.js · Namespace: Presets

Overview

Presets owns the preset browser UI, the save/overwrite flow, and, outside the HISE IDE, external automation-data storage.

Two things worth knowing up front: MIDI/host automation assignments are stored in an external file rather than the preset XML, and Presets exposes broadcasters so other scripts can react to preset load/save without embedding state in the preset itself.

User Preset Migration

If your project needs to migrate presets saved under an older version, create an App/UserPresetProcessor.js file with a UserPresetProcessor namespace.

Within that namespace add an inline function process(data). Include the file after Manifest.js and before Core.js.

process() will be called when the user loads a preset with a saved version that is older than the running project version, using HISE’s own semantic-version comparison.

The Data Object

The data object passed to process() uses this structure:

  • data.version, the preset’s saved version string.
  • data.Content, per-component saved-state objects (id, value, and data for sliderpacks/tables), already decoded.
  • data.Modules, data.MPEData, module state and MPE data.
  • data.MidiAutomation.Children, saved automation assignments, each with an Attribute naming the target component ID.

Whatever process() returns replaces the corresponding section wholesale, HISE doesn’t merge it with the original. Mutating the existing objects in place naturally keeps everything else; building new data from scratch means including every entry you want to survive. Returning a falsy value aborts the load.

Typical uses: remapping a renamed component ID in both data.Content and data.MidiAutomation.Children, expanding one saved component into several, reshaping a sliderpack’s saved data after a layout change, or dropping automation for a removed component.

State and persistence

Outside the HISE IDE, MIDI automation, MPE data, and macro-control assignments are routed to an external automation.xml file (under the expansion’s app data folder) instead of being embedded in the preset. Inside the IDE this redirection doesn’t apply.

Usage

Presets wires itself up once Core.js is included, the preset browser, save flow, and broadcasters are all ready without further setup.

Call Presets.show()/hide() from other scripts to open or close the browser programmatically, and listen to Presets.broadcasters.preLoad/postLoad to react to preset loads.

Look and Feel

FunctionDraws
drawPresetBrowserPanelThe whole pnlPresetBrowser panel, replacing its default background/border.
drawPresetBrowserBackgroundThe floating tile’s background fill.
drawPresetBrowserColumnBackgroundA whole bank/category/preset column: its background, border, and label text.
drawPresetBrowserColumnAfterFillAn extra pass after the default column background/border, before its label text; only reached when drawPresetBrowserColumnBackground isn’t overridden.
drawPresetBrowserListItemA single item row in a column.
drawPresetBrowserEditButtonThe Add/Rename/Delete/More edit icon buttons.
drawPresetBrowserSearchBarThe search bar.
drawPresetBrowserScrollbarEach column’s scrollbar.

Public API

FunctionDescriptionReturns
show()Opens the preset browser overlay.—
hide()Closes the preset browser overlay.—
savePreset()The save/overwrite flow bound to btnPresetSave. If a non-read-only preset is already loaded it offers to overwrite it, otherwise opens a save dialog. Presets must be saved into a bank/category folder directly inside the expansion’s user presets folder; read-only presets can’t be overwritten.—
setDataProperty(property: string, value: NotUndefined)Patches a single property into the PresetBrowser floating tile’s Data JSON. The property must already exist in that JSON.—

Broadcasters

BroadcasterDescription
broadcasters.preLoadBroadcaster that fires before every preset load/save, carrying a single isInternal argument. Use it to snapshot state that should survive a preset load, see Header for the master volume/pan example.
broadcasters.postLoadBroadcaster that fires after every preset load/save, with the same isInternal argument. Use it to restore state snapshotted in preLoad.

Internal Reference

FunctionDescriptionReturns
updatePresetLabel(nameOnly: number)Updates btnPresetBrowser’s displayed text from currentPresetFile.—
overwriteCurrentPreset(presetName: string)Confirms and overwrites the currently loaded preset, called by savePreset() when one is loaded and not read-only.—
createNewPreset()Opens a save dialog, validates the chosen location is a bank/category folder inside the user presets folder and that it isn’t read-only, then saves. Called by savePreset() when no preset is loaded, or the loaded one is read-only.—
setStyleDataProperties()Applies LookAndFeel.style.presets.dataProperties, if defined, to the PresetBrowser floating tile via setDataProperty(). Runs once at load.—