Vital
Loading...
Searching...
No Matches
LoadSave Class Reference

A utility class for loading and saving configuration, preset, and state data for the Vital synthesizer. More...

#include <load_save.h>

Classes

class  FileSorterAscending
 A helper class for sorting files in ascending order based on their names. More...
 

Public Types

enum  PresetStyle {
  kBass , kLead , kKeys , kPad ,
  kPercussion , kSequence , kExperimental , kSfx ,
  kTemplate , kNumPresetStyles
}
 Enumeration of preset styles that categorize sounds. More...
 

Static Public Member Functions

static void convertBufferToPcm (json &data, const std::string &field)
 Converts a float buffer field in JSON to PCM format in base64.
 
static void convertPcmToFloatBuffer (json &data, const std::string &field)
 Converts a PCM buffer field in JSON to a float buffer in base64.
 
static json stateToJson (SynthBase *synth, const CriticalSection &critical_section)
 Converts the state of a given SynthBase to JSON.
 
static void loadControls (SynthBase *synth, const json &data)
 Loads controls from the given JSON data into a SynthBase instance.
 
static void loadModulations (SynthBase *synth, const json &modulations)
 Loads modulation connections from JSON data into a SynthBase instance.
 
static void loadSample (SynthBase *synth, const json &sample)
 Loads a sample configuration into the SynthBase from a JSON object.
 
static void loadWavetables (SynthBase *synth, const json &wavetables)
 Loads wavetable configurations into a SynthBase from a JSON array.
 
static void loadLfos (SynthBase *synth, const json &lfos)
 Loads LFO states (line shapes) from a JSON array into a SynthBase.
 
static void loadSaveState (std::map< std::string, String > &save_info, json data)
 Extracts and stores basic preset info (name, author, comments, style, macros) from JSON data.
 
static void initSaveInfo (std::map< std::string, String > &save_info)
 Initializes save_info with default values for preset information.
 
static json updateFromOldVersion (json state)
 Updates a JSON state from an older version of Vital's format to the current version.
 
static bool jsonToState (SynthBase *synth, std::map< std::string, String > &save_info, json state)
 Loads a JSON state into the given SynthBase, applying older version updates if necessary.
 
static String getAuthorFromFile (const File &file)
 Extracts the author's name from a given preset file.
 
static String getStyleFromFile (const File &file)
 Extracts the style from a given preset file.
 
static std::string getAuthor (json file)
 Extracts the author name from a JSON object representing a preset/state.
 
static std::string getLicense (json state)
 Extracts the license information from a JSON state, if present.
 
static File getConfigFile ()
 Retrieves the main configuration file path for Vital.
 
static void writeCrashLog (String crash_log)
 Writes a crash log to a file in the data directory.
 
static void writeErrorLog (String error_log)
 Appends an error message to an error log file.
 
static json getConfigJson ()
 Parses and returns the main configuration JSON.
 
static File getFavoritesFile ()
 Retrieves the file storing the user's favorites.
 
static File getDefaultSkin ()
 Retrieves the file specifying the default skin.
 
static json getFavoritesJson ()
 Parses and returns the favorites JSON data.
 
static void addFavorite (const File &new_favorite)
 Adds a new favorite preset or item to the favorites file.
 
static void removeFavorite (const File &old_favorite)
 Removes a favorite item from the favorites.
 
static std::set< std::string > getFavorites ()
 Retrieves all favorites as a set of string paths.
 
static bool hasDataDirectory ()
 Checks if a data directory is properly configured (exists and has packs.json).
 
static File getAvailablePacksFile ()
 Retrieves the file listing available packs.
 
static json getAvailablePacks ()
 Parses and returns JSON data about available packs.
 
static File getInstalledPacksFile ()
 Retrieves the file that stores information about installed packs.
 
static json getInstalledPacks ()
 Returns a JSON list of installed packs.
 
static void saveInstalledPacks (const json &packs)
 Saves the given JSON pack configuration to the installed packs file.
 
static void markPackInstalled (int id)
 Marks a pack as installed by ID in the packs file.
 
static void markPackInstalled (const std::string &name)
 Marks a pack as installed by name in the packs file.
 
static void saveDataDirectory (const File &data_directory)
 Saves the given directory as the data directory in the configuration.
 
static bool isInstalled ()
 Checks if Vital is fully installed (data directory present).
 
static bool wasUpgraded ()
 Checks if Vital was upgraded from a previous version.
 
static bool isExpired ()
 Checks if this build of Vital has expired.
 
static bool doesExpire ()
 Checks if this build of Vital includes an expiration mechanism.
 
static int getDaysToExpire ()
 Returns the number of days remaining until expiration.
 
static bool shouldCheckForUpdates ()
 Checks if Vital should perform update checks.
 
static bool shouldWorkOffline ()
 Checks if Vital should operate in offline mode.
 
static std::string getLoadedSkin ()
 Retrieves the currently loaded skin name.
 
static bool shouldAnimateWidgets ()
 Determines if widget animations are enabled.
 
static bool displayHzFrequency ()
 Determines if frequencies should be displayed in Hz.
 
static bool authenticated ()
 Checks if the user is authenticated.
 
static int getOversamplingAmount ()
 Retrieves the current oversampling amount.
 
static float loadWindowSize ()
 Loads the saved window size scaling factor.
 
static String loadVersion ()
 Loads the saved synth version string.
 
static String loadContentVersion ()
 Loads the saved content version string.
 
static void saveJsonToConfig (json config_state)
 Saves a given JSON object to the configuration file.
 
static void saveJsonToFavorites (json favorites_json)
 Saves a JSON object of favorites to the favorites file.
 
static void saveAuthor (std::string author)
 Saves the provided author name to the config.
 
static void savePreferredTTWTLanguage (std::string language)
 Saves a preferred Text-To-Wavetable (TTWT) language to the config.
 
static void saveLayoutConfig (vital::StringLayout *layout)
 Saves layout configuration (keyboard layout and octave controls).
 
static void saveVersionConfig ()
 Saves the current synth version to the config file.
 
static void saveContentVersion (std::string version)
 Saves the current content version to the config file.
 
static void saveUpdateCheckConfig (bool check_for_updates)
 Saves the user's preference regarding update checks.
 
static void saveWorkOffline (bool work_offline)
 Saves the user's preference for working offline.
 
static void saveLoadedSkin (const std::string &name)
 Saves the currently loaded skin name to the config.
 
static void saveAnimateWidgets (bool animate_widgets)
 Saves the widget animation preference.
 
static void saveDisplayHzFrequency (bool display_hz)
 Saves the preference to display frequency in Hz.
 
static void saveAuthenticated (bool authenticated)
 Saves the user's authentication status.
 
static void saveWindowSize (float window_size)
 Saves the window size scaling factor.
 
static void saveMidiMapConfig (MidiManager *midi_manager)
 Saves MIDI mapping configuration.
 
static void loadConfig (MidiManager *midi_manager, vital::StringLayout *layout=nullptr)
 Loads configuration data into a MidiManager and optional StringLayout.
 
static std::wstring getComputerKeyboardLayout ()
 Retrieves the saved computer keyboard layout for playing notes.
 
static std::string getPreferredTTWTLanguage ()
 Returns the preferred Text-To-Wavetable language, if set.
 
static std::string getAuthor ()
 Retrieves the saved author name from the config.
 
static std::pair< wchar_t, wchar_t > getComputerKeyboardOctaveControls ()
 Retrieves the keys used for octave shifts on the computer keyboard layout.
 
static void saveAdditionalFolders (const std::string &name, std::vector< std::string > folders)
 Saves additional folder paths for presets, wavetables, or samples.
 
static std::vector< std::string > getAdditionalFolders (const std::string &name)
 Retrieves a list of additional folder paths for a given category.
 
static File getDataDirectory ()
 Gets the current data directory from the config.
 
static std::vector< File > getDirectories (const String &folder_name)
 Retrieves directories of a given folder name under the data directory structure.
 
static std::vector< File > getPresetDirectories ()
 Gets directories that should contain presets.
 
static std::vector< File > getWavetableDirectories ()
 Gets directories that should contain wavetables.
 
static std::vector< File > getSkinDirectories ()
 Gets directories that should contain skins.
 
static std::vector< File > getSampleDirectories ()
 Gets directories that should contain samples.
 
static std::vector< File > getLfoDirectories ()
 Gets directories that should contain LFO shapes.
 
static File getUserDirectory ()
 Retrieves the user directory inside the data directory.
 
static File getUserPresetDirectory ()
 Retrieves the user's preset directory.
 
static File getUserWavetableDirectory ()
 Retrieves the user's wavetable directory.
 
static File getUserSkinDirectory ()
 Retrieves the user's skin directory.
 
static File getUserSampleDirectory ()
 Retrieves the user's sample directory.
 
static File getUserLfoDirectory ()
 Retrieves the user's LFO directory.
 
static void getAllFilesOfTypeInDirectories (Array< File > &files, const String &extensions, const std::vector< File > &directories)
 Scans a set of directories for files matching certain extensions.
 
static void getAllPresets (Array< File > &presets)
 Retrieves all preset files from preset directories.
 
static void getAllWavetables (Array< File > &wavetables)
 Retrieves all wavetables from wavetable directories.
 
static void getAllSkins (Array< File > &skins)
 Retrieves all skins from skin directories.
 
static void getAllLfos (Array< File > &lfos)
 Retrieves all LFO shapes from LFO directories.
 
static void getAllSamples (Array< File > &samples)
 Retrieves all samples (wav files) from sample directories.
 
static void getAllUserPresets (Array< File > &presets)
 Retrieves all user presets (from data and user directories).
 
static void getAllUserWavetables (Array< File > &wavetables)
 Retrieves all user wavetables (from data and user directories).
 
static void getAllUserLfos (Array< File > &lfos)
 Retrieves all user LFO shapes (from data and user directories).
 
static void getAllUserSamples (Array< File > &samples)
 Retrieves all user samples (from data and user directories).
 
static int compareFeatureVersionStrings (String a, String b)
 Compares two feature version strings (ignoring patch-level differences).
 
static int compareVersionStrings (String a, String b)
 Compares two version strings.
 
static File getShiftedFile (const String directory_name, const String &extensions, const std::string &additional_folders_name, const File &current_file, int shift)
 Given a directory name and extensions, returns a file shifted by some offset from the current file.
 

Static Public Attributes

static const int kMaxCommentLength = 500
 Maximum length of preset comments.
 
static const std::string kUserDirectoryName = "User"
 Various folder and directory name constants.
 
static const std::string kPresetFolderName = "Presets"
 
static const std::string kWavetableFolderName = "Wavetables"
 
static const std::string kSkinFolderName = "Skins"
 
static const std::string kSampleFolderName = "Samples"
 
static const std::string kLfoFolderName = "LFOs"
 
static const std::string kAdditionalWavetableFoldersName = "wavetable_folders"
 
static const std::string kAdditionalSampleFoldersName = "sample_folders"
 

Detailed Description

A utility class for loading and saving configuration, preset, and state data for the Vital synthesizer.

This class provides a comprehensive set of static methods for:

  • Converting between data formats (e.g., float PCM data and integer PCM).
  • Reading and writing synth states, including parameters, wavetables, samples, LFOs, modulations, and more.
  • Managing user directories, favorites, installed packs, and additional folders.
  • Updating old configuration/preset states to newer versions.
  • Handling checks for updates, authentication, window size, and other global settings.

Member Enumeration Documentation

◆ PresetStyle

Enumeration of preset styles that categorize sounds.

Enumerator
kBass 
kLead 
kKeys 
kPad 
kPercussion 
kSequence 
kExperimental 
kSfx 
kTemplate 
kNumPresetStyles 

Member Function Documentation

◆ addFavorite()

void LoadSave::addFavorite ( const File & new_favorite)
static

Adds a new favorite preset or item to the favorites file.

Parameters
new_favoriteThe file to be added as a favorite.

◆ authenticated()

bool LoadSave::authenticated ( )
static

Checks if the user is authenticated.

Returns
True if authenticated, false otherwise.

◆ compareFeatureVersionStrings()

int LoadSave::compareFeatureVersionStrings ( String a,
String b )
static

Compares two feature version strings (ignoring patch-level differences).

Parameters
aThe first version string.
bThe second version string.
Returns
A comparison integer: < 0 if a < b, 0 if equal, > 0 if a > b.

◆ compareVersionStrings()

int LoadSave::compareVersionStrings ( String a,
String b )
static

Compares two version strings.

Parameters
aThe first version string.
bThe second version string.
Returns
A comparison integer: < 0 if a < b, 0 if equal, > 0 if a > b.

◆ convertBufferToPcm()

void LoadSave::convertBufferToPcm ( json & data,
const std::string & field )
static

Converts a float buffer field in JSON to PCM format in base64.

Parameters
dataThe JSON object containing the field.
fieldThe name of the field to convert.

◆ convertPcmToFloatBuffer()

void LoadSave::convertPcmToFloatBuffer ( json & data,
const std::string & field )
static

Converts a PCM buffer field in JSON to a float buffer in base64.

Parameters
dataThe JSON object containing the field.
fieldThe name of the field to convert.

◆ displayHzFrequency()

bool LoadSave::displayHzFrequency ( )
static

Determines if frequencies should be displayed in Hz.

Returns
True if frequencies are displayed in Hz.

◆ doesExpire()

bool LoadSave::doesExpire ( )
static

Checks if this build of Vital includes an expiration mechanism.

Returns
True if it expires after a certain number of days, otherwise false.

◆ getAdditionalFolders()

std::vector< std::string > LoadSave::getAdditionalFolders ( const std::string & name)
static

Retrieves a list of additional folder paths for a given category.

Parameters
nameThe category name (e.g., "wavetable_folders").
Returns
A vector of folder paths as strings.

◆ getAllFilesOfTypeInDirectories()

void LoadSave::getAllFilesOfTypeInDirectories ( Array< File > & files,
const String & extensions,
const std::vector< File > & directories )
static

Scans a set of directories for files matching certain extensions.

Parameters
filesAn Array<File> to store the results.
extensionsA string specifying the file extensions to look for.
directoriesA vector of File objects representing directories to search.

◆ getAllLfos()

void LoadSave::getAllLfos ( Array< File > & lfos)
static

Retrieves all LFO shapes from LFO directories.

Parameters
lfosAn Array<File> to store the found LFO files.

◆ getAllPresets()

void LoadSave::getAllPresets ( Array< File > & presets)
static

Retrieves all preset files from preset directories.

Parameters
presetsAn Array<File> to store the found preset files.

◆ getAllSamples()

void LoadSave::getAllSamples ( Array< File > & samples)
static

Retrieves all samples (wav files) from sample directories.

Parameters
samplesAn Array<File> to store the found sample files.

◆ getAllSkins()

void LoadSave::getAllSkins ( Array< File > & skins)
static

Retrieves all skins from skin directories.

Parameters
skinsAn Array<File> to store the found skins.

◆ getAllUserLfos()

void LoadSave::getAllUserLfos ( Array< File > & lfos)
static

Retrieves all user LFO shapes (from data and user directories).

Parameters
lfosAn Array<File> to store the found user LFO files.

◆ getAllUserPresets()

void LoadSave::getAllUserPresets ( Array< File > & presets)
static

Retrieves all user presets (from data and user directories).

Parameters
presetsAn Array<File> to store the found user presets.

◆ getAllUserSamples()

void LoadSave::getAllUserSamples ( Array< File > & samples)
static

Retrieves all user samples (from data and user directories).

Parameters
samplesAn Array<File> to store the found user samples.

◆ getAllUserWavetables()

void LoadSave::getAllUserWavetables ( Array< File > & wavetables)
static

Retrieves all user wavetables (from data and user directories).

Parameters
wavetablesAn Array<File> to store the found user wavetables.

◆ getAllWavetables()

void LoadSave::getAllWavetables ( Array< File > & wavetables)
static

Retrieves all wavetables from wavetable directories.

Parameters
wavetablesAn Array<File> to store the found wavetables.

◆ getAuthor() [1/2]

std::string LoadSave::getAuthor ( )
static

Retrieves the saved author name from the config.

Returns
The author name.

◆ getAuthor() [2/2]

std::string LoadSave::getAuthor ( json file)
static

Extracts the author name from a JSON object representing a preset/state.

Parameters
fileA JSON object containing the author's field.
Returns
The author's name as a std::string.

◆ getAuthorFromFile()

String LoadSave::getAuthorFromFile ( const File & file)
static

Extracts the author's name from a given preset file.

Parameters
fileThe preset File to examine.
Returns
The author's name if found, or an empty String otherwise.

◆ getAvailablePacks()

json LoadSave::getAvailablePacks ( )
static

Parses and returns JSON data about available packs.

Returns
A JSON object listing available packs.

◆ getAvailablePacksFile()

File LoadSave::getAvailablePacksFile ( )
static

Retrieves the file listing available packs.

Returns
A File object representing the available packs file.

◆ getComputerKeyboardLayout()

std::wstring LoadSave::getComputerKeyboardLayout ( )
static

Retrieves the saved computer keyboard layout for playing notes.

Returns
A wide-string representing the keyboard layout.

◆ getComputerKeyboardOctaveControls()

std::pair< wchar_t, wchar_t > LoadSave::getComputerKeyboardOctaveControls ( )
static

Retrieves the keys used for octave shifts on the computer keyboard layout.

Returns
A pair of wchar_t representing the down and up keys.

◆ getConfigFile()

File LoadSave::getConfigFile ( )
static

Retrieves the main configuration file path for Vital.

Returns
A File object representing the configuration file.

◆ getConfigJson()

json LoadSave::getConfigJson ( )
static

Parses and returns the main configuration JSON.

Returns
A JSON object representing the current configuration.

◆ getDataDirectory()

File LoadSave::getDataDirectory ( )
static

Gets the current data directory from the config.

Returns
A File object representing the data directory.

◆ getDaysToExpire()

int LoadSave::getDaysToExpire ( )
static

Returns the number of days remaining until expiration.

Returns
Days left before expiration, or a negative number if expired.

◆ getDefaultSkin()

File LoadSave::getDefaultSkin ( )
static

Retrieves the file specifying the default skin.

Returns
A File object representing the default skin file.

◆ getDirectories()

std::vector< File > LoadSave::getDirectories ( const String & folder_name)
static

Retrieves directories of a given folder name under the data directory structure.

Parameters
folder_nameThe name of the folder (e.g., "Presets").
Returns
A vector of File objects pointing to directories.

◆ getFavorites()

std::set< std::string > LoadSave::getFavorites ( )
static

Retrieves all favorites as a set of string paths.

Returns
A set of full path names representing favorites.

◆ getFavoritesFile()

File LoadSave::getFavoritesFile ( )
static

Retrieves the file storing the user's favorites.

Returns
A File object representing the favorites file.

◆ getFavoritesJson()

json LoadSave::getFavoritesJson ( )
static

Parses and returns the favorites JSON data.

Returns
A JSON object of favorites.

◆ getInstalledPacks()

json LoadSave::getInstalledPacks ( )
static

Returns a JSON list of installed packs.

Returns
A JSON object of installed packs.

◆ getInstalledPacksFile()

File LoadSave::getInstalledPacksFile ( )
static

Retrieves the file that stores information about installed packs.

Returns
A File object representing the installed packs file.

◆ getLfoDirectories()

std::vector< File > LoadSave::getLfoDirectories ( )
static

Gets directories that should contain LFO shapes.

Returns
A vector of File objects representing LFO directories.

◆ getLicense()

std::string LoadSave::getLicense ( json state)
static

Extracts the license information from a JSON state, if present.

Parameters
stateThe JSON object potentially containing a "license" key.
Returns
The license string if found, or an empty string otherwise.

◆ getLoadedSkin()

std::string LoadSave::getLoadedSkin ( )
static

Retrieves the currently loaded skin name.

Returns
The name of the loaded skin, or an empty string if none is set.

◆ getOversamplingAmount()

int LoadSave::getOversamplingAmount ( )
static

Retrieves the current oversampling amount.

Returns
The oversampling factor as an integer.

◆ getPreferredTTWTLanguage()

std::string LoadSave::getPreferredTTWTLanguage ( )
static

Returns the preferred Text-To-Wavetable language, if set.

Returns
The language code as a string.

◆ getPresetDirectories()

std::vector< File > LoadSave::getPresetDirectories ( )
static

Gets directories that should contain presets.

Returns
A vector of File objects representing preset directories.

◆ getSampleDirectories()

std::vector< File > LoadSave::getSampleDirectories ( )
static

Gets directories that should contain samples.

Returns
A vector of File objects representing sample directories.

◆ getShiftedFile()

File LoadSave::getShiftedFile ( const String directory_name,
const String & extensions,
const std::string & additional_folders_name,
const File & current_file,
int shift )
static

Given a directory name and extensions, returns a file shifted by some offset from the current file.

Used for navigating presets or wavetables by stepping forward/backward.

Parameters
directory_nameThe directory name to search.
extensionsThe file extensions to consider.
additional_folders_nameThe config key for extra directories.
current_fileThe current file.
shiftThe integer offset to move (e.g., +1 for next file, -1 for previous).
Returns
The shifted File, or a default empty File if none found.

◆ getSkinDirectories()

std::vector< File > LoadSave::getSkinDirectories ( )
static

Gets directories that should contain skins.

Returns
A vector of File objects representing skin directories.

◆ getStyleFromFile()

String LoadSave::getStyleFromFile ( const File & file)
static

Extracts the style from a given preset file.

Parameters
fileThe preset File to examine.
Returns
The preset style if found, or an empty String otherwise.

◆ getUserDirectory()

File LoadSave::getUserDirectory ( )
static

Retrieves the user directory inside the data directory.

Returns
A File object representing the user directory.

◆ getUserLfoDirectory()

File LoadSave::getUserLfoDirectory ( )
static

Retrieves the user's LFO directory.

Returns
A File object representing the user LFO directory.

◆ getUserPresetDirectory()

File LoadSave::getUserPresetDirectory ( )
static

Retrieves the user's preset directory.

Returns
A File object representing the user preset directory.

◆ getUserSampleDirectory()

File LoadSave::getUserSampleDirectory ( )
static

Retrieves the user's sample directory.

Returns
A File object representing the user sample directory.

◆ getUserSkinDirectory()

File LoadSave::getUserSkinDirectory ( )
static

Retrieves the user's skin directory.

Returns
A File object representing the user skin directory.

◆ getUserWavetableDirectory()

File LoadSave::getUserWavetableDirectory ( )
static

Retrieves the user's wavetable directory.

Returns
A File object representing the user wavetable directory.

◆ getWavetableDirectories()

std::vector< File > LoadSave::getWavetableDirectories ( )
static

Gets directories that should contain wavetables.

Returns
A vector of File objects representing wavetable directories.

◆ hasDataDirectory()

bool LoadSave::hasDataDirectory ( )
static

Checks if a data directory is properly configured (exists and has packs.json).

Returns
True if a valid data directory is found, false otherwise.

◆ initSaveInfo()

void LoadSave::initSaveInfo ( std::map< std::string, String > & save_info)
static

Initializes save_info with default values for preset information.

Parameters
save_infoThe map to initialize.

◆ isExpired()

bool LoadSave::isExpired ( )
static

Checks if this build of Vital has expired.

Returns
True if expired, false if still within allowed usage days.

◆ isInstalled()

bool LoadSave::isInstalled ( )
static

Checks if Vital is fully installed (data directory present).

Returns
True if installed, false otherwise.

◆ jsonToState()

bool LoadSave::jsonToState ( SynthBase * synth,
std::map< std::string, String > & save_info,
json state )
static

Loads a JSON state into the given SynthBase, applying older version updates if necessary.

Parameters
synthA pointer to the SynthBase.
save_infoA map to store extracted preset information.
stateThe JSON state to load.
Returns
True if successful, false if the version is incompatible.

◆ loadConfig()

void LoadSave::loadConfig ( MidiManager * midi_manager,
vital::StringLayout * layout = nullptr )
static

Loads configuration data into a MidiManager and optional StringLayout.

Parameters
midi_managerA pointer to the MidiManager for loading MIDI maps.
layoutAn optional StringLayout pointer to set keyboard layouts.

◆ loadContentVersion()

String LoadSave::loadContentVersion ( )
static

Loads the saved content version string.

Returns
The content version string, or "0.0" if not set.

◆ loadControls()

void LoadSave::loadControls ( SynthBase * synth,
const json & data )
static

Loads controls from the given JSON data into a SynthBase instance.

This sets each control parameter in the synth to the values found in the JSON object.

Parameters
synthA pointer to the SynthBase instance to modify.
dataThe JSON object containing control data.

◆ loadLfos()

void LoadSave::loadLfos ( SynthBase * synth,
const json & lfos )
static

Loads LFO states (line shapes) from a JSON array into a SynthBase.

Parameters
synthA pointer to the SynthBase.
lfosA JSON array of LFO states.

◆ loadModulations()

void LoadSave::loadModulations ( SynthBase * synth,
const json & modulations )
static

Loads modulation connections from JSON data into a SynthBase instance.

Rebuilds modulation sources and destinations, as well as line mappings.

Parameters
synthA pointer to the SynthBase instance.
modulationsA JSON array of modulation definitions.

◆ loadSample()

void LoadSave::loadSample ( SynthBase * synth,
const json & sample )
static

Loads a sample configuration into the SynthBase from a JSON object.

Parameters
synthA pointer to the SynthBase.
sampleA JSON object representing the sample state.

◆ loadSaveState()

void LoadSave::loadSaveState ( std::map< std::string, String > & save_info,
json data )
static

Extracts and stores basic preset info (name, author, comments, style, macros) from JSON data.

Parameters
save_infoA map where info is stored as key-value pairs.
dataThe JSON data containing preset info.

◆ loadVersion()

String LoadSave::loadVersion ( )
static

Loads the saved synth version string.

Returns
The version string, or "0.0.0" if none is available.

◆ loadWavetables()

void LoadSave::loadWavetables ( SynthBase * synth,
const json & wavetables )
static

Loads wavetable configurations into a SynthBase from a JSON array.

Parameters
synthA pointer to the SynthBase.
wavetablesA JSON array of wavetable definitions.

◆ loadWindowSize()

float LoadSave::loadWindowSize ( )
static

Loads the saved window size scaling factor.

Returns
The window size scaling factor (>= 0.25f).

◆ markPackInstalled() [1/2]

void LoadSave::markPackInstalled ( const std::string & name)
static

Marks a pack as installed by name in the packs file.

Parameters
nameThe name of the pack.

◆ markPackInstalled() [2/2]

void LoadSave::markPackInstalled ( int id)
static

Marks a pack as installed by ID in the packs file.

Parameters
idThe integer ID of the pack.

◆ removeFavorite()

void LoadSave::removeFavorite ( const File & old_favorite)
static

Removes a favorite item from the favorites.

Parameters
old_favoriteThe file to remove from favorites.

◆ saveAdditionalFolders()

void LoadSave::saveAdditionalFolders ( const std::string & name,
std::vector< std::string > folders )
static

Saves additional folder paths for presets, wavetables, or samples.

Parameters
nameThe category name (e.g., "wavetable_folders").
foldersA vector of folder paths as strings.

◆ saveAnimateWidgets()

void LoadSave::saveAnimateWidgets ( bool animate_widgets)
static

Saves the widget animation preference.

Parameters
animate_widgetsTrue if widgets should animate, false otherwise.

◆ saveAuthenticated()

void LoadSave::saveAuthenticated ( bool authenticated)
static

Saves the user's authentication status.

Parameters
authenticatedTrue if authenticated, false otherwise.

◆ saveAuthor()

void LoadSave::saveAuthor ( std::string author)
static

Saves the provided author name to the config.

Parameters
authorThe author's name.

◆ saveContentVersion()

void LoadSave::saveContentVersion ( std::string version)
static

Saves the current content version to the config file.

Parameters
versionThe new content version string.

◆ saveDataDirectory()

void LoadSave::saveDataDirectory ( const File & data_directory)
static

Saves the given directory as the data directory in the configuration.

Parameters
data_directoryThe File representing the chosen data directory.

◆ saveDisplayHzFrequency()

void LoadSave::saveDisplayHzFrequency ( bool display_hz)
static

Saves the preference to display frequency in Hz.

Parameters
display_hzTrue if displaying in Hz, false otherwise.

◆ saveInstalledPacks()

void LoadSave::saveInstalledPacks ( const json & packs)
static

Saves the given JSON pack configuration to the installed packs file.

Parameters
packsA JSON object representing the current installed packs.

◆ saveJsonToConfig()

void LoadSave::saveJsonToConfig ( json config_state)
static

Saves a given JSON object to the configuration file.

Parameters
config_stateThe JSON object to save.

◆ saveJsonToFavorites()

void LoadSave::saveJsonToFavorites ( json favorites_json)
static

Saves a JSON object of favorites to the favorites file.

Parameters
favorites_jsonThe JSON object of favorites.

◆ saveLayoutConfig()

void LoadSave::saveLayoutConfig ( vital::StringLayout * layout)
static

Saves layout configuration (keyboard layout and octave controls).

Parameters
layoutA pointer to a StringLayout representing the computer keyboard layout.

◆ saveLoadedSkin()

void LoadSave::saveLoadedSkin ( const std::string & name)
static

Saves the currently loaded skin name to the config.

Parameters
nameThe skin name as a string.

◆ saveMidiMapConfig()

void LoadSave::saveMidiMapConfig ( MidiManager * midi_manager)
static

Saves MIDI mapping configuration.

Parameters
midi_managerA pointer to the MidiManager from which to extract mappings.

◆ savePreferredTTWTLanguage()

void LoadSave::savePreferredTTWTLanguage ( std::string language)
static

Saves a preferred Text-To-Wavetable (TTWT) language to the config.

Parameters
languageThe language code as a string.

◆ saveUpdateCheckConfig()

void LoadSave::saveUpdateCheckConfig ( bool check_for_updates)
static

Saves the user's preference regarding update checks.

Parameters
check_for_updatesTrue if updates should be checked, false otherwise.

◆ saveVersionConfig()

void LoadSave::saveVersionConfig ( )
static

Saves the current synth version to the config file.

◆ saveWindowSize()

void LoadSave::saveWindowSize ( float window_size)
static

Saves the window size scaling factor.

Parameters
window_sizeThe scaling factor to save.

◆ saveWorkOffline()

void LoadSave::saveWorkOffline ( bool work_offline)
static

Saves the user's preference for working offline.

Parameters
work_offlineTrue to work offline, false otherwise.

◆ shouldAnimateWidgets()

bool LoadSave::shouldAnimateWidgets ( )
static

Determines if widget animations are enabled.

Returns
True if animations are enabled, false otherwise.

◆ shouldCheckForUpdates()

bool LoadSave::shouldCheckForUpdates ( )
static

Checks if Vital should perform update checks.

Returns
True if update checks are enabled, false otherwise.

◆ shouldWorkOffline()

bool LoadSave::shouldWorkOffline ( )
static

Checks if Vital should operate in offline mode.

Returns
True if offline mode is enabled, false otherwise.

◆ stateToJson()

json LoadSave::stateToJson ( SynthBase * synth,
const CriticalSection & critical_section )
static

Converts the state of a given SynthBase to JSON.

Captures all synth settings, modulations, wavetables, LFO sources, etc.

Parameters
synthA pointer to the SynthBase instance.
critical_sectionA reference to a CriticalSection for thread safety.
Returns
A JSON object representing the current synth state.

◆ updateFromOldVersion()

json LoadSave::updateFromOldVersion ( json state)
static

Updates a JSON state from an older version of Vital's format to the current version.

Applies various transformations to parameter names, ranges, or modulation destinations to maintain compatibility.

Parameters
stateThe original JSON state.
Returns
The updated JSON state.

◆ wasUpgraded()

bool LoadSave::wasUpgraded ( )
static

Checks if Vital was upgraded from a previous version.

Returns
True if the saved version is older than the current build.

◆ writeCrashLog()

void LoadSave::writeCrashLog ( String crash_log)
static

Writes a crash log to a file in the data directory.

Parameters
crash_logThe crash log text.

◆ writeErrorLog()

void LoadSave::writeErrorLog ( String error_log)
static

Appends an error message to an error log file.

Parameters
error_logThe error message to write.

Member Data Documentation

◆ kAdditionalSampleFoldersName

const std::string LoadSave::kAdditionalSampleFoldersName = "sample_folders"
static

◆ kAdditionalWavetableFoldersName

const std::string LoadSave::kAdditionalWavetableFoldersName = "wavetable_folders"
static

◆ kLfoFolderName

const std::string LoadSave::kLfoFolderName = "LFOs"
static

◆ kMaxCommentLength

const int LoadSave::kMaxCommentLength = 500
static

Maximum length of preset comments.

◆ kPresetFolderName

const std::string LoadSave::kPresetFolderName = "Presets"
static

◆ kSampleFolderName

const std::string LoadSave::kSampleFolderName = "Samples"
static

◆ kSkinFolderName

const std::string LoadSave::kSkinFolderName = "Skins"
static

◆ kUserDirectoryName

const std::string LoadSave::kUserDirectoryName = "User"
static

Various folder and directory name constants.

◆ kWavetableFolderName

const std::string LoadSave::kWavetableFolderName = "Wavetables"
static

The documentation for this class was generated from the following files: