2
0
Fork 0

GUI settings updated to reflect parameters on preset load.

This commit is contained in:
bruce 2013-09-29 12:25:37 +08:00
parent a687e75714
commit 6952e7faf7
4 changed files with 87 additions and 13 deletions

View file

@ -24,6 +24,58 @@
//[MiscUserDefs] You can add your own user definitions and misc code here... //[MiscUserDefs] You can add your own user definitions and misc code here...
void PluginGui::updateFromParameters()
{
sineImageButton->setToggleState(false, false);
halfsineImageButton->setToggleState(false, false);
abssineImageButton->setToggleState(false, false);
quartersineImageButton->setToggleState(false, false);
switch(processor->getEnumParameter("Modulator Wave")) {
case 0: sineImageButton->setToggleState(true, false); break;
case 1: halfsineImageButton->setToggleState(true, false); break;
case 2: abssineImageButton->setToggleState(true, false); break;
case 3: quartersineImageButton->setToggleState(true, false); break;
}
sineImageButton2->setToggleState(false, false);
halfsineImageButton2->setToggleState(false, false);
abssineImageButton2->setToggleState(false, false);
quartersineImageButton2->setToggleState(false, false);
switch(processor->getEnumParameter("Carrier Wave")) {
case 0: sineImageButton2->setToggleState(true, false); break;
case 1: halfsineImageButton2->setToggleState(true, false); break;
case 2: abssineImageButton2->setToggleState(true, false); break;
case 3: quartersineImageButton2->setToggleState(true, false); break;
}
frequencyComboBox->setSelectedItemIndex(processor->getEnumParameter("Modulator Frequency Multiplier"), true);
frequencyComboBox2->setSelectedItemIndex(processor->getEnumParameter("Carrier Frequency Multiplier"), true);
attenuationSlider->setValue(processor->getEnumParameter("Modulator Attenuation") * -0.75, NotificationType::dontSendNotification);
attenuationSlider2->setValue(processor->getEnumParameter("Carrier Attenuation") * -0.75, NotificationType::dontSendNotification);
aSlider->setValue(processor->getIntParameter("Modulator Attack"), NotificationType::dontSendNotification);
dSlider->setValue(processor->getIntParameter("Modulator Decay"), NotificationType::dontSendNotification);
sSlider->setValue(processor->getIntParameter("Modulator Sustain Level"), NotificationType::dontSendNotification);
rSlider->setValue(processor->getIntParameter("Modulator Release"), NotificationType::dontSendNotification);
aSlider2->setValue(processor->getIntParameter("Carrier Attack"), NotificationType::dontSendNotification);
dSlider2->setValue(processor->getIntParameter("Carrier Decay"), NotificationType::dontSendNotification);
sSlider2->setValue(processor->getIntParameter("Carrier Sustain Level"), NotificationType::dontSendNotification);
rSlider2->setValue(processor->getIntParameter("Carrier Release"), NotificationType::dontSendNotification);
keyscaleSlider->setValue(processor->getIntParameter("Modulator Keyscale Level"), NotificationType::dontSendNotification);
keyscaleSlider2->setValue(processor->getIntParameter("Carrier Keyscale Level"), NotificationType::dontSendNotification);
if (processor->getEnumParameter("Modulator Tremolo")) tremoloButton->setToggleState(true, false);
if (processor->getEnumParameter("Modulator Vibrato")) vibratoButton->setToggleState(true, false);
if (processor->getEnumParameter("Modulator Sustain")) sustainButton->setToggleState(true, false);
if (processor->getEnumParameter("Modulator Keyscale Rate")) keyscaleEnvButton->setToggleState(true, false);
if (processor->getEnumParameter("Carrier Tremolo")) tremoloButton2->setToggleState(true, false);
if (processor->getEnumParameter("Carrier Vibrato")) vibratoButton2->setToggleState(true, false);
if (processor->getEnumParameter("Carrier Sustain")) sustainButton2->setToggleState(true, false);
if (processor->getEnumParameter("Carrier Keyscale Rate")) keyscaleEnvButton2->setToggleState(true, false);
}
//[/MiscUserDefs] //[/MiscUserDefs]
//============================================================================== //==============================================================================
@ -396,7 +448,7 @@ PluginGui::PluginGui (JuceOplvstiAudioProcessor* ownerFilter)
addAndMakeVisible (sineImageButton2 = new ImageButton ("sine image button")); addAndMakeVisible (sineImageButton2 = new ImageButton ("sine image button"));
sineImageButton2->setTooltip ("sine"); sineImageButton2->setTooltip ("sine");
sineImageButton2->setButtonText ("Sine"); sineImageButton2->setButtonText ("Sine");
sineImageButton2->setRadioGroupId (1); sineImageButton2->setRadioGroupId (2);
sineImageButton2->addListener (this); sineImageButton2->addListener (this);
sineImageButton2->setImages (false, true, true, sineImageButton2->setImages (false, true, true,
@ -406,7 +458,7 @@ PluginGui::PluginGui (JuceOplvstiAudioProcessor* ownerFilter)
addAndMakeVisible (halfsineImageButton2 = new ImageButton ("half sine image button")); addAndMakeVisible (halfsineImageButton2 = new ImageButton ("half sine image button"));
halfsineImageButton2->setTooltip ("half sine"); halfsineImageButton2->setTooltip ("half sine");
halfsineImageButton2->setButtonText ("Half Sine"); halfsineImageButton2->setButtonText ("Half Sine");
halfsineImageButton2->setRadioGroupId (1); halfsineImageButton2->setRadioGroupId (2);
halfsineImageButton2->addListener (this); halfsineImageButton2->addListener (this);
halfsineImageButton2->setImages (false, true, true, halfsineImageButton2->setImages (false, true, true,
@ -416,7 +468,7 @@ PluginGui::PluginGui (JuceOplvstiAudioProcessor* ownerFilter)
addAndMakeVisible (abssineImageButton2 = new ImageButton ("abs sine image button")); addAndMakeVisible (abssineImageButton2 = new ImageButton ("abs sine image button"));
abssineImageButton2->setTooltip ("abs sine"); abssineImageButton2->setTooltip ("abs sine");
abssineImageButton2->setButtonText ("Abs Sine"); abssineImageButton2->setButtonText ("Abs Sine");
abssineImageButton2->setRadioGroupId (1); abssineImageButton2->setRadioGroupId (2);
abssineImageButton2->addListener (this); abssineImageButton2->addListener (this);
abssineImageButton2->setImages (false, true, true, abssineImageButton2->setImages (false, true, true,
@ -426,7 +478,7 @@ PluginGui::PluginGui (JuceOplvstiAudioProcessor* ownerFilter)
addAndMakeVisible (quartersineImageButton2 = new ImageButton ("quarter sine image button")); addAndMakeVisible (quartersineImageButton2 = new ImageButton ("quarter sine image button"));
quartersineImageButton2->setTooltip ("quarter sine"); quartersineImageButton2->setTooltip ("quarter sine");
quartersineImageButton2->setButtonText ("Quarter Sine"); quartersineImageButton2->setButtonText ("Quarter Sine");
quartersineImageButton2->setRadioGroupId (1); quartersineImageButton2->setRadioGroupId (2);
quartersineImageButton2->addListener (this); quartersineImageButton2->addListener (this);
quartersineImageButton2->setImages (false, true, true, quartersineImageButton2->setImages (false, true, true,
@ -1141,26 +1193,26 @@ BEGIN_JUCER_METADATA
fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/> fontname="Default font" fontsize="15" bold="0" italic="0" justification="36"/>
<IMAGEBUTTON name="sine image button" id="27e01d31ba835965" memberName="sineImageButton2" <IMAGEBUTTON name="sine image button" id="27e01d31ba835965" memberName="sineImageButton2"
virtualName="" explicitFocusOrder="0" pos="120 352 34 30" tooltip="sine" virtualName="" explicitFocusOrder="0" pos="120 352 34 30" tooltip="sine"
buttonText="Sine" connectedEdges="0" needsCallback="1" radioGroupId="1" buttonText="Sine" connectedEdges="0" needsCallback="1" radioGroupId="2"
keepProportions="1" resourceNormal="full_sine_png" opacityNormal="0.5" keepProportions="1" resourceNormal="full_sine_png" opacityNormal="0.5"
colourNormal="0" resourceOver="" opacityOver="0.5" colourOver="0" colourNormal="0" resourceOver="" opacityOver="0.5" colourOver="0"
resourceDown="" opacityDown="1" colourDown="0"/> resourceDown="" opacityDown="1" colourDown="0"/>
<IMAGEBUTTON name="half sine image button" id="6e9afdb08dd4edac" memberName="halfsineImageButton2" <IMAGEBUTTON name="half sine image button" id="6e9afdb08dd4edac" memberName="halfsineImageButton2"
virtualName="" explicitFocusOrder="0" pos="176 352 34 30" tooltip="half sine" virtualName="" explicitFocusOrder="0" pos="176 352 34 30" tooltip="half sine"
buttonText="Half Sine" connectedEdges="0" needsCallback="1" radioGroupId="1" buttonText="Half Sine" connectedEdges="0" needsCallback="1" radioGroupId="2"
keepProportions="1" resourceNormal="half_sine_png" opacityNormal="0.5" keepProportions="1" resourceNormal="half_sine_png" opacityNormal="0.5"
colourNormal="0" resourceOver="" opacityOver="0.5" colourOver="0" colourNormal="0" resourceOver="" opacityOver="0.5" colourOver="0"
resourceDown="" opacityDown="1" colourDown="0"/> resourceDown="" opacityDown="1" colourDown="0"/>
<IMAGEBUTTON name="abs sine image button" id="361941cfa04130c1" memberName="abssineImageButton2" <IMAGEBUTTON name="abs sine image button" id="361941cfa04130c1" memberName="abssineImageButton2"
virtualName="" explicitFocusOrder="0" pos="232 352 34 30" tooltip="abs sine" virtualName="" explicitFocusOrder="0" pos="232 352 34 30" tooltip="abs sine"
buttonText="Abs Sine" connectedEdges="0" needsCallback="1" radioGroupId="1" buttonText="Abs Sine" connectedEdges="0" needsCallback="1" radioGroupId="2"
keepProportions="1" resourceNormal="abs_sine_png" opacityNormal="0.5" keepProportions="1" resourceNormal="abs_sine_png" opacityNormal="0.5"
colourNormal="0" resourceOver="" opacityOver="0.5" colourOver="0" colourNormal="0" resourceOver="" opacityOver="0.5" colourOver="0"
resourceDown="" opacityDown="1" colourDown="0"/> resourceDown="" opacityDown="1" colourDown="0"/>
<IMAGEBUTTON name="quarter sine image button" id="3fa62f49fdd1a41f" memberName="quartersineImageButton2" <IMAGEBUTTON name="quarter sine image button" id="3fa62f49fdd1a41f" memberName="quartersineImageButton2"
virtualName="" explicitFocusOrder="0" pos="288 352 34 30" tooltip="quarter sine" virtualName="" explicitFocusOrder="0" pos="288 352 34 30" tooltip="quarter sine"
buttonText="Quarter Sine" connectedEdges="0" needsCallback="1" buttonText="Quarter Sine" connectedEdges="0" needsCallback="1"
radioGroupId="1" keepProportions="1" resourceNormal="quarter_sine_png" radioGroupId="2" keepProportions="1" resourceNormal="quarter_sine_png"
opacityNormal="0.5" colourNormal="0" resourceOver="" opacityOver="0.5" opacityNormal="0.5" colourNormal="0" resourceOver="" opacityOver="0.5"
colourOver="0" resourceDown="" opacityDown="1" colourDown="0"/> colourOver="0" resourceDown="" opacityDown="1" colourDown="0"/>
<LABEL name="wave label" id="c810628f3c772781" memberName="waveLabel2" <LABEL name="wave label" id="c810628f3c772781" memberName="waveLabel2"

View file

@ -30,9 +30,7 @@
//============================================================================== //==============================================================================
/** /**
//[Comments] //[Comments]
An auto-generated component, created by the Introjucer. This is a GUI for the OPL2 VST plugin, created in Juce.
Describe your class and how it works here!
//[/Comments] //[/Comments]
*/ */
class PluginGui : public AudioProcessorEditor, class PluginGui : public AudioProcessorEditor,
@ -47,6 +45,7 @@ public:
//============================================================================== //==============================================================================
//[UserMethods] -- You can add your own custom methods in this section. //[UserMethods] -- You can add your own custom methods in this section.
void updateFromParameters();
//[/UserMethods] //[/UserMethods]
void paint (Graphics& g); void paint (Graphics& g);

View file

@ -110,10 +110,11 @@ JuceOplvstiAudioProcessor::JuceOplvstiAudioProcessor()
for(std::map<String,std::vector<float>>::iterator it = programs.begin(); it != programs.end(); ++it) { for(std::map<String,std::vector<float>>::iterator it = programs.begin(); it != programs.end(); ++it) {
program_order.push_back(it->first); program_order.push_back(it->first);
} }
setCurrentProgram(0); setCurrentProgram(0);
for (int i = 0; i < Hiopl::CHANNELS+1; i++) { for (int i = 0; i < Hiopl::CHANNELS+1; i++) {
active_notes[i] = NO_NOTE; active_notes[i] = NO_NOTE;
} }
} }
void JuceOplvstiAudioProcessor::initPrograms() void JuceOplvstiAudioProcessor::initPrograms()
@ -396,6 +397,20 @@ void JuceOplvstiAudioProcessor::setEnumParameter (String name, int index)
setParameter(i, p->getParameter()); setParameter(i, p->getParameter());
} }
int JuceOplvstiAudioProcessor::getIntParameter (String name)
{
int i = paramIdxByName[name];
IntFloatParameter* p = (IntFloatParameter*)params[i];
return p->getParameterValue();
}
int JuceOplvstiAudioProcessor::getEnumParameter (String name)
{
int i = paramIdxByName[name];
EnumFloatParameter* p = (EnumFloatParameter*)params[i];
return p->getParameterIndex();
}
void JuceOplvstiAudioProcessor::setParameter (int index, float newValue) void JuceOplvstiAudioProcessor::setParameter (int index, float newValue)
{ {
FloatParameter* p = params[index]; FloatParameter* p = params[index];
@ -518,6 +533,10 @@ void JuceOplvstiAudioProcessor::setCurrentProgram (int index)
for (unsigned int i = 0; i < params.size() && i < v_params.size(); i++) { for (unsigned int i = 0; i < params.size() && i < v_params.size(); i++) {
setParameter(i, v_params[i]); setParameter(i, v_params[i]);
} }
PluginGui* gui = (PluginGui*)getActiveEditor();
if (gui) {
gui->updateFromParameters();
}
} }
const String JuceOplvstiAudioProcessor::getProgramName (int index) const String JuceOplvstiAudioProcessor::getProgramName (int index)
@ -588,7 +607,9 @@ bool JuceOplvstiAudioProcessor::hasEditor() const
AudioProcessorEditor* JuceOplvstiAudioProcessor::createEditor() AudioProcessorEditor* JuceOplvstiAudioProcessor::createEditor()
{ {
return new PluginGui (this); PluginGui* gui = new PluginGui(this);
gui->updateFromParameters();
return gui;
} }
//============================================================================== //==============================================================================

View file

@ -46,6 +46,8 @@ public:
void setParameter (int index, float newValue); void setParameter (int index, float newValue);
void setEnumParameter (String name, int newValue); void setEnumParameter (String name, int newValue);
void setIntParameter (String name, int newValue); void setIntParameter (String name, int newValue);
int getIntParameter (String name);
int getEnumParameter (String name);
const String getParameterName (int index); const String getParameterName (int index);
const String getParameterText (int index); const String getParameterText (int index);