public void save() { EnamlData data = new EnamlData(); data.setStringValue("version", VERSION); data.setIntValue("global-settings.rack-window-height", rackHeight); data.setIntValue("global-settings.rack-window-pos.x", rackPosX); data.setIntValue("global-settings.rack-window-pos.y", rackPosY); data.setIntValue("global-settings.keyboard-window-pos.x", keyWndPosX); data.setIntValue("global-settings.keyboard-window-pos.y", keyWndPosY); data.saveToFile("Audimat.cfg"); }
//- saving ------------------------------------------------------------ public void saveToFile(String filename) { EnamlData rigData = new EnamlData(); rigData.setStringValue("version", Settings.VERSION); Dictionary <VSTPanel, String> plugList = new Dictionary <VSTPanel, string>(); int count = 1; foreach (VSTPanel panel in panels) { String plugName = "plugin-" + count.ToString().PadLeft(3, '0'); rigData.setStringValue("plugin-list." + plugName + ".path", panel.plugPath); rigData.setStringValue("plugin-list." + plugName + ".audio-out", panel.audioOut); rigData.setStringValue("plugin-list." + plugName + ".midi-in", ((panel.midiInDevice != null) ? panel.midiInDevice.devName : "no input")); plugList[panel] = plugName; count++; } count = 1; foreach (Patch patch in patches) { String patname = "patch-" + count.ToString().PadLeft(3, '0'); rigData.setStringValue("patch-list." + patname + ".name", patch.name); foreach (VSTPanel panel in patch.panels.Keys) { rigData.setIntValue("patch-list." + patname + "." + plugList[panel], patch.panels[panel]); } count++; } rigData.saveToFile(filename); hasChanged = false; }
//- writing expressions ------------------------------------- public void saveExpression(string path, ExprNode expr) { if (expr == null) { return; } switch (expr.type) { case OILType.IdentExpr: IdentExprNode idexpr = (IdentExprNode)expr; oilcan.setStringValue(path + ".type", "ident-expr"); oilcan.setStringValue(path + ".ref", idexpr.idsym.OILname); break; case OILType.IntConst: IntConstant iconst = (IntConstant)expr; oilcan.setStringValue(path + ".type", "int-const"); oilcan.setIntValue(path + ".val", iconst.value); break; case OILType.FloatConst: FloatConstant fconst = (FloatConstant)expr; oilcan.setStringValue(path + ".type", "float-const"); oilcan.setFloatValue(path + ".val", fconst.value); break; case OILType.ArithmeticExpr: ArithmeticExprNode arithexpr = (ArithmeticExprNode)expr; oilcan.setStringValue(path + ".type", "arith-expr"); saveExpression(path + ".lhs", arithexpr.lhs); oilcan.setStringValue(path + ".op", ArithmeticExprNode.opname[(int)arithexpr.op]); saveExpression(path + ".rhs", arithexpr.rhs); break; case OILType.CompareExpr: ComparisonExprNode compexpr = (ComparisonExprNode)expr; oilcan.setStringValue(path + ".type", "comp-expr"); saveExpression(path + ".lhs", compexpr.lhs); oilcan.setStringValue(path + ".op", ComparisonExprNode.opname[(int)compexpr.op]); saveExpression(path + ".rhs", compexpr.rhs); break; case OILType.AssignExpr: AssignExprNode assignexpr = (AssignExprNode)expr; oilcan.setStringValue(path + ".type", "assign-expr"); saveExpression(path + ".lhs", assignexpr.lhs); oilcan.setStringValue(path + ".op", AssignExprNode.opname[(int)assignexpr.op]); saveExpression(path + ".rhs", assignexpr.rhs); break; default: break; } }