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 protected struct Track {
29 //public TrackTransport transport;
39 //this.transport = null;
42 public Track.with_uri(string uri, string label, bool active, bool mute, double volume, double pan) {
49 this.bin = new TrackBin(label);
50 this.bin.set_uri(uri);
51 //this.transport = null;
54 //public void set_transport(TrackTransport transport) {
55 //this.transport = transport;
56 //this.transport.active_toggled.connect(active_toggled_callback);
59 public SettingsStructures.TrackSettings get_settings_structure() {
60 SettingsStructures.TrackSettings ret = SettingsStructures.TrackSettings();
65 ret.volume = SettingsStructures.VolumeSettings.with_values(volume, mute);
66 ret.panorama = SettingsStructures.PanoramaSettings.with_values(pan);
67 ret.dynamics = SettingsStructures.DynamicsSettings();
68 ret.echo = SettingsStructures.EchoSettings();
69 ret.equalizer = SettingsStructures.EqualizerSettings();
72 public void from_settings_structure(SettingsStructures.TrackSettings settings) {
73 this.uri = settings.uri;
74 this.label = settings.name;
75 this.active = settings.active;
76 this.mute = settings.volume.mute;
77 this.volume = settings.volume.volume;
78 this.pan = settings.panorama.panorama;
79 this.bin = new TrackBin(this.label);
80 this.bin.set_uri(this.uri);
83 public static string tracklist_to_xml_string(List<Track?> tracklist) {
84 string ret = "<TrackList>\n";
85 for (int idx = 0; idx < tracklist.length(); ++idx) {
86 ret += ((Track)tracklist.nth_data(idx)).get_settings_structure().to_xml_string();
88 return ret + "</TrackList>\n";
91 public static void tracklist_from_xml_node_helper(Xml.Node* node, ref unowned List<Track?> tracks) {
92 // Loop over the passed node's children
93 for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {
94 // Spaces between tags are also nodes, discard them
95 if (iter->type != Xml.ElementType.ELEMENT_NODE) {
98 // Get the node's name
99 if ("TrackList" == iter->name) {
100 tracklist_from_xml_node(iter, ref tracks);
106 public static void tracklist_from_xml_node(Xml.Node* node, ref unowned List<Track?> tracks) {
107 // Loop over the passed node's children
108 for (Xml.Node* iter = node->children; iter != null; iter = iter->next) {
109 // Spaces between tags are also nodes, discard them
110 if (iter->type != Xml.ElementType.ELEMENT_NODE) {
113 // Get the node's name
114 string node_name = iter->name;
115 // Get the nodes type
116 //string? type = XmlHelpers.get_node_attribute(iter, "type");
117 if ("TrackSettings" == node_name)
119 SettingsStructures.TrackSettings track = SettingsStructures.TrackSettings();
120 track.from_xml_node(iter);
122 t.from_settings_structure(track);