u-he-preset-randomizer
Version:
Create random u-he synth presets through randomization and merging of your existing presets.
93 lines • 4.49 kB
JavaScript
import path from "path";
import os from "os";
import fs from "fs-extra";
import chalk from "chalk";
const uheSynthNames = ["ACE", "Bazille", "Diva", "Hive", "Repro-1", "Repro-5", "Zebra2", "ZebraHZ", "Zebralette3", "Zebra3", "TyrellN6", "Podolski", "TripleCheese"];
/**
* Detects Preset Library locations
*/
export function detectPresetLibraryLocations(config) {
const detectedPresetLibraries = [];
if (process.platform === 'darwin') {
const userLocationsToTry = [];
if (config.customFolder) {
userLocationsToTry.push(config.customFolder + '/__SynthName__/');
userLocationsToTry.push(config.customFolder + '/../__SynthName__/');
}
userLocationsToTry.push(path.join(os.homedir(), `/Library/Audio/Presets/u-he/__SynthName__/`));
for (const synthName of uheSynthNames) {
for (const location of userLocationsToTry) {
const pathToCheck = location.replace('__SynthName__', synthName);
if (fs.existsSync(pathToCheck)) {
detectedPresetLibraries.push({
synthName: synthName,
root: pathToCheck,
presets: `/Library/Audio/Presets/u-he/${synthName}/`,
userPresets: path.join(pathToCheck, `/UserPresets/${synthName}`),
});
if (synthName === 'Repro-1') {
detectedPresetLibraries.push({
synthName: 'Repro-5',
root: pathToCheck,
presets: `/Library/Audio/Presets/u-he/Repro-5/`,
userPresets: path.join(pathToCheck, `/UserPresets/Repro-5`),
});
if (config.debug) {
console.debug(chalk.gray(`> Found synth Repro-5 in ${pathToCheck}`));
}
}
if (config.debug) {
console.debug(chalk.gray(`> Found synth ${synthName} in ${pathToCheck}`));
}
break;
}
}
}
return detectedPresetLibraries;
}
// Otherwise try Windows or Linux file system conventions
const locationsToTry = [];
if (config.customFolder) {
locationsToTry.push(config.customFolder + '/__SynthName__.data/');
locationsToTry.push(path.resolve(config.customFolder + '/../__SynthName__.data/'));
}
// Windows locations
locationsToTry.push(path.join(os.homedir(), `/Documents/u-he/__SynthName__.data/`));
locationsToTry.push(`C:/Program Files/Common Files/VST3/__SynthName__.data/`);
locationsToTry.push(`C:/Program Files/VSTPlugins/__SynthName__.data/`);
locationsToTry.push(`C:/Program Files/Common Files/CLAP/u-he/__SynthName__.data/`);
locationsToTry.push(`C:/VstPlugins/u-he/__SynthName__.data/`);
// Linux locations ?
locationsToTry.push(path.join(os.homedir(), `/.u-he/__SynthName__.data/`));
locationsToTry.push(`C:/users/VstPlugins/__SynthName__.data/`); // Wine
for (const synthName of uheSynthNames) {
for (const location of locationsToTry) {
const pathToCheck = location.replace('__SynthName__', synthName);
if (fs.existsSync(pathToCheck)) {
if (config.debug) {
console.debug(chalk.gray(`> Found synth ${synthName} in ${pathToCheck}`));
}
detectedPresetLibraries.push({
synthName: synthName,
root: pathToCheck,
presets: path.join(pathToCheck, `/Presets/${synthName}`),
userPresets: path.join(pathToCheck, `/UserPresets/${synthName}`),
});
if (synthName === 'Repro-1') {
detectedPresetLibraries.push({
synthName: 'Repro-5',
root: pathToCheck,
presets: path.join(pathToCheck, `/Presets/Repro-5`),
userPresets: path.join(pathToCheck, `/UserPresets/Repro-5`),
});
if (config.debug) {
console.debug(chalk.gray(`> Found synth Repro-5 in ${pathToCheck}`));
}
}
break;
}
}
}
return detectedPresetLibraries;
}
//# sourceMappingURL=detector.js.map