/* Demo Recorder for MAEMO 5 * Copyright (C) 2010 Dru Moore * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * or (at your option) any later version, as published by the Free * Software Foundation * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ namespace IdWorks { public struct EqualizerSettings { public double[] bands; public string name; public EqualizerSettings() { this.name = ""; this.bands = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; } public EqualizerSettings.with_name(string val) { this.name = val; this.bands = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; } public EqualizerSettings.with_values(string name, double[] bands) { this.name = name; this.bands = bands; } public string to_string() { return "%s: bands:{%02f %02f %02f %02f %02f %02f %02f %02f %02f %02f}\n".printf( name , bands[0] , bands[1] , bands[2] , bands[3] , bands[4] , bands[5] , bands[6] , bands[7] , bands[8] , bands[9]); } public string serialize_to_string() { return "EqualizerPreset:%s,%02f,%02f,%02f,%02f,%02f,%02f,%02f,%02f,%02f,%02f\n".printf( name.replace(",", "\\,") , bands[0] , bands[1] , bands[2] , bands[3] , bands[4] , bands[5] , bands[6] , bands[7] , bands[8] , bands[9]); } public string to_xml_string() { return ("\n" + "\n" + ">%02f\n" + ">%02f\n" + ">%02f\n" + ">%02f\n" + ">%02f\n" + ">%02f\n" + ">%02f\n" + ">%02f\n" + ">%02f\n" + ">%02f\n" + "\n").printf( base.name, base.bands[0], base.bands[1], base.bands[2], base.bands[3], base.bands[4], base.bands[5], base.bands[6], base.bands[7], base.bands[8], base.bands[9] ); } public void from_xml_string(Xml.Node* node) {} public bool deserialize_from_string(string data) { bool good = false; // call parser to build an array of string of parts string[] values = CdlParser.ParseLine(data); // check length of array if (13 == values.length) { // parse parts into this name = values[0]; for (int i = 0; i < 10; ++i) { bands[i] = values[i + 1].to_double(); } good = true; } return good; } } }