Skip to content
Snippets Groups Projects
Commit 0f97c42b authored by jsiegle's avatar jsiegle
Browse files

FilterEditor now has text box inputs

parent 35342cc5
No related branches found
No related tags found
No related merge requests found
......@@ -30,9 +30,40 @@ FilterEditor::FilterEditor(GenericProcessor* parentNode, bool useDefaultParamete
: GenericEditor(parentNode, useDefaultParameterEditors)
{
desiredWidth = 180;
desiredWidth = 150;
lastHighCutString = "6000";
lastLowCutString = "600";
highCutLabel = new Label("high cut label", "High cut:");
highCutLabel->setBounds(35,80,180,20);
highCutLabel->setFont(Font("Small Text", 12, Font::plain));
highCutLabel->setColour(Label::textColourId, Colours::darkgrey);
addAndMakeVisible(highCutLabel);
lowCutLabel = new Label("low cut label", "Low cut:");
lowCutLabel->setBounds(35,30,180,20);
lowCutLabel->setFont(Font("Small Text", 12, Font::plain));
lowCutLabel->setColour(Label::textColourId, Colours::darkgrey);
addAndMakeVisible(lowCutLabel);
lowCutValue = new Label("low cut value", lastLowCutString);
lowCutValue->setBounds(40,50,60,20);
lowCutValue->setFont(Font("Default", 15, Font::plain));
lowCutValue->setColour(Label::textColourId, Colours::white);
lowCutValue->setColour(Label::backgroundColourId, Colours::grey);
lowCutValue->setEditable(true);
lowCutValue->addListener(this);
addAndMakeVisible(lowCutValue);
highCutValue = new Label("high cut label", lastHighCutString);
highCutValue->setBounds(40,100,60,20);
highCutValue->setFont(Font("Default", 15, Font::plain));
highCutValue->setColour(Label::textColourId, Colours::white);
highCutValue->setColour(Label::backgroundColourId, Colours::grey);
highCutValue->setEditable(true);
highCutValue->addListener(this);
addAndMakeVisible(highCutValue);
//createRadioButtons(35, 50, 160, lowCutValues, "Low Cutoff");
//createRadioButtons(35, 90, 160, highCutValues, "High Cutoff");
......@@ -52,7 +83,7 @@ FilterEditor::FilterEditor(GenericProcessor* parentNode, bool useDefaultParamete
FilterEditor::~FilterEditor()
{
deleteAllChildren();
// deleteAllChildren();
}
// void FilterEditor::sliderValueChanged (Slider* slider)
......@@ -65,34 +96,114 @@ FilterEditor::~FilterEditor()
// }
void FilterEditor::buttonEvent(Button* button)
void FilterEditor::labelTextChanged(Label* label)
{
//std::cout << button->getRadioGroupId() << " " << button->getName() << std::endl;
FilterNode* fn = (FilterNode*) getProcessor();
//if (!checkDrawerButton(button) && !checkChannelSelectors(button)) {
Value val = label->getTextValue();
double requestedValue = double(val.getValue());
String value = button->getName();
float val;
if (requestedValue < 0.01 || requestedValue > 10000)
{
sendActionMessage("Value out of range.");
if (label == highCutValue)
{
label->setText(lastHighCutString, dontSendNotification);
} else {
label->setText(lastLowCutString, dontSendNotification);
}
val = value.getFloatValue();
return;
}
Array<int> chans = getActiveChannels();
GenericProcessor* p = (GenericProcessor*) getAudioProcessor();
// This needs to change, since there's not enough feedback about whether
// or not individual channel settings were altered:
for (int n = 0; n < chans.size(); n++)
{
p->setCurrentChannel(chans[n]);
if (label == highCutValue)
{
double minVal = fn->getLowCutValueForChannel(n);
if (requestedValue > minVal)
{
fn->setCurrentChannel(n);
fn->setParameter(1, requestedValue);
}
lastHighCutString = label->getText();
if (button->getRadioGroupId() == 1)
getAudioProcessor()->setParameter(0,val);
else
getAudioProcessor()->setParameter(1,val*1000.0f);
} else {
double maxVal = fn->getHighCutValueForChannel(n);
if (requestedValue < maxVal)
{
fn->setCurrentChannel(n);
fn->setParameter(0, requestedValue);
}
lastLowCutString = label->getText();
}
}
}
void FilterEditor::buttonEvent(Button* button)
{
//std::cout << button->getRadioGroupId() << " " << button->getName() << std::endl;
//if (!checkDrawerButton(button) && !checkChannelSelectors(button)) {
// String value = button->getName();
// float val;
// val = value.getFloatValue();
// Array<int> chans = getActiveChannels();
// GenericProcessor* p = (GenericProcessor*) getAudioProcessor();
// for (int n = 0; n < chans.size(); n++)
// {
// p->setCurrentChannel(chans[n]);
// if (button->getRadioGroupId() == 1)
// getAudioProcessor()->setParameter(0,val);
// else
// getAudioProcessor()->setParameter(1,val*1000.0f);
// }
//std::cout << button->getRadioGroupId() << " " << val << std::endl;
// }
}
\ No newline at end of file
}
void FilterEditor::saveEditorParameters(XmlElement* xml)
{
xml->setAttribute("Type", "FilterEditor");
XmlElement* textLabelValues = xml->createNewChildElement("VALUES");
textLabelValues->setAttribute("HighCut",lastHighCutString);
textLabelValues->setAttribute("LowCut",lastLowCutString);
}
void FilterEditor::loadEditorParameters(XmlElement* xml)
{
forEachXmlChildElement(*xml, xmlNode)
{
if (xmlNode->hasTagName("VALUES"))
{
highCutValue->setText(xmlNode->getStringAttribute("HighCut"),dontSendNotification);
lowCutValue->setText(xmlNode->getStringAttribute("LowCut"),dontSendNotification);
}
}
}
......@@ -38,15 +38,30 @@ class FilterViewport;
*/
class FilterEditor : public GenericEditor
class FilterEditor : public GenericEditor,
public Label::Listener
{
public:
FilterEditor(GenericProcessor* parentNode, bool useDefaultParameterEditors);
virtual ~FilterEditor();
void buttonEvent(Button* button);
void labelTextChanged(Label* label);
void saveEditorParameters(XmlElement* xml);
void loadEditorParameters(XmlElement* xml);
private:
String lastHighCutString;
String lastLowCutString;
ScopedPointer<Label> highCutLabel;
ScopedPointer<Label> lowCutLabel;
ScopedPointer<Label> highCutValue;
ScopedPointer<Label> lowCutValue;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FilterEditor);
};
......
......@@ -159,6 +159,16 @@ void FilterNode::updateSettings()
}
double FilterNode::getLowCutValueForChannel(int chan)
{
return lowCuts[chan];
}
double FilterNode::getHighCutValueForChannel(int chan)
{
return highCuts[chan];
}
void FilterNode::setFilterParameters(double lowCut, double highCut, int chan)
{
......@@ -265,6 +275,11 @@ void FilterNode::loadCustomChannelParametersFromXml(XmlElement* channelInfo, boo
{
highCuts.set(channelNum-1, subNode->getDoubleAttribute("highcut",6000.0f));
lowCuts.set(channelNum-1, subNode->getDoubleAttribute("lowcut",600.0f));
setFilterParameters(lowCuts[channelNum-1],
highCuts[channelNum-1],
channelNum-1);
}
}
}
......
......@@ -56,6 +56,9 @@ public:
return true;
}
double getLowCutValueForChannel(int chan);
double getHighCutValueForChannel(int chan);
void updateSettings();
void saveCustomChannelParametersToXml(XmlElement* channelInfo, int channelNumber, bool isEventChannel);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment