--- /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 {
+
+protected struct Track {
+
+ public string uri;
+ public string label;
+ public bool active;
+ public bool mute;
+ public double volume;
+ public double pan;
+ public TrackBin bin;
+ //public TrackTransport transport;
+
+ public Track() {
+ this.uri = "";
+ this.label = "";
+ this.active = false;
+ this.mute = false;
+ this.volume = 0.0;
+ this.pan = 0.0;
+ this.bin = null;
+ //this.transport = null;
+ }
+
+ public Track.with_uri(string uri, string label, bool active, bool mute, double volume, double pan) {
+ this.uri = uri;
+ this.label = label;
+ this.active = active;
+ this.mute = mute;
+ this.volume = volume;
+ this.pan = pan;
+ this.bin = new TrackBin(label);
+ this.bin.set_uri(uri);
+ //this.transport = null;
+ }
+
+ //public void set_transport(TrackTransport transport) {
+ //this.transport = transport;
+ //this.transport.active_toggled.connect(active_toggled_callback);
+ //}
+
+ public SettingsStructures.TrackSettings get_settings_structure() {
+ SettingsStructures.TrackSettings ret = SettingsStructures.TrackSettings();
+ ret.uri = uri;
+ ret.name = label;
+ ret.notes = "";
+ ret.active = active;
+ ret.volume = SettingsStructures.VolumeSettings.with_values(volume, mute);
+ ret.panorama = SettingsStructures.PanoramaSettings.with_values(pan);
+ ret.dynamics = SettingsStructures.DynamicsSettings();
+ ret.echo = SettingsStructures.EchoSettings();
+ ret.equalizer = SettingsStructures.EqualizerSettings();
+ return ret;
+ }
+ public void from_settings_structure(SettingsStructures.TrackSettings settings) {
+ this.uri = settings.uri;
+ this.label = settings.name;
+ this.active = settings.active;
+ this.mute = settings.volume.mute;
+ this.volume = settings.volume.volume;
+ this.pan = settings.panorama.panorama;
+ this.bin = new TrackBin(this.label);
+ this.bin.set_uri(this.uri);
+ }
+
+ public static string tracklist_to_xml_string(List<Track?> tracklist) {
+ string ret = "<TrackList>\n";
+ for (int idx = 0; idx < tracklist.length(); ++idx) {
+ ret += ((Track)tracklist.nth_data(idx)).get_settings_structure().to_xml_string();
+ }
+ return ret + "</TrackList>\n";
+ }
+
+ public static void tracklist_from_xml_node_helper(Xml.Node* node, ref unowned List<Track?> tracks) {
+ // Loop over the passed node's children
+ for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {
+ // Spaces between tags are also nodes, discard them
+ if (iter->type != Xml.ElementType.ELEMENT_NODE) {
+ continue;
+ }
+ // Get the node's name
+ if ("TrackList" == iter->name) {
+ tracklist_from_xml_node(iter, ref tracks);
+ break;
+ }
+ }
+ }
+
+ public static void tracklist_from_xml_node(Xml.Node* node, ref unowned List<Track?> tracks) {
+ // Loop over the passed node's children
+ for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {
+ // Spaces between tags are also nodes, discard them
+ if (iter->type != Xml.ElementType.ELEMENT_NODE) {
+ continue;
+ }
+ // Get the node's name
+ string node_name = iter->name;
+ // Get the nodes type
+ //string? type = XmlHelpers.get_node_attribute(iter, "type");
+ if ("TrackSettings" == node_name)
+ {
+ SettingsStructures.TrackSettings track = SettingsStructures.TrackSettings();
+ track.from_xml_node(iter);
+ Track t = Track();
+ t.from_settings_structure(track);
+ tracks.append(t);
+ }
+ }
+ }
+
+}
+
+}