2 Copyright (C) 2008 Paul Davis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __export_format_dialog_h__
22 #define __export_format_dialog_h__
24 #include "ardour/types.h"
25 #include "ardour/export_format_manager.h"
26 #include "ardour/export_format_compatibility.h"
27 #include "ardour/export_formats.h"
29 #include "pbd/xml++.h"
30 #include "pbd/signals.h"
32 #include "ardour_dialog.h"
33 #include "audio_clock.h"
39 #include <gtkmm/adjustment.h>
40 #include <gtkmm/box.h>
41 #include <gtkmm/checkbutton.h>
42 #include <gtkmm/combobox.h>
43 #include <gtkmm/entry.h>
44 #include <gtkmm/label.h>
45 #include <gtkmm/liststore.h>
46 #include <gtkmm/radiobutton.h>
47 #include <gtkmm/spinbutton.h>
48 #include <gtkmm/table.h>
49 #include <gtkmm/treeview.h>
51 class ExportFormatDialog : public ArdourDialog, public PBD::ScopedConnectionList
55 typedef ARDOUR::WeakExportFormatCompatibilityPtr WeakCompatPtr;
56 typedef ARDOUR::WeakExportFormatPtr WeakFormatPtr;
57 typedef ARDOUR::ExportFormatManager::WeakQualityPtr WeakQualityPtr;
58 typedef ARDOUR::ExportFormatManager::WeakSampleRatePtr WeakSampleRatePtr;
59 typedef ARDOUR::ExportFormatManager::WeakSampleFormatPtr WeakSampleFormatPtr;
60 typedef ARDOUR::ExportFormatManager::WeakDitherTypePtr WeakDitherTypePtr;
62 typedef boost::shared_ptr<ARDOUR::ExportFormatSpecification> FormatPtr;
67 explicit ExportFormatDialog (FormatPtr format, bool new_dialog = false);
68 ~ExportFormatDialog ();
70 void set_session (ARDOUR::Session* s);
75 ARDOUR::ExportFormatManager manager;
77 XMLNode & original_state;
79 ARDOUR::AnyTime silence_start;
80 ARDOUR::AnyTime silence_end;
85 /*** Init functions ***/
87 void load_state (FormatPtr spec);
88 void init_format_table ();
89 void init_encoding_option_widgets ();
91 /*** Interactive selections ***/
93 /* These are connected to signals from GUI components, and should change element states */
95 void update_compatibility_selection (std::string const & path);
96 void update_quality_selection ();
97 void update_format_selection ();
98 void update_sample_rate_selection ();
99 void update_sample_format_selection ();
100 void update_dither_type_selection ();
102 template<typename ColsT>
103 void update_selection (Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols);
105 /* These are connected to signals from elements, and should only update the gui */
107 void change_compatibility_selection (bool select, WeakCompatPtr compat);
109 void change_quality_selection (bool select, WeakQualityPtr quality);
110 void change_format_selection (bool select, WeakFormatPtr format);
111 void change_sample_rate_selection (bool select, WeakSampleRatePtr rate);
112 void change_sample_format_selection (bool select, WeakSampleFormatPtr format);
113 void change_dither_type_selection (bool select, WeakDitherTypePtr type);
115 template<typename T, typename ColsT>
116 void change_selection (bool select, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols);
118 void change_quality_compatibility (bool compatibility, WeakQualityPtr quality);
119 void change_format_compatibility (bool compatibility, WeakFormatPtr format);
120 void change_sample_rate_compatibility (bool compatibility, WeakSampleRatePtr rate);
121 void change_sample_format_compatibility (bool compatibility, WeakSampleFormatPtr format);
122 void change_dither_type_compatibility (bool compatibility, WeakDitherTypePtr type);
124 template<typename T, typename ColsT>
125 void change_compatibility (bool compatibility, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, ColsT & cols,
126 std::string const & c_incompatible = "red", std::string const & c_compatible = "white");
128 void update_description();
130 uint32_t applying_changes_from_engine;
132 /*** Non-interactive selections ***/
136 void update_trim_start_selection ();
137 void update_trim_end_selection ();
139 void update_normalize_selection ();
140 void update_normalize_sensitivity ();
141 void update_silence_start_selection ();
142 void update_silence_end_selection ();
144 void update_clock (AudioClock & clock, ARDOUR::AnyTime const & time);
145 void update_time (ARDOUR::AnyTime & time, AudioClock const & clock);
147 void update_src_quality_selection ();
148 void update_tagging_selection ();
150 /*** Encoding options */
152 void change_encoding_options (ARDOUR::ExportFormatPtr ptr);
154 void empty_encoding_option_table ();
155 void remove_widget (Gtk::Widget & to_remove, Gtk::Container * remove_from);
157 void show_linear_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatLinear> ptr);
158 void show_ogg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ptr);
159 void show_flac_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFLAC> ptr);
160 void show_bwf_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatBWF> ptr);
162 void fill_sample_format_lists (boost::shared_ptr<ARDOUR::HasSampleFormat> ptr);
164 /*** GUI components ***/
166 /* Name, new and remove */
170 Gtk::Label name_label;
171 Gtk::Entry name_entry;
172 Gtk::Label name_generated_part;
176 Gtk::HBox normalize_hbox;
177 Gtk::CheckButton normalize_checkbox;
178 Gtk::RadioButton normalize_peak_rb;
179 Gtk::RadioButton normalize_loudness_rb;
180 Gtk::SpinButton normalize_dbfs_spinbutton;
181 Gtk::Adjustment normalize_dbfs_adjustment;
182 Gtk::SpinButton normalize_lufs_spinbutton;
183 Gtk::Adjustment normalize_lufs_adjustment;
184 Gtk::SpinButton normalize_dbtp_spinbutton;
185 Gtk::Adjustment normalize_dbtp_adjustment;
186 Gtk::Label normalize_dbfs_label;
187 Gtk::Label normalize_lufs_label;
188 Gtk::Label normalize_dbtp_label;
192 Gtk::Table silence_table;
194 Gtk::CheckButton trim_start_checkbox;
195 Gtk::CheckButton silence_start_checkbox;
196 AudioClock silence_start_clock;
198 Gtk::CheckButton trim_end_checkbox;
199 Gtk::CheckButton silence_end_checkbox;
200 AudioClock silence_end_clock;
202 /* Post-export hook */
204 Gtk::Label command_label;
205 Gtk::Entry command_entry;
209 struct CompatibilityCols : public Gtk::TreeModelColumnRecord
212 Gtk::TreeModelColumn<ARDOUR::ExportFormatCompatibilityPtr> ptr;
213 Gtk::TreeModelColumn<bool> selected;
214 Gtk::TreeModelColumn<std::string> label;
216 CompatibilityCols () { add(ptr); add(selected); add(label); }
218 CompatibilityCols compatibility_cols;
219 Glib::RefPtr<Gtk::ListStore> compatibility_list;
221 /* Hack to disallow row selection in compatibilities */
222 void prohibit_compatibility_selection ();
223 sigc::connection compatibility_select_connection;
225 struct QualityCols : public Gtk::TreeModelColumnRecord
228 Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::QualityPtr> ptr;
229 Gtk::TreeModelColumn<std::string> color;
230 Gtk::TreeModelColumn<std::string> label;
232 QualityCols () { add(ptr); add(color); add(label); }
234 QualityCols quality_cols;
235 Glib::RefPtr<Gtk::ListStore> quality_list;
237 struct FormatCols : public Gtk::TreeModelColumnRecord
240 Gtk::TreeModelColumn<ARDOUR::ExportFormatPtr> ptr;
241 Gtk::TreeModelColumn<std::string> color;
242 Gtk::TreeModelColumn<std::string> label;
244 FormatCols () { add(ptr); add(color); add(label); }
246 FormatCols format_cols;
247 Glib::RefPtr<Gtk::ListStore> format_list;
249 struct SampleRateCols : public Gtk::TreeModelColumnRecord
252 Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::SampleRatePtr> ptr;
253 Gtk::TreeModelColumn<std::string> color;
254 Gtk::TreeModelColumn<std::string> label;
256 SampleRateCols () { add(ptr); add(color); add(label); }
258 SampleRateCols sample_rate_cols;
259 Glib::RefPtr<Gtk::ListStore> sample_rate_list;
261 Gtk::Table format_table;
263 Gtk::Label compatibility_label;
264 Gtk::Label quality_label;
265 Gtk::Label format_label;
266 Gtk::Label sample_rate_label;
268 Gtk::TreeView compatibility_view;
269 Gtk::TreeView quality_view;
270 Gtk::TreeView format_view;
271 Gtk::TreeView sample_rate_view;
273 /* SRC quality combo */
275 struct SRCQualityCols : public Gtk::TreeModelColumnRecord
278 Gtk::TreeModelColumn<ARDOUR::ExportFormatBase::SRCQuality> id;
279 Gtk::TreeModelColumn<std::string> label;
281 SRCQualityCols () { add(id); add(label); }
283 SRCQualityCols src_quality_cols;
284 Glib::RefPtr<Gtk::ListStore> src_quality_list;
286 Gtk::Label src_quality_label;
287 Gtk::ComboBox src_quality_combo;
289 /* Common encoding option components */
291 Gtk::VBox encoding_options_vbox;
292 Gtk::Label encoding_options_label;
294 Gtk::Table encoding_options_table;
296 /* Other common components */
298 Gtk::Button * revert_button;
299 Gtk::Button * close_button;
301 /*** Changing encoding option stuff ***/
305 struct SampleFormatCols : public Gtk::TreeModelColumnRecord
308 Gtk::TreeModelColumn<ARDOUR::HasSampleFormat::SampleFormatPtr> ptr;
309 Gtk::TreeModelColumn<std::string> color;
310 Gtk::TreeModelColumn<std::string> label;
312 SampleFormatCols () { add(ptr); add(color); add(label); }
314 SampleFormatCols sample_format_cols;
315 Glib::RefPtr<Gtk::ListStore> sample_format_list;
317 struct DitherTypeCols : public Gtk::TreeModelColumnRecord
320 Gtk::TreeModelColumn<ARDOUR::HasSampleFormat::DitherTypePtr> ptr;
321 Gtk::TreeModelColumn<std::string> color;
322 Gtk::TreeModelColumn<std::string> label;
324 DitherTypeCols () { add(ptr); add (color); add(label); }
326 DitherTypeCols dither_type_cols;
327 Glib::RefPtr<Gtk::ListStore> dither_type_list;
329 Gtk::Label sample_format_label;
330 Gtk::Label dither_label;
332 Gtk::CheckButton with_cue;
333 Gtk::CheckButton with_toc;
334 Gtk::CheckButton with_mp4chaps;
336 Gtk::VBox cue_toc_vbox;
338 void update_with_toc ();
339 void update_with_cue ();
340 void update_with_mp4chaps();
341 void update_command ();
343 Gtk::TreeView sample_format_view;
344 Gtk::TreeView dither_type_view;
348 Gtk::CheckButton tag_checkbox;
352 #endif /* __export_format_dialog_h__ */