XmlElement* Track::DumpXml(int formatVersion) const { XmlElement* node = new XmlElement(tag::kTrack); node->setAttribute(tag::kFileFormat, formatVersion); node->setAttribute(tag::kName, fName); node->setAttribute(tag::kMuted, fMuted); node->setAttribute(tag::kSoloed, (this == fScumbler->GetSoloTrack())); //node->setAttribute("active", this->IsActive()); node->setAttribute(tag::kInputGain, fInputGain); node->setAttribute(tag::kPan, fPan); node->setAttribute(tag::kOutputVolume, fOutputVolume); node->setAttribute(tag::kChannels, static_cast<int>(this->GetEnabledChannels())); // store the pre-loop plugins XmlElement* preNode = node->createNewChildElement(tag::kPreBlock); preNode->addChildElement(fPreEffects->DumpXml(formatVersion)); // !!! store the loop info XmlElement* loopNode = node->createNewChildElement(tag::kLoop); loopNode->setAttribute(tag::kLoopDuration, fLoop->GetLoopDuration()); loopNode->setAttribute(tag::kLoopFeedback, fLoop->GetFeedback()); LoopProcessor::LoopInfo info; fLoop->GetLoopInfo(info); loopNode->setAttribute(tag::kLoopPosition, info.fLoopSample); XmlElement* postNode = node->createNewChildElement(tag::kPostBlock); postNode->addChildElement(fPostEffects->DumpXml(formatVersion)); return node; }
//------------------------------------------------------------------------------ void StupidWindow::saveKeyMappings() { int i; File mappingsFile = JuceHelperStuff::getAppDataFolder().getChildFile("AppMappings.xml"); XmlElement *mappingsXml = commandManager.getKeyMappings()->createXml(false); XmlElement rootXml("Pedalboard2AppMappings"); XmlElement *midiXml = new XmlElement("MidiMappings"); XmlElement *oscXml = new XmlElement("OscMappings"); MidiMappingManager *midiManager = mainPanel->getMidiMappingManager(); OscMappingManager *oscManager = mainPanel->getOscMappingManager(); //Add the KeyPress mappings. rootXml.addChildElement(mappingsXml); //Add the MIDI CC mappings. for(i=0;i<midiManager->getNumAppMappings();++i) midiXml->addChildElement(midiManager->getAppMapping(i)->getXml()); rootXml.addChildElement(midiXml); //Add the OSC mappings. for(i=0;i<oscManager->getNumAppMappings();++i) oscXml->addChildElement(oscManager->getAppMapping(i)->getXml()); rootXml.addChildElement(oscXml); //Save to the file. rootXml.writeToFile(mappingsFile, ""); }
//------------------------------------------------------------------------------ XmlElement *PluginField::getXml() const { int i; map<uint32, String>::const_iterator it2; multimap<uint32, Mapping *>::const_iterator it; XmlElement *retval = new XmlElement("Patch"); XmlElement *mappingsXml = new XmlElement("Mappings"); XmlElement *userNamesXml = new XmlElement("UserNames"); //Update saved window positions. for(i=0;i<getNumChildComponents();++i) { PluginComponent *plugin = dynamic_cast<PluginComponent *>(getChildComponent(i)); if(plugin) plugin->saveWindowState(); } //Set the patch tempo. retval->setAttribute(L"tempo", tempo); //Add FilterGraph. retval->addChildElement(signalPath->createXml(oscManager)); //Add Mappings. for(it=mappings.begin();it!=mappings.end();++it) mappingsXml->addChildElement(it->second->getXml()); retval->addChildElement(mappingsXml); //Add user names. for(it2=userNames.begin();it2!=userNames.end();++it2) { XmlElement *nameXml = new XmlElement("Name"); nameXml->setAttribute("id", (int)it2->first); nameXml->setAttribute("val", it2->second); userNamesXml->addChildElement(nameXml); } retval->addChildElement(userNamesXml); return retval; }
void OriginalRecording::writeXml() { String name = recordPath + "Continuous_Data"; if (experimentNumber > 1) { name += "_"; name += String(experimentNumber); } name += ".openephys"; File file(name); XmlDocument doc(file); ScopedPointer<XmlElement> xml = doc.getDocumentElement(); if ( !xml || ! xml->hasTagName("EXPERIMENT")) { xml = new XmlElement("EXPERIMENT"); xml->setAttribute("version",VERSION); xml->setAttribute("number",experimentNumber); xml->setAttribute("separatefiles",separateFiles); } XmlElement* rec = new XmlElement("RECORDING"); rec->setAttribute("number",recordingNumber); rec->setAttribute("length",(double)(timestamp-startTimestamp)); for (int i = 0; i < processorArray.size(); i++) { XmlElement* proc = new XmlElement("PROCESSOR"); proc->setAttribute("id",processorArray[i]->id); rec->setAttribute("samplerate",processorArray[i]->sampleRate); for (int j = 0; j < processorArray[i]->channels.size(); j++) { ChannelInfo* c = processorArray[i]->channels[j]; XmlElement* chan = new XmlElement("CHANNEL"); chan->setAttribute("name",c->name); chan->setAttribute("bitVolts",c->bitVolts); chan->setAttribute("filename",c->filename); chan->setAttribute("position",(double)(c->startPos)); //As long as the file doesnt exceed 2^53 bytes, this will have integer precission. Better than limiting to 32bits. proc->addChildElement(chan); } rec->addChildElement(proc); } xml->addChildElement(rec); xml->writeToFile(file,String::empty); }
//============================================================================== XmlElement* SerializeFactoryXml::serializeObjects (const String& rootName) { XmlElement* root = new XmlElement (rootName); for (int i = 0; i < objects.size(); ++i) { root->addChildElement (objects.getUnchecked(i)->serialize ()); } return root; }
XmlElement* CDPlayer::saveToXml(const File& /*projectDirectory*/, MyMultiDocumentPanel::LayoutMode layoutMode) const { XmlElement* element = new XmlElement("CDPlayer"); element->setAttribute("gain", getGain()); element->setAttribute("mute", m_mute); element->setAttribute("solo", m_solo); element->setAttribute("color", m_color.toString()); switch (layoutMode) { case MyMultiDocumentPanel::FloatingWindows: { Rectangle<int> parentBounds = getParentComponent()->getBounds(); XmlElement* boundsXml = new XmlElement("Bounds"); boundsXml->setAttribute("x", parentBounds.getX()); boundsXml->setAttribute("y", parentBounds.getY()); boundsXml->setAttribute("width", parentBounds.getWidth()); boundsXml->setAttribute("height", parentBounds.getHeight()); element->addChildElement(boundsXml); } break; case MyMultiDocumentPanel::MaximisedWindowsWithTabs: { XmlElement* mdiDocumentPosXml = new XmlElement("MdiDocumentPos"); mdiDocumentPosXml->addTextElement(getProperties()["mdiDocumentPos_"]); element->addChildElement(mdiDocumentPosXml); } break; } XmlElement* nameXml = new XmlElement("Name"); nameXml->addTextElement(Component::getName()); element->addChildElement(nameXml); XmlElement* driveXml = new XmlElement("Drive"); driveXml->addTextElement(m_availableCDsComboBox.getText()); element->addChildElement(driveXml); return element; }
XmlElement * Slice::toXml() { //for every slice, create an xmlelement and its id XmlElement* sliceXml = new XmlElement( "slice" ); sliceXml->setAttribute( "name", name ); sliceXml->setAttribute( "uniqueId", String( uniqueId ) ); sliceXml->setAttribute( "enable", enabled ); //then create an xmlelement to store its rects and points XmlElement* inputRectXml = new XmlElement( "inputRect" ); inputRectXml->setAttribute( "orientation", inputRectOrientation ); sliceXml->addChildElement( inputRectXml ); //loop through this rect's points for ( Point<float> point : inputRectPoints ) { //for every step, create an xmlelement and store the step nr XmlElement* pointXml = new XmlElement( "point" ); pointXml->setAttribute( "x", point.getX() ); pointXml->setAttribute( "y", point.getY() ); inputRectXml->addChildElement( pointXml ); } //then create an xmlelement to store its rects and points XmlElement* maskXml = new XmlElement( "mask" ); sliceXml->addChildElement( maskXml ); //loop through this mask's points for ( Point<float> point : maskPoints ) { //for every step, create an xmlelement and store the step nr XmlElement* pointXml = new XmlElement( "point" ); pointXml->setAttribute( "x", point.getX() ); pointXml->setAttribute( "y", point.getY() ); maskXml->addChildElement( pointXml ); } return sliceXml; }
void pspRandomSystem::saveXml(juce::File xmlFile){ XmlElement* mainElement = new XmlElement("RandomTrajectory"); XmlElement* params = new XmlElement("parameterValues"); params->setAttribute("numParticles", (int)particles->size()); params->setAttribute("lxMin", (double)lx.min); params->setAttribute("lxMax", (double)lx.max); params->setAttribute("lyMin", (double)ly.min); params->setAttribute("lyMax", (double)ly.max); params->setAttribute("lzMin", (double)lz.min); params->setAttribute("lzMax", (double)lz.max); mainElement->addChildElement(params); mainElement->writeToFile(xmlFile, ""); mainElement->deleteAllChildElements(); delete mainElement; }
//============================================================================== void Equalizer::addToXML (XmlElement* xml) { xml->setAttribute (T("prst"), Ppreset); { XmlElement* e = new XmlElement (T("fxpar")); for (int n = 0; n < 128; n++) { int par = getParameter (n); if (par == 0) continue; XmlElement* pe = new XmlElement (T("p") + String (n)); pe->setAttribute (T("v"), par); e->addChildElement (pe); } xml->addChildElement (e); } }
//============================================================================== XmlElement* ValueTree::SharedObject::createXml() const { XmlElement* xml = new XmlElement (type); int i; for (i = 0; i < properties.size(); ++i) { const Property* const p = properties.getUnchecked(i); jassert (! p->value.isObject()); // DynamicObjects can't be stored as XML! xml->setAttribute (p->name.name, p->value.toString()); } for (i = 0; i < children.size(); ++i) xml->addChildElement (children.getUnchecked(i)->createXml()); return xml; }
//============================================================================== XmlElement* ValueTree::SharedObject::createXml() const { XmlElement* xml = new XmlElement (type.toString()); int i; for (i = 0; i < properties.size(); ++i) { Identifier name (properties.getName(i)); const var& v = properties [name]; jassert (! v.isObject()); // DynamicObjects can't be stored as XML! xml->setAttribute (name.toString(), v.toString()); } for (i = 0; i < children.size(); ++i) xml->addChildElement (children.getUnchecked(i)->createXml()); return xml; }
void ComponentLayout::copySelectedToClipboard() { if (selected.getNumSelected() == 0) return; XmlElement clip (clipboardXmlTag); for (int i = 0; i < components.size(); ++i) { Component* const c = components.getUnchecked(i); if (selected.isSelected (c)) { if (ComponentTypeHandler* const type = ComponentTypeHandler::getHandlerFor (*c)) { XmlElement* const e = type->createXmlFor (c, this); clip.addChildElement (e); } } } SystemClipboard::copyTextToClipboard (clip.createDocument (String::empty, false, false)); }
XmlElement* JucerDocument::createXml() const { XmlElement* doc = new XmlElement (jucerCompXmlTag); doc->setAttribute ("documentType", getTypeName()); doc->setAttribute ("className", className); if (templateFile.trim().isNotEmpty()) doc->setAttribute ("template", templateFile); doc->setAttribute ("componentName", componentName); doc->setAttribute ("parentClasses", parentClasses); doc->setAttribute ("constructorParams", constructorParams); doc->setAttribute ("variableInitialisers", variableInitialisers); doc->setAttribute ("snapPixels", snapGridPixels); doc->setAttribute ("snapActive", snapActive); doc->setAttribute ("snapShown", snapShown); doc->setAttribute ("overlayOpacity", String (componentOverlayOpacity, 3)); doc->setAttribute ("fixedSize", fixedSize); doc->setAttribute ("initialWidth", initialWidth); doc->setAttribute ("initialHeight", initialHeight); if (activeExtraMethods.size() > 0) { XmlElement* extraMethods = new XmlElement ("METHODS"); doc->addChildElement (extraMethods); for (int i = 0; i < activeExtraMethods.size(); ++i) { XmlElement* e = new XmlElement ("METHOD"); extraMethods ->addChildElement (e); e->setAttribute ("name", activeExtraMethods[i]); } } return doc; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RegGrid2DExportXml::exportToXml(const RegGrid2D& regGrid, uint precision, XmlElement* parent) { if (!parent) { return; } XmlElement* xmlRegGrid = parent->addChildElement("RegularGrid2D"); CVF_ASSERT(xmlRegGrid); xmlRegGrid->setAttributeInt("GridPointCountI", regGrid.gridPointCountI()); xmlRegGrid->setAttributeInt("GridPointCountJ", regGrid.gridPointCountJ()); xmlRegGrid->setAttributeDouble("SpacingX", regGrid.spacing().x()); xmlRegGrid->setAttributeDouble("SpacingY", regGrid.spacing().y()); xmlRegGrid->setAttributeDouble("OffsetX", regGrid.offset().x()); xmlRegGrid->setAttributeDouble("OffsetY", regGrid.offset().y()); XmlElement* xmlElevations = xmlRegGrid->addChildElement("Elevations"); CVF_ASSERT(xmlElevations); String valueText; int j; for (j = 0; j < regGrid.gridPointCountJ(); j++) { int i; for (i = 0; i < regGrid.gridPointCountI(); i++) { valueText += String::number(regGrid.elevation(i, j), 'f', static_cast<int>(precision)); valueText += " "; } } xmlElevations->setValueText(valueText); }
XmlElement* PMixDocument::createNodeXml (AudioProcessorGraph::Node* const node) noexcept { AudioPluginInstance* plugin = dynamic_cast <AudioPluginInstance*> (node->getProcessor()); if (plugin == nullptr) { jassertfalse; return nullptr; } XmlElement* e = new XmlElement ("NODE"); e->setAttribute ("uid", (int) node->nodeID); e->setAttribute ("x", node->properties ["x"].toString()); e->setAttribute ("y", node->properties ["y"].toString()); e->setAttribute ("uiLastX", node->properties ["uiLastX"].toString()); e->setAttribute ("uiLastY", node->properties ["uiLastY"].toString()); e->setAttribute ("uiStatus", node->properties ["uiStatus"].toString()); PluginDescription pd; plugin->fillInPluginDescription (pd); if(!InternalPluginFormat::isInternalFormat(pd.name)) { e->setAttribute("colour", node->properties ["colour"].toString()); e->setAttribute ("iposx", node->properties ["iposx"].toString()); e->setAttribute ("iposy", node->properties ["iposy"].toString()); } e->addChildElement (pd.createXml()); XmlElement* state = new XmlElement ("STATE"); MemoryBlock m; node->getProcessor()->getStateInformation (m); state->addTextElement (m.toBase64Encoding()); e->addChildElement (state); if(!InternalPluginFormat::isInternalFormat(pd.name)) { XmlElement* params = new XmlElement ("PARAMS"); Array<var>* paramsArray = node->properties.getVarPointer("params")->getArray(); params->addTextElement("["); for(int i=0;i<paramsArray->size();i++) { var parameterIdx = paramsArray->getReference(i); params->addTextElement(parameterIdx.toString()); if(i != paramsArray->size()-1) params->addTextElement(", "); } params->addTextElement("]"); e->addChildElement(params); Array<var>* presetsArr = node->properties.getVarPointer("presets")->getArray(); for(int i=0;i<presetsArr->size();i++) { XmlElement* presetXML = new XmlElement ("PRESET"); DynamicObject* thePreset = presetsArr->getReference(i).getDynamicObject(); presetXML->setAttribute("name", thePreset->getProperty("name").toString()); presetXML->setAttribute("x", thePreset->getProperty("x").toString()); presetXML->setAttribute("y", thePreset->getProperty("y").toString()); presetXML->setAttribute("radius", thePreset->getProperty("radius").toString()); presetXML->setAttribute("hidden", thePreset->getProperty("hidden").toString()); //presetXML->setAttribute("distance", thePreset->getProperty("distance").toString()); presetXML->setAttribute("coeff", thePreset->getProperty("coeff").toString()); presetXML->setAttribute("uid", thePreset->getProperty("uid").toString()); Array<var>* paramsArray = thePreset->getProperty("state").getArray(); presetXML->addTextElement("["); for(int i=0;i<paramsArray->size();i++) { var parameterIdx = paramsArray->getReference(i); presetXML->addTextElement(parameterIdx.toString()); if(i != paramsArray->size()-1) presetXML->addTextElement(", "); } presetXML->addTextElement("]"); e->addChildElement(presetXML); } } return e; }
void toXml (XmlElement & node) { node.addChildElement (new XmlElement ("Media")); node.getChildElement (node.getNumChildElements()-1)->setAttribute ("path", filePath); node.getChildElement (node.getNumChildElements()-1)->setAttribute ("duration", duration); }