Result InitComponent::saveConfig() { AudioDeviceManager::AudioDeviceSetup audioDeviceSetup; deviceManager.getAudioDeviceSetup(audioDeviceSetup); ScopedPointer<XmlElement> audioDeviceState ( deviceManager.createStateXml() ); /* create audioDeviceState when no changes were applied to the device settings */ if (audioDeviceState == NULL) { audioDeviceState = createXmlSettings(deviceManager); } /* Check if audioDeviceState is complete */ String attrString; attrString = "audioDeviceRate"; if ( !audioDeviceState->hasAttribute( attrString ) ) audioDeviceState->setAttribute(attrString, audioDeviceSetup.sampleRate ); attrString = "audioDeviceBufferSize"; if ( !audioDeviceState->hasAttribute(attrString ) ) audioDeviceState->setAttribute( attrString, audioDeviceSetup.bufferSize ); attrString = "audioDeviceInChans"; if ( !audioDeviceState->hasAttribute( attrString ) ) audioDeviceState->setAttribute( attrString, audioDeviceSetup.inputChannels.toString(2, 1) ); attrString = "audioDeviceOutChans"; if ( !audioDeviceState->hasAttribute( attrString ) ) audioDeviceState->setAttribute( attrString, audioDeviceSetup.outputChannels.toString(2, 1) ); /* add more attributes to audioDeviceState */ XmlElement* mchaSettings = new XmlElement( "MCHASETTINGS" ); // this will be deleted automatically by the parent mchaSettings->setAttribute( "loggingLevel", mchaSettingsComponent->getLogLevel() ); mchaSettings->setAttribute( "memoryMode", mchaSettingsComponent->getMemoryMode() ); audioDeviceState->addChildElement(mchaSettings); File settingsFile( settingsFileName ); if (settingsFile == File::nonexistent) { return Result::fail( L"Settings file is absent" );; } DBG( L"mchaInit:\n Settings file created:\t" + settingsFile.getFileName() ); if ( !audioDeviceState->writeToFile ( settingsFile, String::empty ) ) { return Result::fail( L"Unable to save settings" ); } deviceManager.closeAudioDevice(); return Result::ok(); }
void FaustgenFactory::generateSVG() { // To be sure we get a correct SVG diagram... removeSVG(); // Prepare compile options std::string error; const char* argv[64]; memset(argv, 0, 64 * sizeof(char*)); jassert(fCompileOptions.size() < 64); auto opt = 0; for (opt = 0; opt < fCompileOptions.size(); opt++) { argv[opt] = (char*) fCompileOptions.getReference(opt).toRawUTF8(); } argv[opt++] = "-svg"; argv[opt++] = "-sn"; argv[opt++] = "-sd"; if (fDrawPath != File::nonexistent) { // Generate SVG file if (!generateAuxFilesFromString(getTMPName().toStdString(), fSourceCode.toStdString(), fCompileOptions.size() + 3, argv, error)) { //TODO: if there is an error here STOP LOG("Generate SVG error : " + error); } File svgFile = getSVGFile(); if (svgFile.exists()) { #if 0 File htmlFile(fDrawPath.getFullPathName() + "/" + getSVGFolderName() + "/index.html"); htmlFile.appendText(HTML_WRAPPER); #else XmlDocument svgXML(svgFile); ScopedPointer<XmlElement> mainElement (svgXML.getDocumentElement()); mainElement->setAttribute("width", "100%"); mainElement->setAttribute("height", "100%"); mainElement->writeToFile(svgFile, String::empty); #endif } } }
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); }