diff --git a/Source/FluidSynthModel.cpp b/Source/FluidSynthModel.cpp index 5b8cef1..fd7ff8b 100644 --- a/Source/FluidSynthModel.cpp +++ b/Source/FluidSynthModel.cpp @@ -379,6 +379,8 @@ void FluidSynthModel::loadFont(const String &absPath) { // valueTreeState.state.getChildWithName("presets") = presets; valueTreeState.state.getChildWithName("banks").copyPropertiesAndChildrenFrom(banks, nullptr); valueTreeState.state.getChildWithName("presets").copyPropertiesAndChildrenFrom(presets, nullptr); + valueTreeState.state.getChildWithName("banks").sendPropertyChangeMessage("synthetic"); + valueTreeState.state.getChildWithName("presets").sendPropertyChangeMessage("synthetic"); #if JUCE_DEBUG unique_ptr xml{valueTreeState.state.createXml()}; diff --git a/Source/Pills.cpp b/Source/Pills.cpp index cb03df7..03d3056 100644 --- a/Source/Pills.cpp +++ b/Source/Pills.cpp @@ -19,6 +19,7 @@ Pill::Pill( , bank{bank} , textButton{String(bank)} { + setOpaque(true); textButton.setConnectedEdges ( (isFirst ? 0 : Button::ConnectedOnLeft) | (isLast ? 0 : Button::ConnectedOnRight) @@ -26,12 +27,24 @@ Pill::Pill( textButton.setRadioGroupId(34567); loadToggleState(); textButton.setClickingTogglesState(true); + + addAndMakeVisible(textButton); valueTreeState.addParameterListener("bank", this); // valueTreeState.state.addListener(this); textButton.addListener(this); } +void Pill::paint (Graphics& g) +{ + // (Our component is opaque, so we must completely fill the background with a solid colour) + g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); +} + +void Pill::resized() { + textButton.setBounds(getLocalBounds()); +} + Pill::~Pill() { valueTreeState.removeParameterListener("bank", this); // valueTreeState.state.removeListener(this); @@ -101,7 +114,9 @@ void Pills::valueTreePropertyChanged( ValueTree& treeWhosePropertyHasChanged, const Identifier& property) { if (treeWhosePropertyHasChanged.getType() == StringRef("banks")) { - loadModelFrom(treeWhosePropertyHasChanged); + if (property == StringRef("synthetic")) { + loadModelFrom(treeWhosePropertyHasChanged); + } } } @@ -114,13 +129,15 @@ void Pills::loadModelFrom(ValueTree& banks) { // rows.push_back(unique_ptr(new Pill(), [](Pill* pill) { // pill->remo // })); - pills.push_back( - make_unique( + unique_ptr pill{make_unique( valueTreeState, num, i == 0, - i == numChildren - 1)); + i == numChildren - 1)}; + addAndMakeVisible(pill.get()); + pills.push_back(move(pill)); } + resized(); } // void Pills::populate(int initiallySelectedItem) { @@ -210,7 +227,7 @@ void Pills::resized() { Rectangle r2 (getLocalBounds()); r2.removeFromLeft(equalWidth * index); r2.removeFromRight(equalWidth * (static_cast(pills.size())-index-1)); - pill->textButton.setBounds (r2); + pill->setBounds(r2); index++; } } diff --git a/Source/Pills.h b/Source/Pills.h index c66f756..2264231 100644 --- a/Source/Pills.h +++ b/Source/Pills.h @@ -9,7 +9,8 @@ using namespace std; class Pill -: public Button::Listener +: public Component +, public Button::Listener , public AudioProcessorValueTreeState::Listener { public: @@ -23,6 +24,9 @@ public: void buttonClicked (Button* button) override; + void resized() override; + void paint(Graphics& g) override; + virtual void parameterChanged (const String& parameterID, float newValue) override; private: void loadToggleState(); diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index b062ff3..2c7d3eb 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -73,7 +73,7 @@ JuicySFAudioProcessorEditor::JuicySFAudioProcessorEditor( tablesComponent.setWantsKeyboardFocus(false); setWantsKeyboardFocus(true); - addAndMakeVisible (midiKeyboard); + addAndMakeVisible(midiKeyboard); addAndMakeVisible(slidersComponent); addAndMakeVisible(tablesComponent); diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 40e6515..b614540 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -73,8 +73,8 @@ AudioProcessorValueTreeState::ParameterLayout JuicySFAudioProcessor::createParam // make_unique("uiHeightTemp", "height of this plugin's GUI. Editor writes here on change (e.g. on window resize). Processor copies this into Persist before any save.", GuiConstants::minHeight, GuiConstants::maxHeight, GuiConstants::minHeight, "UI Height Temp" ), // make_unique("uiWidth", "width of this plugin's GUI", GuiConstants::minWidth, GuiConstants::maxWidth, GuiConstants::minWidth, "UI Width" ), // make_unique("uiHeight", "height of this plugin's GUI", GuiConstants::minHeight, GuiConstants::maxHeight, GuiConstants::minHeight, "UI Height" ), - // todo: check whether bank really is 0-127 - make_unique("bank", "which bank is selected in the soundfont", MidiConstants::midiMinValue, MidiConstants::midiMaxValue, MidiConstants::midiMinValue, "Bank" ), + // SoundFont 2.4 spec section 7.2: zero through 127, or 128. + make_unique("bank", "which bank is selected in the soundfont", MidiConstants::midiMinValue, 128, MidiConstants::midiMinValue, "Bank" ), // note: banks may be sparse, and lack a 0th preset. so defend against this. make_unique("preset", "which patch (aka patch, program, instrument) is selected in the soundfont", MidiConstants::midiMinValue, MidiConstants::midiMaxValue, MidiConstants::midiMinValue, "Preset" ), make_unique("attack", "volume envelope attack time", MidiConstants::midiMinValue, MidiConstants::midiMaxValue, MidiConstants::midiMinValue, "A" ), diff --git a/Source/TableComponent.cpp b/Source/TableComponent.cpp index 021c1af..babf668 100644 --- a/Source/TableComponent.cpp +++ b/Source/TableComponent.cpp @@ -120,19 +120,52 @@ void TableComponent::parameterChanged(const String& parameterID, float newValue) } } -// void TableComponent::valueTreePropertyChanged( -// ValueTree& treeWhosePropertyHasChanged, -// const Identifier& property) { -// if (treeWhosePropertyHasChanged.getType() == StringRef("presets")) { -// loadModelFrom(treeWhosePropertyHasChanged); +void TableComponent::valueTreePropertyChanged( + ValueTree& treeWhosePropertyHasChanged, + const Identifier& property) { + if (treeWhosePropertyHasChanged.getType() == StringRef("presets")) { + if (property == StringRef("synthetic")) { + loadModelFrom(treeWhosePropertyHasChanged); + } + } +} + +// void TableComponent::valueTreeParentChanged(ValueTree& treeWhoseParentHasChanged) { +// if (treeWhoseParentHasChanged.getType() == StringRef("presets")) { +// loadModelFrom(treeWhoseParentHasChanged); // } // } -void TableComponent::valueTreeParentChanged(ValueTree& treeWhoseParentHasChanged) { - if (treeWhoseParentHasChanged.getType() == StringRef("presets")) { - loadModelFrom(treeWhoseParentHasChanged); - } -} +// void TableComponent::valueTreePropertyChanged( +// ValueTree& treeWhosePropertyHasChanged, +// const Identifier& property) { +// DEBUG_PRINT(treeWhosePropertyHasChanged.getType().toString()); +// } +// void TableComponent::valueTreeChildAdded( +// ValueTree& parentTree, +// ValueTree& childWhichHasBeenAdded) { +// DEBUG_PRINT(parentTree.getType().toString()); +// } +// void TableComponent::valueTreeChildRemoved( +// ValueTree& parentTree, +// ValueTree& childWhichHasBeenRemoved, +// int indexFromWhichChildWasRemoved) { +// DEBUG_PRINT(parentTree.getType().toString()); +// } +// void TableComponent::valueTreeChildOrderChanged( +// ValueTree& parentTreeWhoseChildrenHaveMoved, +// int oldIndex, +// int newIndex) { +// DEBUG_PRINT(parentTreeWhoseChildrenHaveMoved.getType().toString()); +// } +// void TableComponent::valueTreeParentChanged( +// ValueTree& treeWhoseParentHasChanged) { +// DEBUG_PRINT(treeWhoseParentHasChanged.getType().toString()); +// } +// void TableComponent::valueTreeRedirected( +// ValueTree& treeWhichHasBeenChanged) { +// DEBUG_PRINT(treeWhichHasBeenChanged.getType().toString()); +// } // void TableComponent::setRows(const vector>& rows, int initiallySelectedRow) { // this->rows = rows; diff --git a/Source/TableComponent.h b/Source/TableComponent.h index 6944ccc..41feaa3 100644 --- a/Source/TableComponent.h +++ b/Source/TableComponent.h @@ -79,8 +79,8 @@ public: virtual void parameterChanged (const String& parameterID, float newValue) override; - inline virtual void valueTreePropertyChanged (ValueTree& treeWhosePropertyHasChanged, - const Identifier& property) override {}; + virtual void valueTreePropertyChanged (ValueTree& treeWhosePropertyHasChanged, + const Identifier& property) override; inline virtual void valueTreeChildAdded (ValueTree& parentTree, ValueTree& childWhichHasBeenAdded) override {}; inline virtual void valueTreeChildRemoved (ValueTree& parentTree, @@ -88,7 +88,7 @@ public: int indexFromWhichChildWasRemoved) override {}; inline virtual void valueTreeChildOrderChanged (ValueTree& parentTreeWhoseChildrenHaveMoved, int oldIndex, int newIndex) override {}; - virtual void valueTreeParentChanged (ValueTree& treeWhoseParentHasChanged) override; + inline virtual void valueTreeParentChanged (ValueTree& treeWhoseParentHasChanged) override {}; inline virtual void valueTreeRedirected (ValueTree& treeWhichHasBeenChanged) override {}; private: void loadModelFrom(ValueTree& presets);