void VSTEffectDialog::OnSave(wxCommandEvent & evt) { int i = mProgram->GetCurrentSelection(); wxString fn; // Ask the user for the real name fn = FileSelector(_("Save VST Program As:"), FileNames::DataDir(), mProgram->GetValue() + wxT(".xml"), wxT("xml"), wxT("*.xml"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, this); // User canceled... if (fn.IsEmpty()) { return; } XMLFileWriter xmlFile; // Create/Open the file xmlFile.Open(fn, wxT("wb")); xmlFile.StartTag(wxT("vstprogrampersistence")); xmlFile.WriteAttr(wxT("version"), wxT("1")); i = mEffect->callDispatcher(effGetVendorVersion, 0, 0, NULL, 0.0); xmlFile.StartTag(wxT("effect")); xmlFile.WriteAttr(wxT("name"), mEffect->GetEffectIdentifier()); xmlFile.WriteAttr(wxT("version"), i); xmlFile.StartTag(wxT("program")); xmlFile.WriteAttr(wxT("name"), mProgram->GetValue()); long clen = 0; if (mAEffect->flags & effFlagsProgramChunks) { void *chunk = NULL; clen = mEffect->callDispatcher(effGetChunk, 1, 0, &chunk, 0.0); if (clen != 0) { xmlFile.StartTag(wxT("chunk")); xmlFile.WriteSubTree(b64encode(chunk, clen) + wxT('\n')); xmlFile.EndTag(wxT("chunk")); } } if (clen == 0) { for (i = 0; i < mAEffect->numParams; i++) { xmlFile.StartTag(wxT("param")); xmlFile.WriteAttr(wxT("index"), i); xmlFile.WriteAttr(wxT("name"), mEffect->GetString(effGetParamName, i)); xmlFile.WriteAttr(wxT("value"), wxString::Format(wxT("%f"), mEffect->callGetParameter(i))); xmlFile.EndTag(wxT("param")); } } xmlFile.EndTag(wxT("program")); xmlFile.EndTag(wxT("effect")); xmlFile.EndTag(wxT("vstprogrampersistence")); // Close the file xmlFile.Close(); }