Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Source/Plugins/CAR/CAR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,43 @@ void CAR::setAffectedChannelState (int channel, bool newState)
m_affectedChannels.add (channel);
}

void CAR::saveCustomChannelParametersToXml(XmlElement* channelElement,
int channelNumber, InfoObjectCommon::InfoObjectType channelType)
{
if (channelType == InfoObjectCommon::DATA_CHANNEL)
{
XmlElement* groupState = channelElement->createNewChildElement("GROUPSTATE");

const Array<int>& referenceChannels = getReferenceChannels();
bool isReferenceChannel = referenceChannels.contains(channelNumber);
groupState->setAttribute("reference", isReferenceChannel);

const Array<int>& affectedChannels = getAffectedChannels();
bool isAffectedChannel = affectedChannels.contains(channelNumber);
groupState->setAttribute("affected", isAffectedChannel);
}
}

void CAR::loadCustomChannelParametersFromXml(XmlElement* channelElement,
InfoObjectCommon::InfoObjectType channelType)
{
if (channelType == InfoObjectCommon::DATA_CHANNEL)
{
int channelNumber = channelElement->getIntAttribute("number");

forEachXmlChildElementWithTagName(*channelElement, groupState, "GROUPSTATE")
{
if (groupState->hasAttribute("reference"))
{
bool isReferenceChannel = groupState->getBoolAttribute("reference");
setReferenceChannelState(channelNumber, isReferenceChannel);
}

if (groupState->hasAttribute("affected"))
{
bool isAffectedChannel = groupState->getBoolAttribute("affected");
setAffectedChannelState(channelNumber, isAffectedChannel);
}
}
}
}
5 changes: 5 additions & 0 deletions Source/Plugins/CAR/CAR.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ class CAR : public GenericProcessor
void setReferenceChannelState (int channel, bool newState);
void setAffectedChannelState (int channel, bool newState);

/** Saving/loading channel parameters */
void saveCustomChannelParametersToXml(XmlElement* channelElement,
int channelNumber, InfoObjectCommon::InfoObjectType channelType);
void loadCustomChannelParametersFromXml(XmlElement* channelElement,
InfoObjectCommon::InfoObjectType channelType);

private:
LinearSmoothedValueAtomic<float> m_gainLevel;
Expand Down
21 changes: 21 additions & 0 deletions Source/Plugins/CAR/CAREditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,24 @@ void CAREditor::sliderEvent (Slider* sliderWhichValueHasChanged)

processor->setGainLevel ( (float)sliderWhichValueHasChanged->getValue());
}

void CAREditor::saveCustomParameters(XmlElement* xml)
{
auto processor = static_cast<CAR*> (getProcessor());

xml->setAttribute("Type", "CAREditor");

XmlElement* paramValues = xml->createNewChildElement("VALUES");
paramValues->setAttribute("gainLevel", processor->getGainLevel());
}

void CAREditor::loadCustomParameters(XmlElement* xml)
{
auto processor = static_cast<CAR*> (getProcessor());

forEachXmlChildElementWithTagName(*xml, xmlNode, "VALUES")
{
double gain = xmlNode->getDoubleAttribute("gainLevel", m_gainSlider->getValue());
m_gainSlider->setValue(gain, sendNotificationSync);
}
}
3 changes: 3 additions & 0 deletions Source/Plugins/CAR/CAREditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class CAREditor : public GenericEditor
void sliderEvent (Slider* sliderWhichValueHasChanged) override;
void channelChanged (int channel, bool newState) override;

/** Saving/loading parameters */
void saveCustomParameters(XmlElement* xml) override;
void loadCustomParameters(XmlElement* xml) override;

private:
enum ChannelsType
Expand Down