copy JUCE demo plugin more closely. worry about coupling later; for now get ownership in right place. update lastUIW/H on resize.
This commit is contained in:
parent
89b12b132a
commit
9bbb27d780
|
@ -22,9 +22,9 @@ JuicySFAudioProcessorEditor::JuicySFAudioProcessorEditor (JuicySFAudioProcessor&
|
||||||
// set resize limits for this plug-in
|
// set resize limits for this plug-in
|
||||||
setResizeLimits (400, 300, 800, 600);
|
setResizeLimits (400, 300, 800, 600);
|
||||||
|
|
||||||
setSize (400, 300);
|
setSize (p.lastUIWidth, p.lastUIHeight);
|
||||||
|
|
||||||
processor.subscribeToStateChanges(this);
|
// processor.subscribeToStateChanges(this);
|
||||||
|
|
||||||
midiKeyboard.setName ("MIDI Keyboard");
|
midiKeyboard.setName ("MIDI Keyboard");
|
||||||
|
|
||||||
|
@ -40,20 +40,20 @@ JuicySFAudioProcessorEditor::JuicySFAudioProcessorEditor (JuicySFAudioProcessor&
|
||||||
|
|
||||||
JuicySFAudioProcessorEditor::~JuicySFAudioProcessorEditor()
|
JuicySFAudioProcessorEditor::~JuicySFAudioProcessorEditor()
|
||||||
{
|
{
|
||||||
processor.unsubscribeFromStateChanges(this);
|
// processor.unsubscribeFromStateChanges(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JuicySFAudioProcessorEditor::getStateInformation (XmlElement& xml) {
|
//void JuicySFAudioProcessorEditor::getStateInformation (XmlElement& xml) {
|
||||||
// save
|
// // save
|
||||||
xml.setAttribute ("uiWidth", getWidth());
|
// xml.setAttribute ("uiWidth", getWidth());
|
||||||
xml.setAttribute ("uiHeight", getHeight());
|
// xml.setAttribute ("uiHeight", getHeight());
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
void JuicySFAudioProcessorEditor::setStateInformation (XmlElement* xmlState) {
|
//void JuicySFAudioProcessorEditor::setStateInformation (XmlElement* xmlState) {
|
||||||
// load
|
// // load
|
||||||
setSize (xmlState->getIntAttribute ("uiWidth", getWidth()),
|
// setSize (xmlState->getIntAttribute ("uiWidth", getWidth()),
|
||||||
xmlState->getIntAttribute ("uiHeight", getHeight()));
|
// xmlState->getIntAttribute ("uiHeight", getHeight()));
|
||||||
}
|
//}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
void JuicySFAudioProcessorEditor::paint (Graphics& g)
|
void JuicySFAudioProcessorEditor::paint (Graphics& g)
|
||||||
|
@ -85,6 +85,9 @@ void JuicySFAudioProcessorEditor::resized()
|
||||||
midiKeyboard.setBounds (r.removeFromBottom (pianoHeight).reduced(padding, 0));
|
midiKeyboard.setBounds (r.removeFromBottom (pianoHeight).reduced(padding, 0));
|
||||||
tablesComponent.setBounds(r.reduced(0, padding));
|
tablesComponent.setBounds(r.reduced(0, padding));
|
||||||
|
|
||||||
|
processor.lastUIWidth = getWidth();
|
||||||
|
processor.lastUIHeight = getHeight();
|
||||||
|
|
||||||
// Rectangle<int> r2 (getLocalBounds());
|
// Rectangle<int> r2 (getLocalBounds());
|
||||||
// r2.reduce(0, padding);
|
// r2.reduce(0, padding);
|
||||||
// r2.removeFromBottom(pianoHeight);
|
// r2.removeFromBottom(pianoHeight);
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
class JuicySFAudioProcessorEditor : public AudioProcessorEditor,
|
class JuicySFAudioProcessorEditor : public AudioProcessorEditor/*,
|
||||||
public StateChangeSubscriber
|
public StateChangeSubscriber*/
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
JuicySFAudioProcessorEditor (JuicySFAudioProcessor&);
|
JuicySFAudioProcessorEditor (JuicySFAudioProcessor&);
|
||||||
|
@ -34,8 +34,8 @@ public:
|
||||||
bool keyPressed(const KeyPress &key) override;
|
bool keyPressed(const KeyPress &key) override;
|
||||||
bool keyStateChanged (bool isKeyDown) override;
|
bool keyStateChanged (bool isKeyDown) override;
|
||||||
|
|
||||||
void getStateInformation (XmlElement& xml) override;
|
// void getStateInformation (XmlElement& xml) override;
|
||||||
void setStateInformation (XmlElement* xmlState) override;
|
// void setStateInformation (XmlElement* xmlState) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This reference is provided as a quick way for your editor to
|
// This reference is provided as a quick way for your editor to
|
||||||
|
|
|
@ -19,9 +19,10 @@ AudioProcessor* JUCE_CALLTYPE createPluginFilter();
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
JuicySFAudioProcessor::JuicySFAudioProcessor()
|
JuicySFAudioProcessor::JuicySFAudioProcessor()
|
||||||
: AudioProcessor (getBusesProperties()),
|
: AudioProcessor (getBusesProperties()),
|
||||||
fluidSynthModel()/*,
|
|
||||||
lastUIWidth(400),
|
lastUIWidth(400),
|
||||||
lastUIHeight(300)*/
|
lastUIHeight(300),
|
||||||
|
fluidSynthModel(),
|
||||||
|
soundFontPath(String())
|
||||||
{
|
{
|
||||||
initialiseSynth();
|
initialiseSynth();
|
||||||
}
|
}
|
||||||
|
@ -187,10 +188,14 @@ void JuicySFAudioProcessor::getStateInformation (MemoryBlock& destData)
|
||||||
// Create an outer XML element..
|
// Create an outer XML element..
|
||||||
XmlElement xml ("MYPLUGINSETTINGS");
|
XmlElement xml ("MYPLUGINSETTINGS");
|
||||||
|
|
||||||
list<StateChangeSubscriber*>::iterator p;
|
// add some attributes to it..
|
||||||
for(p = stateChangeSubscribers.begin(); p != stateChangeSubscribers.end(); p++) {
|
xml.setAttribute ("uiWidth", lastUIWidth);
|
||||||
(*p)->getStateInformation(xml);
|
xml.setAttribute ("uiHeight", lastUIHeight);
|
||||||
}
|
|
||||||
|
// list<StateChangeSubscriber*>::iterator p;
|
||||||
|
// for(p = stateChangeSubscribers.begin(); p != stateChangeSubscribers.end(); p++) {
|
||||||
|
// (*p)->getStateInformation(xml);
|
||||||
|
// }
|
||||||
|
|
||||||
// Store the values of all our parameters, using their param ID as the XML attribute
|
// Store the values of all our parameters, using their param ID as the XML attribute
|
||||||
for (auto* param : getParameters())
|
for (auto* param : getParameters())
|
||||||
|
@ -213,10 +218,14 @@ void JuicySFAudioProcessor::setStateInformation (const void* data, int sizeInByt
|
||||||
// make sure that it's actually our type of XML object..
|
// make sure that it's actually our type of XML object..
|
||||||
if (xmlState->hasTagName ("MYPLUGINSETTINGS"))
|
if (xmlState->hasTagName ("MYPLUGINSETTINGS"))
|
||||||
{
|
{
|
||||||
list<StateChangeSubscriber*>::iterator p;
|
// list<StateChangeSubscriber*>::iterator p;
|
||||||
for(p = stateChangeSubscribers.begin(); p != stateChangeSubscribers.end(); p++) {
|
// for(p = stateChangeSubscribers.begin(); p != stateChangeSubscribers.end(); p++) {
|
||||||
(*p)->setStateInformation(xmlState);
|
// (*p)->setStateInformation(xmlState);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
// ok, now pull out our last window size..
|
||||||
|
lastUIWidth = jmax (xmlState->getIntAttribute ("uiWidth", lastUIWidth), 400);
|
||||||
|
lastUIHeight = jmax (xmlState->getIntAttribute ("uiHeight", lastUIHeight), 300);
|
||||||
|
|
||||||
// Now reload our parameters..
|
// Now reload our parameters..
|
||||||
for (auto* param : getParameters())
|
for (auto* param : getParameters())
|
||||||
|
@ -226,13 +235,13 @@ void JuicySFAudioProcessor::setStateInformation (const void* data, int sizeInByt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JuicySFAudioProcessor::subscribeToStateChanges(StateChangeSubscriber* subscriber) {
|
//void JuicySFAudioProcessor::subscribeToStateChanges(StateChangeSubscriber* subscriber) {
|
||||||
stateChangeSubscribers.push_back(subscriber);
|
// stateChangeSubscribers.push_back(subscriber);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
void JuicySFAudioProcessor::unsubscribeFromStateChanges(StateChangeSubscriber* subscriber) {
|
//void JuicySFAudioProcessor::unsubscribeFromStateChanges(StateChangeSubscriber* subscriber) {
|
||||||
stateChangeSubscribers.remove(subscriber);
|
// stateChangeSubscribers.remove(subscriber);
|
||||||
}
|
//}
|
||||||
|
|
||||||
// FluidSynth only supports float in its process function, so that's all we can support.
|
// FluidSynth only supports float in its process function, so that's all we can support.
|
||||||
bool JuicySFAudioProcessor::supportsDoublePrecisionProcessing() const {
|
bool JuicySFAudioProcessor::supportsDoublePrecisionProcessing() const {
|
||||||
|
|
|
@ -65,8 +65,11 @@ public:
|
||||||
|
|
||||||
MidiKeyboardState keyboardState;
|
MidiKeyboardState keyboardState;
|
||||||
|
|
||||||
void subscribeToStateChanges(StateChangeSubscriber* subscriber);
|
// void subscribeToStateChanges(StateChangeSubscriber* subscriber);
|
||||||
void unsubscribeFromStateChanges(StateChangeSubscriber* subscriber);
|
// void unsubscribeFromStateChanges(StateChangeSubscriber* subscriber);
|
||||||
|
|
||||||
|
int lastUIWidth, lastUIHeight;
|
||||||
|
String soundFontPath;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initialiseSynth();
|
void initialiseSynth();
|
||||||
|
@ -75,7 +78,7 @@ private:
|
||||||
fluid_synth_t* fluidSynth;
|
fluid_synth_t* fluidSynth;
|
||||||
Synthesiser synth;
|
Synthesiser synth;
|
||||||
|
|
||||||
list<StateChangeSubscriber*> stateChangeSubscribers;
|
// list<StateChangeSubscriber*> stateChangeSubscribers;
|
||||||
|
|
||||||
static BusesProperties getBusesProperties();
|
static BusesProperties getBusesProperties();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user