From a55f38a1789d0918601f1f7aea48bbbcfd324781 Mon Sep 17 00:00:00 2001 From: Aaron Cuevas Lopez <aacuelo@teleco.upv.es> Date: Tue, 4 Nov 2014 21:15:08 +0100 Subject: [PATCH] Fix RHD source not saving channel naming and gains --- Source/Processors/SourceNode/SourceNode.cpp | 41 +++++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/Source/Processors/SourceNode/SourceNode.cpp b/Source/Processors/SourceNode/SourceNode.cpp index c6039f53f..089604015 100755 --- a/Source/Processors/SourceNode/SourceNode.cpp +++ b/Source/Processors/SourceNode/SourceNode.cpp @@ -505,12 +505,22 @@ void SourceNode::process(AudioSampleBuffer& buffer, void SourceNode::saveCustomParametersToXml(XmlElement* parentElement) { - // if (getName().equalsIgnoreCase("File Reader")) - // { - // XmlElement* childNode = parentElement->createNewChildElement("FILENAME"); - // FileReaderThread* thread = (FileReaderThread*) dataThread.get(); - // childNode->setAttribute("path", thread->getFile()); - // } + StringArray names; + Array<channelType> types; + Array<int> stream; + Array<int> originalChannelNumber; + Array<float> gains; + getChannelsInfo(names, types, stream, originalChannelNumber, gains); + XmlElement *channelInfo = parentElement->createNewChildElement("CHANNEL_INFO"); + for (int i = 0; i < names.size(); i++) + { + XmlElement* chan = channelInfo->createNewChildElement("CHANNEL"); + chan->setAttribute("name",names[i]); + chan->setAttribute("stream",stream[i]); + chan->setAttribute("number",originalChannelNumber[i]); + chan->setAttribute("type",(int)types[i]); + chan->setAttribute("gain",gains[i]); + } } @@ -523,12 +533,19 @@ void SourceNode::loadCustomParametersFromXml() forEachXmlChildElement(*parametersAsXml, xmlNode) { -// if (xmlNode->hasTagName("FILENAME")) -// { -// String filepath = xmlNode->getStringAttribute("path"); -// FileReaderEditor* fre = (FileReaderEditor*) getEditor(); -// fre->setFile(filepath); -// } + if (xmlNode->hasTagName("CHANNEL_INFO")) + { + forEachXmlChildElementWithTagName(*xmlNode,chan,"CHANNEL") + { + String name = chan->getStringAttribute("name"); + int stream = chan->getIntAttribute("stream"); + int number = chan->getIntAttribute("number"); + channelType type = static_cast<channelType>(chan->getIntAttribute("type")); + float gain = chan->getDoubleAttribute("gain"); + modifyChannelName(type,stream,number,name,false); + modifyChannelGain(stream,number,type,gain,false); + } + } } } -- GitLab