Default Bank IR volume correction

This commit is contained in:
Robin E.R. Davies
2026-06-04 13:46:11 -04:00
parent b5fd5188c7
commit b009d8824a
8 changed files with 115 additions and 7 deletions
Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
#!/usr/bin/bash
export SRC_ZIP="V3 Factory Presets.piBank"
export SRC_ZIP="V4 Factory Presets.piBank"
export DST_ZIP="Factory Presets.piBank"
rm "presets/$DST_ZIP"
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
3
4
+12
View File
@@ -188,6 +188,18 @@ namespace pipedal
}
return false;
}
BankFileEntry* getPresetByName(const std::string&presetName) {
for (std::unique_ptr<BankFileEntry> &preset: presets_)
{
if (preset->preset().name() == presetName)
{
return &(*preset);
}
}
return nullptr;
}
bool renamePreset(int64_t instanceId, const std::string &name)
{
if (hasName(name))
+37 -4
View File
@@ -294,8 +294,33 @@ void Storage::MoveExistingFactoryPresetsBank()
namespace pipedal::implementation {
extern int64_t ImportBankFile(PiPedalModel &model, const std::filesystem::path& filePath,uint64_t uploadAfter = -1);
extern void UpgradeBank(
PiPedalModel&model,
const std::filesystem::path &existingBankFile,
const std::filesystem::path &piBank,
const std::vector<std::string>&presetsToUpgrade
);
}
void Storage::UpgradeV3FactoryPresets()
{
std::vector<std::string> presetsToUpgrade = {
"Marshall JCM800 + TS9",
"Huge Lead 2"
};
fs::path factoryPresetPath = GetBankFileName("Factory Presets");
UpgradeBank(
*this->model,
factoryPresetPath,
this->configRoot / "default_presets" / "presets" / "Factory Presets.piBank",
presetsToUpgrade
);
}
void Storage::InstallFactoryPresets()
{
fs::path defaultBankFilePath = this->configRoot / "default_presets" / "presets" / "Factory Presets.piBank";
@@ -367,14 +392,22 @@ void Storage::ProvisionDefaultBanks()
constexpr uint32_t V2_VERSION_NUMBER = 2; // first to have a Factory Presets
constexpr uint32_t V3_VERSION_NUMBER = 3; // New A2 Presets, completely replacing the previons version.
constexpr uint32_t V4_VERSION_NUMBER = 4; // Fix incorrect Cab IR settings.
if (varPresetVersion < V3_VERSION_NUMBER) {
if (varPresetVersion < V4_VERSION_NUMBER) {
Lv2Log::info("Installing Factory Presets");
// Move the old factory presets bank out of the way.
MoveExistingFactoryPresetsBank();
InstallFactoryPresets();
SetVarPresetVersion(V3_VERSION_NUMBER);
if (varPresetVersion < V3_VERSION_NUMBER) {
MoveExistingFactoryPresetsBank();
}
if (varPresetVersion == V3_VERSION_NUMBER)
{
UpgradeV3FactoryPresets();
} else {
InstallFactoryPresets();
}
SetVarPresetVersion(V4_VERSION_NUMBER);
SaveBankIndex(); // checkpoint.
}
// Next time we will have to MERGE factor presets.
+1
View File
@@ -86,6 +86,7 @@ private:
void SetVarPresetVersion(int32_t version);
void UpgradeV1FactoryPresets();
void MoveExistingFactoryPresetsBank();
void UpgradeV3FactoryPresets();
void InstallFactoryPresets();
void CopyFactoryPresetsToDefaultBank();
void ProvisionDefaultBanks();
+63 -1
View File
@@ -183,6 +183,67 @@ static fs::path GetTone3000ThumbnailFile(const fs::path& thumbnailDirectory, con
namespace pipedal::implementation {
void UpgradeBank(PiPedalModel& model,
const std::filesystem::path& existingBankFilePath,
const std::filesystem::path& piBankFilePath,
const std::vector<std::string>& presetsToUpgrade
) {
BankFile sourceBankFile;
if (piBankFilePath.empty())
{
throw std::runtime_error("Unexpected.");
}
if (IsZipFile(piBankFilePath))
{
auto presetReader = PresetBundleReader::LoadPresetsFile(model, piBankFilePath);
presetReader->ExtractMediaFiles();
std::stringstream ss(presetReader->GetPresetJson());
json_reader reader(ss);
reader.read(&sourceBankFile);
}
else
{
std::ifstream f{ piBankFilePath };
if (!f.is_open()) {
throw std::runtime_error(SS("Unable to open file " << piBankFilePath));
}
// legacy json format, no zip, no media files.
json_reader reader(f);
reader.read(&sourceBankFile);
}
BankFile existingBankFile;
{
std::ifstream ifs{ existingBankFilePath };
if (!ifs.is_open()) {
return;
}
json_reader reader{ ifs };
reader.read(&existingBankFile);
}
for (const std::string& presetToUpgrade : presetsToUpgrade)
{
BankFileEntry* existingEntry = existingBankFile.getPresetByName(presetToUpgrade);
if (existingEntry) {
BankFileEntry* newEntry = sourceBankFile.getPresetByName(presetToUpgrade);
if (newEntry)
{
existingEntry->preset(newEntry->preset());
}
}
}
{
std::ofstream ofs{ existingBankFilePath };
json_writer writer{ ofs };
writer.write(existingBankFile);
}
}
int64_t ImportBankFile(PiPedalModel& model, const std::filesystem::path& filePath, uint64_t uploadAfter = -1)
{
BankFile bankFile;
@@ -211,6 +272,7 @@ namespace pipedal::implementation {
json_reader reader(f);
reader.read(&bankFile);
}
uint64_t instanceId = model.UploadBank(bankFile, uploadAfter);
return instanceId;
@@ -623,7 +685,7 @@ public:
fs::path path = GetTone3000ThumbnailFile(this->model->Tone3000ThumbnailDirectory(), id);
if (!fs::exists(path))
{
path = GetTone3000ThumbnailFile(this->model->OldTone3000ThumbnailDirectory(),id);
path = GetTone3000ThumbnailFile(this->model->OldTone3000ThumbnailDirectory(), id);
if (!fs::exists(path))
{
throw PiPedalException("File not found.");