diff --git a/Builds/MacOSX/juicysfplugin.xcodeproj/xcshareddata/xcschemes/juicysfplugin - VST3.xcscheme b/Builds/MacOSX/juicysfplugin.xcodeproj/xcshareddata/xcschemes/juicysfplugin - VST3.xcscheme
index b6c7b9d..f373512 100644
--- a/Builds/MacOSX/juicysfplugin.xcodeproj/xcshareddata/xcschemes/juicysfplugin - VST3.xcscheme
+++ b/Builds/MacOSX/juicysfplugin.xcodeproj/xcshareddata/xcschemes/juicysfplugin - VST3.xcscheme
@@ -44,6 +44,7 @@
allowLocationSimulation = "YES">
diff --git a/Source/FluidSynthModel.cpp b/Source/FluidSynthModel.cpp
index d25af90..24e1b72 100644
--- a/Source/FluidSynthModel.cpp
+++ b/Source/FluidSynthModel.cpp
@@ -168,29 +168,9 @@ void FluidSynthModel::initialise() {
fluid_synth_add_default_mod(synth.get(), mod.get(), FLUID_SYNTH_ADD);
}
+const StringArray FluidSynthModel::programChangeParams{"bank", "preset"};
void FluidSynthModel::parameterChanged(const String& parameterID, float newValue) {
- if (parameterID == "bank") {
- int bank, preset;
- {
- RangedAudioParameter *param{valueTreeState.getParameter("bank")};
- jassert(dynamic_cast (param) != nullptr);
- AudioParameterInt* castParam{dynamic_cast(param)};
- bank = castParam->get();
- }
- {
- RangedAudioParameter *param{valueTreeState.getParameter("preset")};
- jassert(dynamic_cast(param) != nullptr);
- AudioParameterInt* castParam{dynamic_cast(param)};
- preset = castParam->get();
- }
- int bankOffset{fluid_synth_get_bank_offset(synth.get(), sfont_id)};
- fluid_synth_program_select(
- synth.get(),
- channel,
- sfont_id,
- static_cast(bankOffset + bank),
- static_cast(preset));
- } else if (parameterID == "preset") {
+ if (programChangeParams.contains(parameterID)) {
int bank, preset;
{
RangedAudioParameter *param{valueTreeState.getParameter("bank")};
diff --git a/Source/FluidSynthModel.h b/Source/FluidSynthModel.h
index d545c67..af14ae3 100644
--- a/Source/FluidSynthModel.h
+++ b/Source/FluidSynthModel.h
@@ -55,7 +55,7 @@ public:
void changeProgramName(int index, const String& newName);
private:
- // static const StringArray controllerParams;
+ static const StringArray programChangeParams;
// there's no bimap in the standard library!
static const map controllerToParam;
diff --git a/Source/Pills.cpp b/Source/Pills.cpp
index fe8a3d6..654fb66 100644
--- a/Source/Pills.cpp
+++ b/Source/Pills.cpp
@@ -14,7 +14,6 @@ Pill::Pill(
bool isFirst,
bool isLast
)
-// : pills{pills}
: valueTreeState{valueTreeState}
, bank{bank}
, textButton{String(bank)}
@@ -25,13 +24,9 @@ Pill::Pill(
| (isLast ? 0 : Button::ConnectedOnRight)
);
textButton.setRadioGroupId(34567);
- // loadToggleState();
textButton.setClickingTogglesState(true);
addAndMakeVisible(textButton);
-
- // valueTreeState.addParameterListener("bank", this);
-// valueTreeState.state.addListener(this);
textButton.addListener(this);
}
@@ -45,8 +40,6 @@ void Pill::resized() {
}
Pill::~Pill() {
- // valueTreeState.removeParameterListener("bank", this);
-// valueTreeState.state.removeListener(this);
textButton.removeListener(this);
}
@@ -54,14 +47,6 @@ void Pill::bankChanged(int bank) {
textButton.setToggleState(this->bank == bank, dontSendNotification);
}
-// void Pill::loadToggleState() {
-// RangedAudioParameter *param {valueTreeState.getParameter("bank")};
-// jassert(dynamic_cast (param) != nullptr);
-// AudioParameterInt* castParam {dynamic_cast (param)};
-// int value{castParam->get()};
-// textButton.setToggleState(value == bank, dontSendNotification);
-// }
-
void Pill::buttonClicked(Button* button) {
ValueTree banks{valueTreeState.state.getChildWithName("banks")};
int banksChildren{banks.getNumChildren()};
@@ -77,8 +62,6 @@ void Pill::buttonClicked(Button* button) {
ValueTree preset{bank.getChild(0)};
int presetNum{preset.getProperty("num")};
- // selected = button;
- // onItemSelected(itemToIDMapper(button->getName().toStdString()));
{
RangedAudioParameter *param{valueTreeState.getParameter("bank")};
jassert(dynamic_cast(param) != nullptr);
@@ -93,38 +76,14 @@ void Pill::buttonClicked(Button* button) {
}
}
-// void Pill::parameterChanged(const String& parameterID, float newValue) {
-// if (parameterID == "bank") {
-// loadToggleState();
-// }
-// }
-
-// void Pill::valueTreePropertyChanged(
-// ValueTree& treeWhosePropertyHasChanged,
-// const Identifier& property) {
-// if (treeWhosePropertyHasChanged.getType() == StringRef("presets")) {
-// loadModelFrom(treeWhosePropertyHasChanged);
-// }
-// }
-
Pills::Pills(
AudioProcessorValueTreeState& valueTreeState
- // string label,
- // const vector &items,
- // const function &onItemSelected,
- // const function &itemToIDMapper,
- // int initiallySelectedItem
)
: valueTreeState{valueTreeState}
-// , label{label}
- // items(items),
- // onItemSelected(onItemSelected),
- // itemToIDMapper(itemToIDMapper)
{
// faster (rounded edges introduce transparency)
setOpaque (true);
- // populate(initiallySelectedItem);
ValueTree banks{valueTreeState.state.getChildWithName("banks")};
loadModelFrom(banks);
@@ -169,9 +128,6 @@ void Pills::loadModelFrom(ValueTree& banks) {
for(int i{0}; i < numChildren; i++) {
ValueTree child{banks.getChild(i)};
int num{child.getProperty("num")};
- // rows.push_back(unique_ptr(new Pill(), [](Pill* pill) {
- // pill->remo
- // }));
unique_ptr pill{make_unique(
valueTreeState,
num,
@@ -184,99 +140,29 @@ void Pills::loadModelFrom(ValueTree& banks) {
resized();
}
-// void Pills::populate(int initiallySelectedItem) {
-// int index = 0;
-// for (string item : items) {
-// TextButton* pill = addToList(new TextButton(
-// item
-// ));
-// // pill->setColour (TextButton::buttonOnColourId, Colours::blueviolet.brighter());
-// // pill->setBounds(20 + index * 55, 260, 55, 24);
-// pill->setConnectedEdges (
-// (index == 0 ? 0 : Button::ConnectedOnLeft)
-// | (index == (items.size()-1) ? 0 : Button::ConnectedOnRight)
-// );
-// pill->setRadioGroupId(34567);
-// if (index == initiallySelectedItem) {
-// pill->setToggleState(true, dontSendNotification);
-// selected = pill;
-// }
-// pill->setClickingTogglesState(true);
-// pill->addListener(this);
-// index++;
-// }
-// }
-
-// void Pills::setItems(
-// const vector &items,
-// int initiallySelectedItem
-// ) {
-// this->items = items;
-// for(TextButton* t : buttons) {
-// t->removeListener(this);
-// }
-// buttons.clear(true);
-// populate(initiallySelectedItem);
-// resized();
-// }
-
-// TextButton* Pills::addToList (TextButton* newButton) {
-// buttons.add (newButton);
-// addAndMakeVisible (newButton);
-// return newButton;
-// }
-
void Pills::cycle(bool right) {
- RangedAudioParameter *param {valueTreeState.getParameter("bank")};
- jassert(dynamic_cast (param) != nullptr);
- AudioParameterInt* castParam {dynamic_cast (param)};
+ RangedAudioParameter *param{valueTreeState.getParameter("bank")};
+ jassert(dynamic_cast(param) != nullptr);
+ AudioParameterInt* castParam{dynamic_cast (param)};
int bank{castParam->get()};
- // ValueTree banks{valueTreeState.state.getChildWithName("banks")};
-// int numChildren{banks.getNumChildren()};
-
- // vector bankInts;
- // bankInts.resize(banks.getNumChildren());
-
- // transform(banks.begin(), banks.end(), bankInts.begin(), [](ValueTree bank) -> int {
- // return bank.getProperty("num");
- // });
-
-// int closestBank{bank};
-// for(int i{0}; i < numChildren; i++) {
-// ValueTree child{banks.getChild(i)};
-// int proposedBank{child.getProperty("num")};
-// if (right && proposedBank > bank) {
-// closestBank = jmin(closestBank, proposedBank);
-// } else if (left )
-// }
-
- // int currentIx{static_cast(distance(bankInts.begin(), find(bankInts.begin(), bankInts.end(), currentlySelectedBank)))};
- // currentIx += right ? 1 : pills.size()-1;
- // // pills[currentIx % pills.size()]->textButton.triggerClick();
- // *castParam = bankInts[currentIx % bankInts.size()];
-
- int currentIx = static_cast(
+ int currentIx{static_cast(
distance(
pills.begin(),
find_if(
pills.begin(),
pills.end(),
- [bank](unique_ptr& pill){return pill->bank == bank;})));
+ [bank](unique_ptr& pill){
+ return pill->bank == bank;})))};
currentIx += right ? 1 : pills.size()-1;
pills[currentIx % pills.size()]->textButton.triggerClick();
-
- // TODO: base this on valueTree
- // int currentIx = static_cast(distance(pills.begin(), find(pills.begin(), pills.end(), selected)));
- // currentIx += right ? 1 : pills.size()-1;
- // pills[currentIx % pills.size()]->textButton.triggerClick();
}
void Pills::resized() {
- int index = 0;
- Rectangle r (getLocalBounds());
- const int equalWidth = r.proportionOfWidth(pills.size() <= 0 ? 1.0 : 1.0f/pills.size());
+ int index{0};
+ Rectangle r{getLocalBounds()};
+ const int equalWidth{r.proportionOfWidth(pills.size() <= 0 ? 1.0 : 1.0f/pills.size())};
for(auto& pill : pills) {
Rectangle r2 (getLocalBounds());
r2.removeFromLeft(equalWidth * index);