drj/patch/preset_manager.axo
status
In development, subject to changes based on feedback.
description
The preset manager saves and loads all parameters in the patch level it appears in, using the SD card for storage. This should not be confused with the built in presets system. Each sub patch may need their own preset manager to handle its parameters, in the case of hierarchical patches and depending on what you want saved. (A global load/save mode may be added later)
Note that if modules in a patch, or any of its sub patches are added, removed or changed, then the presets will no longer load correctly for the changed (sub)patches. Also be aware that on saving, you will get a glitch in the audio as the SD write blocks for a moment.
There are 4 ways to load and save presets:
1 - Using MIDI by sending standard program change messages.
2 - Using MIDI by sending designated CCs set the preset number and trigger load and save operations.
3 - Using the preset number spinbox, load and save buttons on the module for managing presets from patch windows.
4 - Using the preset, load and save inputs to set the preset number and trigger load and save operations.
The pgmchange menu enables or disables MIDI program changes.
The channel spinbox sets the MIDI channel that will be used for MIDI control.
The presetcc, loadcc and savecc spinboxes selects the MIDI CC numbers used for controlling the preset manager. The preset number to load or save is set with presetcc, the load action is triggered by loadcc and the save action is triggered by savecc. Set the CC numbers to -1 to disable their corresponding functions.
The autoload spinbox selects a preset number which will be loaded automatically when the patch starts. Set autoload to -1 for no preset to be loaded.
The preset spinbox, load and save buttons control the load and save operations directly from a patch window.
The preset output and the save and load pulse outputs can be used to chain save/load actions to sub patches by connecting to the corresponding inputs of other preset managers. If managing presets by MIDI only, the preset managers (in the various sub patches) that listens to MIDI does not need to be chained together. When a preset manager gets a change message via MIDI, it will not send save/load pulses to avoid multiple load/save triggers.
The filenames are constructed of a prefix, taken form the prefix string input, a three digit zero padded preset number and a file extension. The preset files are saved in the SD card directory of the current patch. So a preset filename looks like e.g.:
0:/my_patch/foo001.pst
This means there are 1000 preset slots, although only the first 128 can be accessed via MID (for now).
If a patch has multiple preset managers throughout its sub patches, each preset manager needs a unique string for the prefix. This allows each sub patch to save its parameters to separate files that can be reloaded later by the same sub patch in a different context. As an example, saving preset number 123 for "my_patch", containing two preset managers with the prefixes "syn" and "echo", results in the following files being created:
0:/my_patch/syn123.pst
0:/my_patch/echo123.pst
The file format is an array of 32 bit words, with a two word header:
word 0 => "PRS1", file type identifier string
word 1 => number of parameters
word 2 => first parameter value
..
word N => last parameter value
