1 /* Demo Recorder for MAEMO 5
2 * Copyright (C) 2010 Dru Moore <usr@dru-id.co.uk>
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2,
5 * or (at your option) any later version, as published by the Free
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 public struct EqualizerSettings {
21 public double[] bands;
24 public EqualizerSettings() {
26 this.bands = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
28 public EqualizerSettings.with_name(string val) {
30 this.bands = new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
32 public EqualizerSettings.with_values(string name, double[] bands) {
37 public string to_string() {
38 return "%s: bands:{%02f %02f %02f %02f %02f %02f %02f %02f %02f %02f}\n".printf(
52 public string serialize_to_string() {
53 return "EqualizerPreset:%s,%02f,%02f,%02f,%02f,%02f,%02f,%02f,%02f,%02f,%02f\n".printf(
54 name.replace(",", "\\,")
66 public string to_xml_string() {
67 return ("<EqualizerSettings>\n" +
68 "<name><![CDATA[%s]]></name>\n" +
69 "<band_0 type=\"double\">>%02f</band_0>\n" +
70 "<band_1 type=\"double\">>%02f</band_1>\n" +
71 "<band_2 type=\"double\">>%02f</band_2>\n" +
72 "<band_3 type=\"double\">>%02f</band_3>\n" +
73 "<band_4 type=\"double\">>%02f</band_4>\n" +
74 "<band_5 type=\"double\">>%02f</band_5>\n" +
75 "<band_6 type=\"double\">>%02f</band_6>\n" +
76 "<band_7 type=\"double\">>%02f</band_7>\n" +
77 "<band_8 type=\"double\">>%02f</band_8>\n" +
78 "<band_9 type=\"double\">>%02f</band_9>\n" +
79 "</EqualizerSettings>\n").printf(
93 public void from_xml_string(Xml.Node* node) {}
96 public bool deserialize_from_string(string data) {
98 // call parser to build an array of string of parts
99 string[] values = CdlParser.ParseLine(data);
100 // check length of array
101 if (13 == values.length) {
102 // parse parts into this
104 for (int i = 0; i < 10; ++i) {
105 bands[i] = values[i + 1].to_double();