//-------------------------------------------------------------- void Device::saveXML(string dir) { ofxXmlSettings settings; settings.addTag("device"); settings.setAttribute("device", "id", m_id,0); settings.pushTag("device"); settings.addTag("soundInput"); settings.pushTag("soundInput"); settings.addValue("volMax", getSoundInputVolumeMax()); settings.addValue("volHistoryNb", getSoundInputVolHistorySize()); settings.addValue("volHistoryTh", getSoundInputVolHistoryTh()); settings.popTag(); settings.addValue("enableStandby", getEnableStandbyMode() ? 1 : 0); settings.addValue("timeStandby", m_timeStandby); settings.addValue("nbLEDsStandby", getNbLEDsStandby()); settings.addValue("speedStandby", getSpeedStandby()); settings.addTag("surface"); settings.setAttribute("surface", "id", "main", 0); settings.pushTag("surface"); settings.addValue("xNorm", m_pointSurface.x); settings.addValue("yNorm", m_pointSurface.y); settings.popTag(); settings.popTag(); settings.saveFile( getPathXML(dir) ); }
//-------------------------------------------------------------- void Device::loadXML(string dir) { ofxXmlSettings settings; string pathFile = getPathXML(dir); if ( settings.loadFile(pathFile) ) { string surfaceId = settings.getAttribute("device:surface", "id", "main"); float xNorm = settings.getValue("device:surface:xNorm", 0.5f); float yNorm = settings.getValue("device:surface:yNorm", 0.5f); printf("Device, loaded %s\n", pathFile.c_str()); printf(" - volMax=%.3f\n", settings.getValue("device:soundInput:volMax",0.05f)); printf(" - volHistoryNb=%d\n", settings.getValue("device:soundInput:volHistoryNb",400)); printf(" - volHistoryTh=%.3f\n", settings.getValue("device:soundInput:volHistoryTh",0.1f)); printf(" - enableStandby=%s\n", settings.getValue("device:enableStandby",1) ? "true" : "false"); printf(" - timeStandby=%.2f\n", settings.getValue("device:timeStandby",10.0f) ); printf(" - nbLEDsStandby=%d\n", settings.getValue("device:nbLEDsStandby",50) ); printf(" - speedStandby=%d\n", settings.getValue("device:speedStandby",70.0) ); printf(" - surface=%s (xNorm=%.2f,yNorm=%.2f)\n",surfaceId.c_str(), xNorm, yNorm); setSoundInputVolumeMax( settings.getValue("device:soundInput:volMax",0.05f) ); setSoundInputVolHistorySize( settings.getValue("device:soundInput:volHistoryNb",400) ); setSoundInputVolHistoryTh( settings.getValue("device:soundInput:volHistoryTh",0.1f) ); setEnableStandbyMode( settings.getValue("device:enableStandby",1)==1 ? true : false ); setTimeStandby( settings.getValue("device:timeStandby",10.0f) ); setNbLEDsStandby( settings.getValue("device:nbLEDsStandby", 50) ); setSpeedStandbyOSC( settings.getValue("device:speedStandby", 70.0) ); setPointSurface(xNorm, yNorm); } else{ printf("Device, error loading %s\n", pathFile.c_str()); } }
//-------------------------------------------------------------- void Device::loadXML(string dir) { OFAPPLOG->begin("Device::loadXML()"); ofxXmlSettings settings; string pathFile = getPathXML(dir); if ( settings.loadFile(pathFile) ) { OFAPPLOG->println("Device, loaded "+pathFile); loadXMLData(settings); } else{ OFAPPLOG->println("Device, error loading "+pathFile); } OFAPPLOG->end(); }
//-------------------------------------------------------------- void Device::saveXML(string dir) { ofxXmlSettings settings; settings.addTag("device"); settings.setAttribute("device", "id", m_id,0); settings.pushTag("device"); settings.addTag("soundInput"); settings.pushTag("soundInput"); settings.addValue("useRawVol", getSoundInputUseRawVolume()); settings.addValue("mute", getSoundInputMute()); settings.addValue("volMax", getSoundInputVolumeMax()); settings.addValue("volMaxMin", getSoundInputVolumeMaxMin()); settings.addValue("volMaxMax", getSoundInputVolumeMaxMax()); settings.addValue("volHistoryNb", getSoundInputVolHistorySize()); settings.addValue("volHistoryTh", getSoundInputVolHistoryTh()); settings.addValue("pitchMin", getSoundInputPitchMin()); settings.addValue("pitchMax", getSoundInputPitchMax()); settings.popTag(); settings.addTag("soundOutput"); settings.pushTag("soundOutput"); for (int i=0; i<m_listSpeakerIds.size(); i++) settings.addValue("speaker", m_listSpeakerIds[i]); settings.popTag(); settings.addTag("color"); settings.pushTag("color"); settings.addValue("enable", m_isEnableColor ? 1:0); settings.addTag("colorMode_manual_hsb"); settings.pushTag("colorMode_manual_hsb"); settings.addValue("hue", m_colorHsv[0]); settings.addValue("saturation", m_colorHsv[1]); settings.popTag(); settings.popTag(); settings.addTag("packets"); settings.pushTag("packets"); settings.addValue("invert", m_isInvertPacketsVolume ? 1 : 0); settings.addValue("reverse", m_isReverseDirPackets ? 1 : 0); settings.popTag(); settings.addTag("ping"); settings.pushTag("ping"); settings.addValue("value", m_volHistoryPingTh); settings.popTag(); settings.addValue("enableGenerative", isGenerative() ? 1 : 0); settings.addTag("bpm"); settings.pushTag("bpm"); settings.addValue("enable", m_bpmEnable ? 1 : 0); settings.addValue("value", m_bpm); settings.popTag(); settings.addValue("enableStandby", getEnableStandbyMode() ? 1 : 0); settings.addValue("timeStandby", m_timeStandby); settings.addValue("sampleVolStandby", getSampleVolStandby()); settings.addValue("enableStandby", getEnableStandup() ? 1 : 0); /* settings.addValue("enableStandup", getEnableStandup() ? 1 : 0); settings.addValue("volStandup", getStandupVol()); */ settings.addTag("surface"); settings.setAttribute("surface", "id", "main", 0); settings.pushTag("surface"); settings.addValue("xNorm", m_pointSurface.x); settings.addValue("yNorm", m_pointSurface.y); settings.popTag(); settings.popTag(); settings.saveFile( getPathXML(dir) ); }