Skip to content

Commit

Permalink
[auto fill banks] Allow building also auto filling synth banks from t…
Browse files Browse the repository at this point in the history
…he current filtered list
  • Loading branch information
christofmuc committed Aug 15, 2024
1 parent 20d7e95 commit fc0a6dc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
26 changes: 18 additions & 8 deletions The-Orm/PatchListTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,17 @@ PatchListTree::PatchListTree(midikraft::PatchDatabase& db, std::vector<midikraft
juce::ignoreUnused(id);
CreateListDialog::showCreateListDialog(nullptr, TopLevelWindow::getActiveTopLevelWindow(), [this](std::shared_ptr<midikraft::PatchList> list, CreateListDialog::TFillParameters fillParameters) {
if (list) {
spdlog::info("Create new user list named {}", list->name());
if (onPatchListFill) {
onPatchListFill(list, fillParameters, [this, list]() {
db_.putPatchList(list);
regenerateUserLists([]() {});
spdlog::info("Create new user list named {}", list->name());
});
}
else {
db_.putPatchList(list);
regenerateUserLists([]() {});
spdlog::info("Create new user list named {}", list->name());
}
}
}, nullptr);
Expand Down Expand Up @@ -407,15 +408,24 @@ TreeViewNode* PatchListTree::newTreeViewItemForStoredBanks(std::shared_ptr<midik
juce::ignoreUnused(id);
CreateListDialog::showCreateListDialog(nullptr, synth, TopLevelWindow::getActiveTopLevelWindow(), [this, synthBanksNode](std::shared_ptr<midikraft::PatchList> list, CreateListDialog::TFillParameters fillParameters) {
if (list) {
if (fillParameters.fillMode != CreateListDialog::None) {

if (onPatchListFill) {
onPatchListFill(list, fillParameters, [this, synthBanksNode, list]() {
db_.putPatchList(list);
spdlog::info("Created new user bank named {}", list->name());
MessageManager::callAsync([this, synthBanksNode]() {
synthBanksNode->regenerate();
regenerateUserLists([]() {});
});
});
}
db_.putPatchList(list);
spdlog::info("Create new user bank named {}", list->name());
MessageManager::callAsync([this, synthBanksNode]() {
synthBanksNode->regenerate();
regenerateUserLists([]() {});
else {
db_.putPatchList(list);
spdlog::info("Created new user bank named {}", list->name());
MessageManager::callAsync([this, synthBanksNode]() {
synthBanksNode->regenerate();
regenerateUserLists([]() {});
});
}
}
}, [synthBanksNode](std::shared_ptr<midikraft::PatchList> result) {
ignoreUnused(result);
Expand Down
33 changes: 22 additions & 11 deletions The-Orm/PatchView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1078,17 +1078,28 @@ void PatchView::fillList(std::shared_ptr<midikraft::PatchList> list, CreateListD
if (fillParameters.fillMode == CreateListDialog::TListFillMode::None) {
finishedCallback();
}
else if (fillParameters.fillMode == CreateListDialog::TListFillMode::Top) {
loadPage(0, fillParameters.number, currentFilter(), [list, finishedCallback](std::vector<midikraft::PatchHolder> patches) {
list->setPatches(patches);
finishedCallback();
});
}
else if (fillParameters.fillMode == CreateListDialog::TListFillMode::Random) {
loadPage(0, -1, currentFilter(), [list, fillParameters, finishedCallback](std::vector<midikraft::PatchHolder> patches) {
list->setPatches(getRandomSubset(patches, fillParameters.number));
finishedCallback();
});
else {
auto filter = currentFilter();
auto synthBank = std::dynamic_pointer_cast<midikraft::SynthBank>(list);
int patchesDesired = fillParameters.number;
if (synthBank) {
// This is a synth bank, restrict the filter to deliver only patches for the synth that the bank is for
filter.synths.clear();
filter.synths[synthBank->synth()->getName()] = synthBank->synth();
patchesDesired = synthBank->patchCapacity();
}
if (fillParameters.fillMode == CreateListDialog::TListFillMode::Top) {
loadPage(0, patchesDesired, filter, [list, finishedCallback](std::vector<midikraft::PatchHolder> patches) {
list->setPatches(patches);
finishedCallback();
});
}
else if (fillParameters.fillMode == CreateListDialog::TListFillMode::Random) {
loadPage(0, -1, filter, [list, patchesDesired, finishedCallback](std::vector<midikraft::PatchHolder> patches) {
list->setPatches(getRandomSubset(patches, patchesDesired));
finishedCallback();
});
}
}
}

0 comments on commit fc0a6dc

Please sign in to comment.