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 class TrackTransport : Gtk.HBox {
22 public TrackBin track_bin;
24 public Gtk.Window window;
26 /*Gst.Element audio_src;
27 public void set_audio_src(Gst.Element src) {
31 Gst.Element audio_sink;
32 public Gst.Element get_audio_sink()
38 Gtk.Button btn_volume;
40 Gtk.Button btn_delete;
45 get { return _title; /*lbl_title.get_text();*/ }
46 set { _title = value; lbl_title.set_markup("<b>" + _title + "</b>"); }
49 Gtk.ToggleButton btn_active;
50 public void set_active_state(bool state) {
51 btn_active.set_active(state);
53 public bool get_active_state() {
54 return btn_active.get_active();
57 Gtk.ToggleButton btn_mute;
58 public void set_mute_state(bool state) {
59 btn_mute.set_active(state);
61 public bool get_mute_state() {
62 return btn_mute.get_active();
65 Gtk.Button btn_effects;
66 /*public void set_effects_state(bool state) {
67 btn_effects.set_active(state);
69 public bool get_effects_state() {
70 return btn_effects.get_active();
73 private double volume;
74 private double panorama;
77 public signal void active_toggled(bool state);
78 //public signal void mute_toggled(bool state);
79 //public signal void effects_toggled(bool state);
80 public signal void eq_updated(int band, double val);
81 public signal void delete_clicked();
82 public signal void volume_updated(double volume);
83 public signal void panorama_updated(double panorama);
85 public signal void dynamics_toggled(bool state);
86 public signal void dynamics_mode_updated(string val);
87 public signal void dynamics_characteristics_updated(string val);
88 public signal void dynamics_ratio_updated(double val);
89 public signal void dynamics_threshold_updated(double val);
91 public signal void echo_toggled(bool val);
92 public signal void echo_max_delay_updated(uint64 val);
93 public signal void echo_delay_updated(uint64 val);
94 public signal void echo_feedback_updated(double val);
95 public signal void echo_intensity_updated(double val);
97 private void show_volume_and_pan() {
98 VolumeAndPanPopUp dlg = new VolumeAndPanPopUp("Mixer Volume", this);
99 dlg.set_transient_for(this.window);
100 dlg.set_volume(this.volume);
101 dlg.set_panorama(this.panorama);
102 dlg.volume_updated.connect(volume_updated_callback);
103 dlg.panorama_updated.connect(panorama_updated_callback);
109 private void show_equalizer() {
110 EqualizerPopUp dlg = new EqualizerPopUp("Track EQ", this);
111 dlg.set_transient_for(this.window);
112 dlg.eq_updated.connect(eq_updated_callback);
118 private void show_effects() {
119 TrackEffectsPopUp dlg = new TrackEffectsPopUp.with_settings("Track Effects", this, SettingsStructures.EchoSettings(), SettingsStructures.DynamicsSettings());
120 dlg.set_transient_for(this.window);
121 // connect up callbacks dlg.blah.connect
122 dlg.echo_toggled.connect((val) => {this.echo_toggled(val);});
123 dlg.echo_max_delay_updated.connect((val) => {this.echo_max_delay_updated(val);});
124 dlg.echo_delay_updated.connect((val) => {this.echo_delay_updated(val);});
125 dlg.echo_feedback_updated.connect((val) => {this.echo_feedback_updated(val);});
126 dlg.echo_intensity_updated.connect((val) => {this.echo_intensity_updated(val);});
127 dlg.dynamics_toggled.connect((val) => {this.dynamics_toggled(val);});
128 dlg.dynamics_mode_updated.connect((val) => {this.dynamics_mode_updated(val);});
129 dlg.dynamics_characteristics_updated.connect((val) => {this.dynamics_characteristics_updated(val);});
130 dlg.dynamics_ratio_updated.connect((val) => {this.dynamics_ratio_updated(val);});
131 dlg.dynamics_threshold_updated.connect((val) => {this.dynamics_threshold_updated(val);});
137 public void playback_starting_callback(Object sender) {
138 btn_active.set_sensitive(false);
139 btn_delete.set_sensitive(false);
142 public void playback_ending_callback(Object sender) {
143 btn_active.set_sensitive(true);
144 btn_delete.set_sensitive(true);
147 public void recording_starting_callback(Object sender) {
148 btn_active.set_sensitive(false);
149 btn_delete.set_sensitive(false);
152 public void recording_ending_callback(Object sender) {
153 btn_active.set_sensitive(true);
154 btn_delete.set_sensitive(true);
157 private void eq_updated_callback(EqualizerPopUp sender, int band, double val) {
158 eq_updated(band, val);
161 private void mute_toggled(bool mute_on) {
162 volume_updated((mute_on) ? 0.0 : this.volume);
165 private void volume_updated_callback(VolumeAndPanPopUp sender, double volume)
167 this.volume = volume;
168 volume_updated(this.volume);
171 private void set_track_active(bool active) {
172 btn_mute.set_sensitive(active);
173 btn_volume.set_sensitive(active);
174 btn_eq.set_sensitive(active);
175 btn_effects.set_sensitive(active);
176 btn_active.set_image(new Gtk.Image.from_icon_name((active ? "general_presence_online" : "general_presence_invisible"), Gtk.IconSize.SMALL_TOOLBAR));
177 //track.active = active;
178 active_toggled(active);
181 private void panorama_updated_callback(VolumeAndPanPopUp sender, double panorama)
183 this.panorama = panorama;
184 panorama_updated(this.panorama);
191 lbl_title = new Gtk.Label("<b>New Track</b>");
192 lbl_title.use_markup = true;
193 lbl_title.set_alignment(0.1f, 0.4f);
194 lbl_title.set_ellipsize(Pango.EllipsizeMode.START);
195 this.pack_start(lbl_title, true, true, 2);
196 Gtk.HButtonBox buttons = new Gtk.HButtonBox();
197 btn_active = new Gtk.ToggleButton(); //.with_label("Active");
198 btn_mute.set_image(new Gtk.Image.from_icon_name("general_presence_online", Gtk.IconSize.SMALL_TOOLBAR));
199 btn_active.toggled.connect((b) => { set_track_active(b.get_active()); });
200 buttons.add(btn_active);
201 btn_mute = new Gtk.ToggleButton(); //.with_label("Mute");
202 btn_mute.set_image(new Gtk.Image.from_icon_name("statusarea_volume_mute", Gtk.IconSize.SMALL_TOOLBAR));
203 btn_mute.toggled.connect((b) => { mute_toggled(b.get_active()); });
204 buttons.add(btn_mute);
205 btn_volume = new Gtk.Button(); //.with_label("Vol");
206 btn_volume.set_image(new Gtk.Image.from_icon_name("statusarea_volumelevel4", Gtk.IconSize.SMALL_TOOLBAR));
207 btn_volume.clicked.connect((b) => { show_volume_and_pan(); });
208 buttons.add(btn_volume);
209 btn_eq = new Gtk.Button.with_label("EQ");
210 btn_eq.clicked.connect((b) => { show_equalizer(); });
212 btn_effects = new Gtk.Button.with_label("FX");
213 btn_effects.clicked.connect((b) => { show_effects(); });
214 buttons.add(btn_effects);
215 btn_delete = new Gtk.Button();
216 btn_delete.set_image(new Gtk.Image.from_icon_name("camera_delete", Gtk.IconSize.SMALL_TOOLBAR));
217 btn_delete.clicked.connect((b) => { delete_clicked(); });
218 buttons.add(btn_delete);
219 this.pack_start(buttons, false, false, 0);
223 private override void add(Gtk.Widget w) {
227 /* Hidden inherited methods */
228 private new void pack_start(Gtk.Widget w, bool expand, bool fill, uint padding = 0) {
229 base.pack_start(w, expand, fill, padding);
232 private new void pack_end(Gtk.Widget w, bool expand, bool fill, uint padding = 0) {
233 base.pack_start(w, expand, fill, padding);