--- /dev/null
+/* Demo Recorder for MAEMO 5
+* Copyright (C) 2010 Dru Moore <usr@dru-id.co.uk>
+* 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 ("<EqualizerSettings>\n" +
+ "<name><![CDATA[%s]]></name>\n" +
+ "<band_0 type=\"double\">>%02f</band_0>\n" +
+ "<band_1 type=\"double\">>%02f</band_1>\n" +
+ "<band_2 type=\"double\">>%02f</band_2>\n" +
+ "<band_3 type=\"double\">>%02f</band_3>\n" +
+ "<band_4 type=\"double\">>%02f</band_4>\n" +
+ "<band_5 type=\"double\">>%02f</band_5>\n" +
+ "<band_6 type=\"double\">>%02f</band_6>\n" +
+ "<band_7 type=\"double\">>%02f</band_7>\n" +
+ "<band_8 type=\"double\">>%02f</band_8>\n" +
+ "<band_9 type=\"double\">>%02f</band_9>\n" +
+ "</EqualizerSettings>\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;
+ }
+
+}
+
+}