2 * Copyright (C) 2008-2013 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2009 David Robillard <d@drobilla.net>
4 * Copyright (C) 2011-2012 Sakari Bergen <sakari.bergen@beatwaves.net>
5 * Copyright (C) 2013-2014 Colin Fletcher <colin.m.fletcher@googlemail.com>
6 * Copyright (C) 2015-2018 Robin Gareus <robin@gareus.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef __export_format_dialog_h__
24 #define __export_format_dialog_h__
26 #include "ardour/types.h"
27 #include "ardour/export_format_manager.h"
28 #include "ardour/export_format_compatibility.h"
29 #include "ardour/export_formats.h"
31 #include "pbd/xml++.h"
32 #include "pbd/signals.h"
34 #include "ardour_dialog.h"
35 #include "audio_clock.h"
41 #include <gtkmm/adjustment.h>
42 #include <gtkmm/box.h>
43 #include <gtkmm/checkbutton.h>
44 #include <gtkmm/combobox.h>
45 #include <gtkmm/entry.h>
46 #include <gtkmm/label.h>
47 #include <gtkmm/liststore.h>
48 #include <gtkmm/radiobutton.h>
49 #include <gtkmm/spinbutton.h>
50 #include <gtkmm/table.h>
51 #include <gtkmm/treeview.h>
53 class ExportFormatDialog : public ArdourDialog, public PBD::ScopedConnectionList
57 typedef ARDOUR::WeakExportFormatCompatibilityPtr WeakCompatPtr;
58 typedef ARDOUR::WeakExportFormatPtr WeakFormatPtr;
59 typedef ARDOUR::ExportFormatManager::WeakQualityPtr WeakQualityPtr;
60 typedef ARDOUR::ExportFormatManager::WeakSampleRatePtr WeakSampleRatePtr;
61 typedef ARDOUR::ExportFormatManager::WeakSampleFormatPtr WeakSampleFormatPtr;
62 typedef ARDOUR::ExportFormatManager::WeakDitherTypePtr WeakDitherTypePtr;
64 typedef boost::shared_ptr<ARDOUR::ExportFormatSpecification> FormatPtr;
69 explicit ExportFormatDialog (FormatPtr format, bool new_dialog = false);
70 ~ExportFormatDialog ();
72 void set_session (ARDOUR::Session* s);
77 ARDOUR::ExportFormatManager manager;
79 XMLNode & original_state;
81 ARDOUR::AnyTime silence_start;
82 ARDOUR::AnyTime silence_end;
87 /*** Init functions ***/
89 void load_state (FormatPtr spec);
90 void init_format_table ();
91 void init_encoding_option_widgets ();
93 /*** Interactive selections ***/
95 /* These are connected to signals from GUI components, and should change element states */
97 void update_compatibility_selection (std::string const & path);
98 void update_quality_selection ();
99 void update_format_selection ();
100 void update_sample_rate_selection ();
101 void update_sample_format_selection ();
102 void update_dither_type_selection ();
104 template<typename ColsT>
105 void update_selection (Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols);
107 /* These are connected to signals from elements, and should only update the gui */
109 void change_compatibility_selection (bool select, WeakCompatPtr compat);
111 void change_quality_selection (bool select, WeakQualityPtr quality);
112 void change_format_selection (bool select, WeakFormatPtr format);
113 void change_sample_rate_selection (bool select, WeakSampleRatePtr rate);
114 void change_sample_format_selection (bool select, WeakSampleFormatPtr format);
115 void change_dither_type_selection (bool select, WeakDitherTypePtr type);
117 template<typename T, typename ColsT>
118 void change_selection (bool select, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols);
120 void change_quality_compatibility (bool compatibility, WeakQualityPtr quality);
121 void change_format_compatibility (bool compatibility, WeakFormatPtr format);
122 void change_sample_rate_compatibility (bool compatibility, WeakSampleRatePtr rate);
123 void change_sample_format_compatibility (bool compatibility, WeakSampleFormatPtr format);
124 void change_dither_type_compatibility (bool compatibility, WeakDitherTypePtr type);
126 template<typename T, typename ColsT>
127 void change_compatibility (bool compatibility, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, ColsT & cols,
128 std::string const & c_incompatible = "red", std::string const & c_compatible = "white");
130 void update_description();
132 uint32_t applying_changes_from_engine;
134 /*** Non-interactive selections ***/
138 void update_trim_start_selection ();
139 void update_trim_end_selection ();
141 void update_normalize_selection ();
142 void update_normalize_sensitivity ();
143 void update_silence_start_selection ();
144 void update_silence_end_selection ();
146 void update_clock (AudioClock & clock, ARDOUR::AnyTime const & time);
147 void update_time (ARDOUR::AnyTime & time, AudioClock const & clock);
149 void update_src_quality_selection ();
150 void update_codec_quality_selection ();
151 void update_tagging_selection ();
152 void set_codec_quality_selection ();
154 /*** Encoding options */
156 void change_encoding_options (ARDOUR::ExportFormatPtr ptr);
158 void empty_encoding_option_table ();
159 void remove_widget (Gtk::Widget & to_remove, Gtk::Container * remove_from);
161 void show_linear_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatLinear> ptr);
162 void show_ogg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ptr);
163 void show_flac_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFLAC> ptr);
164 void show_bwf_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatBWF> ptr);
165 void show_ffmpeg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFFMPEG> ptr);
167 void fill_sample_format_lists (boost::shared_ptr<ARDOUR::HasSampleFormat> ptr);
168 void fill_codec_quality_lists (boost::shared_ptr<ARDOUR::HasCodecQuality> ptr);
170 /*** GUI components ***/
172 /* Name, new and remove */
176 Gtk::Label name_label;
177 Gtk::Entry name_entry;
178 Gtk::Label name_generated_part;
182 Gtk::HBox normalize_hbox;
183 Gtk::CheckButton normalize_checkbox;
184 Gtk::RadioButton normalize_peak_rb;
185 Gtk::RadioButton normalize_loudness_rb;
186 Gtk::SpinButton normalize_dbfs_spinbutton;
187 Gtk::Adjustment normalize_dbfs_adjustment;
188 Gtk::SpinButton normalize_lufs_spinbutton;
189 Gtk::Adjustment normalize_lufs_adjustment;
190 Gtk::SpinButton normalize_dbtp_spinbutton;
191 Gtk::Adjustment normalize_dbtp_adjustment;
192 Gtk::Label normalize_dbfs_label;
193 Gtk::Label normalize_lufs_label;
194 Gtk::Label normalize_dbtp_label;
198 Gtk::Table silence_table;
200 Gtk::CheckButton trim_start_checkbox;
201 Gtk::CheckButton silence_start_checkbox;
202 AudioClock silence_start_clock;
204 Gtk::CheckButton trim_end_checkbox;
205 Gtk::CheckButton silence_end_checkbox;
206 AudioClock silence_end_clock;
208 /* Post-export hook */
210 Gtk::Label command_label;
211 Gtk::Entry command_entry;
215 struct CompatibilityCols : public Gtk::TreeModelColumnRecord
218 Gtk::TreeModelColumn<ARDOUR::ExportFormatCompatibilityPtr> ptr;
219 Gtk::TreeModelColumn<bool> selected;
220 Gtk::TreeModelColumn<std::string> label;
222 CompatibilityCols () { add(ptr); add(selected); add(label); }
224 CompatibilityCols compatibility_cols;
225 Glib::RefPtr<Gtk::ListStore> compatibility_list;
227 /* Hack to disallow row selection in compatibilities */
228 void prohibit_compatibility_selection ();
229 sigc::connection compatibility_select_connection;
231 struct QualityCols : public Gtk::TreeModelColumnRecord
234 Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::QualityPtr> ptr;
235 Gtk::TreeModelColumn<std::string> color;
236 Gtk::TreeModelColumn<std::string> label;
238 QualityCols () { add(ptr); add(color); add(label); }
240 QualityCols quality_cols;
241 Glib::RefPtr<Gtk::ListStore> quality_list;
243 struct FormatCols : public Gtk::TreeModelColumnRecord
246 Gtk::TreeModelColumn<ARDOUR::ExportFormatPtr> ptr;
247 Gtk::TreeModelColumn<std::string> color;
248 Gtk::TreeModelColumn<std::string> label;
250 FormatCols () { add(ptr); add(color); add(label); }
252 FormatCols format_cols;
253 Glib::RefPtr<Gtk::ListStore> format_list;
255 struct SampleRateCols : public Gtk::TreeModelColumnRecord
258 Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::SampleRatePtr> ptr;
259 Gtk::TreeModelColumn<std::string> color;
260 Gtk::TreeModelColumn<std::string> label;
262 SampleRateCols () { add(ptr); add(color); add(label); }
264 SampleRateCols sample_rate_cols;
265 Glib::RefPtr<Gtk::ListStore> sample_rate_list;
267 Gtk::Table format_table;
269 Gtk::Label compatibility_label;
270 Gtk::Label quality_label;
271 Gtk::Label format_label;
272 Gtk::Label sample_rate_label;
274 Gtk::TreeView compatibility_view;
275 Gtk::TreeView quality_view;
276 Gtk::TreeView format_view;
277 Gtk::TreeView sample_rate_view;
279 /* SRC quality combo */
281 struct SRCQualityCols : public Gtk::TreeModelColumnRecord
284 Gtk::TreeModelColumn<ARDOUR::ExportFormatBase::SRCQuality> id;
285 Gtk::TreeModelColumn<std::string> label;
287 SRCQualityCols () { add(id); add(label); }
289 SRCQualityCols src_quality_cols;
290 Glib::RefPtr<Gtk::ListStore> src_quality_list;
292 Gtk::Label src_quality_label;
293 Gtk::ComboBox src_quality_combo;
295 /* Common encoding option components */
297 Gtk::VBox encoding_options_vbox;
298 Gtk::Label encoding_options_label;
300 Gtk::Table encoding_options_table;
302 /* Other common components */
304 Gtk::Button * revert_button;
305 Gtk::Button * close_button;
307 /*** Changing encoding option stuff ***/
311 struct SampleFormatCols : public Gtk::TreeModelColumnRecord
314 Gtk::TreeModelColumn<ARDOUR::HasSampleFormat::SampleFormatPtr> ptr;
315 Gtk::TreeModelColumn<std::string> color;
316 Gtk::TreeModelColumn<std::string> label;
318 SampleFormatCols () { add(ptr); add(color); add(label); }
320 SampleFormatCols sample_format_cols;
321 Glib::RefPtr<Gtk::ListStore> sample_format_list;
323 struct DitherTypeCols : public Gtk::TreeModelColumnRecord
326 Gtk::TreeModelColumn<ARDOUR::HasSampleFormat::DitherTypePtr> ptr;
327 Gtk::TreeModelColumn<std::string> color;
328 Gtk::TreeModelColumn<std::string> label;
330 DitherTypeCols () { add(ptr); add (color); add(label); }
332 DitherTypeCols dither_type_cols;
333 Glib::RefPtr<Gtk::ListStore> dither_type_list;
335 Gtk::Label sample_format_label;
336 Gtk::Label dither_label;
338 Gtk::CheckButton with_cue;
339 Gtk::CheckButton with_toc;
340 Gtk::CheckButton with_mp4chaps;
342 Gtk::VBox cue_toc_vbox;
344 void update_with_toc ();
345 void update_with_cue ();
346 void update_with_mp4chaps();
347 void update_command ();
349 Gtk::TreeView sample_format_view;
350 Gtk::TreeView dither_type_view;
353 /* codec quality combo */
355 struct CodecQualityCols : public Gtk::TreeModelColumnRecord
358 Gtk::TreeModelColumn<int> quality;
359 Gtk::TreeModelColumn<std::string> label;
361 CodecQualityCols () { add(quality); add(label); }
363 CodecQualityCols codec_quality_cols;
364 Glib::RefPtr<Gtk::ListStore> codec_quality_list;
366 Gtk::ComboBox codec_quality_combo;
370 Gtk::CheckButton tag_checkbox;
374 #endif /* __export_format_dialog_h__ */