//========================================================================================= // save and recall presets //======================================================================================== void CabbagePluginAudioProcessorEditor::savePresetsFromParameters(File selectedFile, String mode) { XmlElement xml (getFilter()->getCsoundInputFile().getFileNameWithoutExtension()); for(int i=0; igetGUICtrlsSize(); i++) xml.setAttribute(getFilter()->getGUICtrls(i).getStringProp(CabbageIDs::channel), getFilter()->getGUICtrls(i).getNumProp(CabbageIDs::value)); for(int i=0; igetGUILayoutCtrlsSize(); i++) if (getFilter()->getGUILayoutCtrls(i).getStringProp(CabbageIDs::type) == String("texteditor")) xml.setAttribute(getFilter()->getGUILayoutCtrls(i).getStringProp(CabbageIDs::channel), dynamic_cast(layoutComps[i])->editor->getText()); File file(selectedFile.getFullPathName()); file.replaceWithText(xml.createDocument("")); } void CabbagePluginAudioProcessorEditor::restoreParametersFromPresets(XmlElement* xmlState) { ScopedPointer xml; xml = xmlState; // make sure that it's actually our type of XML object.. if (xml->hasTagName (getFilter()->getCsoundInputFile().getFileNameWithoutExtension())) { for(int i=0; igetNumParameters(); i++) { float newValue = (float)xml->getDoubleAttribute(getFilter()->getGUICtrls(i).getStringProp(CabbageIDs::channel)); #ifndef Cabbage_Build_Standalone float range = getFilter()->getGUICtrls(i).getNumProp("range"); float comboRange = getFilter()->getGUICtrls(i).getNumProp("comborange"); //Logger::writeToLog("inValue:"+String(newValue)); float min = getFilter()->getGUICtrls(i).getNumProp("min"); if(getFilter()->getGUICtrls(i).getStringProp(CabbageIDs::type)=="rslider") //Logger::writeToLog("slider"); if(getFilter()->getGUICtrls(i).getStringProp(CabbageIDs::type)=="xypad") newValue = (jmax(0.f, newValue)/range)+min; else if(getFilter()->getGUICtrls(i).getStringProp(CabbageIDs::type)=="combobox")//combo box value need to be rounded... newValue = (newValue/comboRange); else if(getFilter()->getGUICtrls(i).getStringProp(CabbageIDs::type)=="checkbox" || getFilter()->getGUICtrls(i).getStringProp(CabbageIDs::type)=="button") range=1; else newValue = (newValue/range)+min; //getFilter()->getGUICtrls(i)->setNumProp(CabbageIDs::value, newValue); #endif if(!getFilter()->getGUICtrls(i).getStringProp("filetype").contains("snaps")) { getFilter()->setParameterNotifyingHost(i, newValue); getFilter()->setParameter(i, newValue); getFilter()->getGUICtrls(i).setNumProp(CabbageIDs::value, newValue); } } for(int i=0; igetGUILayoutCtrlsSize(); i++) if (getFilter()->getGUILayoutCtrls(i).getStringProp(CabbageIDs::type) == String("texteditor")) { String newText = (String)xml->getStringAttribute(getFilter()->getGUILayoutCtrls(i).getStringProp(CabbageIDs::channel)); CabbageTextEditor *p = dynamic_cast(layoutComps[i]); p->editor->setText(newText, false); p->textEditorReturnKeyPressed(*(p->editor)); } } }