2 * Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
4 * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
5 * Copyright (C) 2009-2013 Sakari Bergen <sakari.bergen@beatwaves.net>
6 * Copyright (C) 2013-2014 Colin Fletcher <colin.m.fletcher@googlemail.com>
7 * Copyright (C) 2016-2019 Robin Gareus <robin@gareus.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include <gtkmm/stock.h>
26 #include "ardour/session.h"
27 #include "ardour/export_format_specification.h"
29 #include "widgets/tooltips.h"
31 #include "export_format_dialog.h"
32 #include "gui_thread.h"
36 using namespace ARDOUR;
38 ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
39 ArdourDialog (new_dialog ? _("New Export Format Profile") : _("Edit Export Format Profile")),
42 original_state (format->get_state()),
44 applying_changes_from_engine (0),
46 name_label (_("Label: "), Gtk::ALIGN_LEFT),
47 name_generated_part ("", Gtk::ALIGN_LEFT),
49 normalize_checkbox (_("Normalize:")),
50 normalize_peak_rb (_("Peak")),
51 normalize_loudness_rb (_("Loudness")),
52 normalize_dbfs_adjustment ( 0.00, -90.00, 0.00, 0.1, 0.2),
53 normalize_lufs_adjustment (-23.0, -90.00, 0.00, 0.1, 1.0),
54 normalize_dbtp_adjustment ( -1.0, -90.00, 0.00, 0.1, 0.2),
56 normalize_dbfs_label (_("dBFS"), Gtk::ALIGN_LEFT),
57 normalize_lufs_label (_("LUFS"), Gtk::ALIGN_LEFT),
58 normalize_dbtp_label (_("dBTP"), Gtk::ALIGN_LEFT),
61 trim_start_checkbox (_("Trim silence at start")),
62 silence_start_checkbox (_("Add silence at start:")),
63 silence_start_clock ("silence_start", true, "", true, false, true),
65 trim_end_checkbox (_("Trim silence at end")),
66 silence_end_checkbox (_("Add silence at end:")),
67 silence_end_clock ("silence_end", true, "", true, false, true),
69 command_label(_("Command to run post-export\n(%f=file path, %d=directory, %b=basename, see tooltip for more):"), Gtk::ALIGN_LEFT),
72 compatibility_label (_("Compatibility"), Gtk::ALIGN_LEFT),
73 quality_label (_("Quality"), Gtk::ALIGN_LEFT),
74 format_label (_("File format"), Gtk::ALIGN_LEFT),
75 sample_rate_label (_("Sample rate"), Gtk::ALIGN_LEFT),
76 src_quality_label (_("Sample rate conversion quality:"), Gtk::ALIGN_RIGHT),
78 encoding_options_label ("", Gtk::ALIGN_LEFT),
80 /* Changing encoding options from here on */
82 sample_format_label (_("Sample Format"), Gtk::ALIGN_LEFT),
83 dither_label (_("Dithering"), Gtk::ALIGN_LEFT),
85 with_cue (_("Create CUE file for disk-at-once CD/DVD creation")),
86 with_toc (_("Create TOC file for disk-at-once CD/DVD creation")),
87 with_mp4chaps (_("Create chapter mark file for MP4 chapter marks")),
89 tag_checkbox (_("Tag file with session's metadata"))
92 /* Pack containers in dialog */
94 get_vbox()->pack_start (silence_table, false, false, 6);
95 get_vbox()->pack_start (format_table, false, false, 6);
96 get_vbox()->pack_start (encoding_options_vbox, false, false, 0);
97 get_vbox()->pack_start (cue_toc_vbox, false, false, 0);
98 get_vbox()->pack_start (name_hbox, false, false, 6);
100 /* Name, new and remove */
102 name_hbox.pack_start (name_label, false, false, 0);
103 name_hbox.pack_start (name_entry, false, false, 0);
104 name_hbox.pack_start (name_generated_part, true, true, 0);
105 name_entry.set_width_chars(20);
106 update_description();
107 manager.DescriptionChanged.connect(
108 *this, invalidator (*this),
109 boost::bind (&ExportFormatDialog::update_description, this), gui_context());
113 Gtk::RadioButtonGroup normalize_group = normalize_loudness_rb.get_group();
114 normalize_peak_rb.set_group (normalize_group);
116 normalize_hbox.pack_start (normalize_checkbox, false, false, 2);
117 normalize_hbox.pack_start (normalize_peak_rb, false, false, 0);
118 normalize_hbox.pack_start (normalize_dbfs_spinbutton, false, false, 2);
119 normalize_hbox.pack_start (normalize_dbfs_label, false, false, 0);
121 normalize_hbox.pack_start (*Gtk::manage (new Gtk::Label ("")), false, false, 6); // separator
123 normalize_hbox.pack_start (normalize_loudness_rb, false, false, 0);
124 normalize_hbox.pack_start (normalize_lufs_spinbutton, false, false, 2);
125 normalize_hbox.pack_start (normalize_lufs_label, false, false, 0);
126 normalize_hbox.pack_start (*Gtk::manage (new Gtk::Label (_("\u2227"))), false, false, 4);
127 normalize_hbox.pack_start (normalize_dbtp_spinbutton, false, false, 2);
128 normalize_hbox.pack_start (normalize_dbtp_label, false, false, 0);
130 ArdourWidgets::set_tooltip (normalize_loudness_rb,
131 _("Normalize to EBU-R128 LUFS target loudness without exceeding the given true-peak limit. EBU-R128 normalization is only available for mono and stereo targets, true-peak works for any channel layout."));
133 normalize_dbfs_spinbutton.configure (normalize_dbfs_adjustment, 0.1, 2);
134 normalize_lufs_spinbutton.configure (normalize_lufs_adjustment, 0.1, 2);
135 normalize_dbtp_spinbutton.configure (normalize_dbtp_adjustment, 0.1, 2);
139 silence_table.set_row_spacings (6);
140 silence_table.set_col_spacings (12);
142 silence_table.attach (normalize_hbox, 0, 3, 0, 1);
144 silence_table.attach (trim_start_checkbox, 0, 1, 1, 2);
145 silence_table.attach (silence_start_checkbox, 1, 2, 1, 2);
146 silence_table.attach (silence_start_clock, 2, 3, 1, 2);
148 silence_table.attach (trim_end_checkbox, 0, 1, 2, 3);
149 silence_table.attach (silence_end_checkbox, 1, 2, 2, 3);
150 silence_table.attach (silence_end_clock, 2, 3, 2, 3);
152 /* Post-export hook script */
154 get_vbox()->pack_start (command_label, false, false);
155 get_vbox()->pack_start (command_entry, false, false);
157 ArdourWidgets::set_tooltip (command_entry,
160 "%b File's base-name\n"
162 "%d File's directory\n"
163 "%f File's full absolute path\n"
173 "%L Total track count\n"
188 /* Encoding options */
190 init_encoding_option_widgets();
192 encoding_options_table.set_spacings (1);
194 encoding_options_vbox.pack_start (encoding_options_label, false, false, 0);
195 encoding_options_vbox.pack_start (encoding_options_table, false, false, 12);
197 Pango::AttrList bold;
198 Pango::Attribute b = Pango::Attribute::create_attr_weight (Pango::WEIGHT_BOLD);
200 encoding_options_label.set_attributes (bold);
204 codec_quality_list = Gtk::ListStore::create (codec_quality_cols);
205 codec_quality_combo.set_model (codec_quality_list);
206 codec_quality_combo.pack_start (codec_quality_cols.label);
207 //codec_quality_combo.set_active (0);
211 revert_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
212 revert_button->signal_clicked().connect (sigc::mem_fun(*this, &ExportFormatDialog::revert));
213 close_button = add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_APPLY);
214 close_button->set_sensitive (false);
215 close_button->signal_clicked().connect (sigc::mem_fun (*this, &ExportFormatDialog::end_dialog));
216 manager.CompleteChanged.connect (*this, invalidator (*this), boost::bind (&Gtk::Button::set_sensitive, close_button, _1), gui_context());
218 with_cue.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_cue));
219 with_toc.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_toc));
220 with_mp4chaps.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_mp4chaps));
221 command_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_command));
223 cue_toc_vbox.pack_start (with_cue, false, false);
224 cue_toc_vbox.pack_start (with_toc, false, false);
225 cue_toc_vbox.pack_start (with_mp4chaps, false, false);
227 /* Load state before hooking up the rest of the signals */
233 name_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_name));
235 /* Normalize, silence and src_quality signals */
237 trim_start_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_trim_start_selection));
238 trim_end_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_trim_end_selection));
240 normalize_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
241 normalize_peak_rb.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
242 normalize_loudness_rb.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
243 normalize_dbfs_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
244 normalize_lufs_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
245 normalize_dbtp_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
247 silence_start_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
248 silence_start_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
250 silence_end_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
251 silence_end_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
253 src_quality_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_src_quality_selection));
254 codec_quality_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_codec_quality_selection));
256 /* Format table signals */
258 Gtk::CellRendererToggle *toggle = dynamic_cast<Gtk::CellRendererToggle *>(compatibility_view.get_column_cell_renderer (0));
259 toggle->signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_compatibility_selection));
260 compatibility_select_connection = compatibility_view.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::prohibit_compatibility_selection));
262 quality_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_quality_selection));
263 format_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_format_selection));
264 sample_rate_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_sample_rate_selection));
266 /* Encoding option signals */
268 sample_format_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_sample_format_selection));
269 dither_type_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_dither_type_selection));
271 tag_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_tagging_selection));
276 update_normalize_sensitivity ();
279 ExportFormatDialog::~ExportFormatDialog ()
285 ExportFormatDialog::revert ()
287 ++applying_changes_from_engine;
289 format->set_state (original_state);
292 --applying_changes_from_engine;
296 ExportFormatDialog::set_session (ARDOUR::Session* s)
298 SessionHandlePtr::set_session (s);
299 silence_start_clock.set_session (s);
300 silence_end_clock.set_session (s);
306 update_clock (silence_start_clock, silence_start);
307 update_clock (silence_end_clock, silence_end);
309 /* Select native samplerate if no selection is yet made */
311 if (sample_rate_view.get_selection()->count_selected_rows() == 0) {
312 Gtk::ListStore::Children::iterator it;
313 for (it = sample_rate_list->children().begin(); it != sample_rate_list->children().end(); ++it) {
314 if ((samplecnt_t) (*it)->get_value (sample_rate_cols.ptr)->rate == _session->nominal_sample_rate()) {
315 sample_rate_view.get_selection()->select (it);
323 ExportFormatDialog::load_state (FormatPtr spec)
325 name_entry.set_text (spec->name());
327 normalize_checkbox.set_active (spec->normalize());
328 normalize_peak_rb.set_active (!spec->normalize_loudness());
329 normalize_loudness_rb.set_active (spec->normalize_loudness());
330 normalize_dbfs_spinbutton.set_value (spec->normalize_dbfs());
331 normalize_lufs_spinbutton.set_value (spec->normalize_lufs());
332 normalize_dbtp_spinbutton.set_value (spec->normalize_dbtp());
334 trim_start_checkbox.set_active (spec->trim_beginning());
335 silence_start = spec->silence_beginning_time();
336 silence_start_checkbox.set_active (spec->silence_beginning_time().not_zero());
338 trim_end_checkbox.set_active (spec->trim_end());
339 silence_end = spec->silence_end_time();
340 silence_end_checkbox.set_active (spec->silence_end_time().not_zero());
342 with_cue.set_active (spec->with_cue());
343 with_toc.set_active (spec->with_toc());
344 with_mp4chaps.set_active (spec->with_mp4chaps());
346 for (Gtk::ListStore::Children::iterator it = src_quality_list->children().begin(); it != src_quality_list->children().end(); ++it) {
347 if (it->get_value (src_quality_cols.id) == spec->src_quality()) {
348 src_quality_combo.set_active (it);
353 for (Gtk::ListStore::Children::iterator it = codec_quality_list->children().begin(); it != codec_quality_list->children().end(); ++it) {
354 if (it->get_value (codec_quality_cols.quality) == spec->codec_quality()) {
355 codec_quality_combo.set_active (it);
360 for (Gtk::ListStore::Children::iterator it = format_list->children().begin(); it != format_list->children().end(); ++it) {
361 boost::shared_ptr<ARDOUR::ExportFormat> format_in_list = it->get_value (format_cols.ptr);
362 if (format_in_list->get_format_id() == spec->format_id() &&
363 // BWF has the same format id with wav, so we need to check this.
364 format_in_list->has_broadcast_info() == spec->has_broadcast_info()) {
366 format_in_list->set_selected (true);
371 for (Gtk::ListStore::Children::iterator it = sample_rate_list->children().begin(); it != sample_rate_list->children().end(); ++it) {
372 if (it->get_value (sample_rate_cols.ptr)->rate == spec->sample_rate()) {
373 it->get_value (sample_rate_cols.ptr)->set_selected (true);
378 if (spec->sample_format()) {
379 for (Gtk::ListStore::Children::iterator it = sample_format_list->children().begin(); it != sample_format_list->children().end(); ++it) {
380 if (it->get_value (sample_format_cols.ptr)->format == spec->sample_format()) {
381 it->get_value (sample_format_cols.ptr)->set_selected (true);
386 for (Gtk::ListStore::Children::iterator it = dither_type_list->children().begin(); it != dither_type_list->children().end(); ++it) {
387 if (it->get_value (dither_type_cols.ptr)->type == spec->dither_type()) {
388 it->get_value (dither_type_cols.ptr)->set_selected (true);
394 update_normalize_sensitivity ();
395 tag_checkbox.set_active (spec->tag());
396 command_entry.set_text (spec->command());
400 ExportFormatDialog::init_format_table ()
403 format_table.set_spacings (1);
405 format_table.attach (compatibility_label, 0, 1, 0, 1);
406 format_table.attach (quality_label, 1, 2, 0, 1);
407 format_table.attach (format_label, 2, 3, 0, 1);
408 format_table.attach (sample_rate_label, 3, 4, 0, 1);
410 format_table.attach (compatibility_view, 0, 1, 1, 2);
411 format_table.attach (quality_view, 1, 2, 1, 2);
412 format_table.attach (format_view, 2, 3, 1, 2);
413 format_table.attach (sample_rate_view, 3, 4, 1, 2);
415 format_table.attach (src_quality_label, 0, 3, 2, 3);
416 format_table.attach (src_quality_combo, 3, 4, 2, 3);
418 compatibility_view.set_headers_visible (false);
419 quality_view.set_headers_visible (false);
420 format_view.set_headers_visible (false);
421 sample_rate_view.set_headers_visible (false);
423 /*** Table entries ***/
425 Gtk::TreeModel::iterator iter;
426 Gtk::TreeModel::Row row;
428 /* Compatibilities */
430 compatibility_list = Gtk::ListStore::create (compatibility_cols);
431 compatibility_view.set_model (compatibility_list);
433 ExportFormatManager::CompatList const & compat_list = manager.get_compatibilities();
435 for (ExportFormatManager::CompatList::const_iterator it = compat_list.begin(); it != compat_list.end(); ++it) {
436 iter = compatibility_list->append();
439 row[compatibility_cols.ptr] = *it;
440 row[compatibility_cols.selected] = false;
441 row[compatibility_cols.label] = (*it)->name();
443 WeakCompatPtr ptr (*it);
444 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_compatibility_selection, this, _1, ptr), gui_context());
447 compatibility_view.append_column_editable ("", compatibility_cols.selected);
449 Gtk::CellRendererText* text_renderer = Gtk::manage (new Gtk::CellRendererText);
450 text_renderer->property_editable() = false;
452 Gtk::TreeView::Column* column = compatibility_view.get_column (0);
453 column->pack_start (*text_renderer);
454 column->add_attribute (text_renderer->property_text(), compatibility_cols.label);
458 quality_list = Gtk::ListStore::create (quality_cols);
459 quality_view.set_model (quality_list);
461 ExportFormatManager::QualityList const & qualities = manager.get_qualities ();
463 for (ExportFormatManager::QualityList::const_iterator it = qualities.begin(); it != qualities.end(); ++it) {
464 iter = quality_list->append();
467 row[quality_cols.ptr] = *it;
468 row[quality_cols.color] = "white";
469 row[quality_cols.label] = (*it)->name();
471 WeakQualityPtr ptr (*it);
472 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_quality_selection, this, _1, ptr), gui_context());
473 (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_quality_compatibility, this, _1, ptr), gui_context());
476 quality_view.append_column ("", quality_cols.label);
480 format_list = Gtk::ListStore::create (format_cols);
481 format_view.set_model (format_list);
483 ExportFormatManager::FormatList const & formats = manager.get_formats ();
485 for (ExportFormatManager::FormatList::const_iterator it = formats.begin(); it != formats.end(); ++it) {
486 iter = format_list->append();
489 row[format_cols.ptr] = *it;
490 row[format_cols.color] = "white";
491 row[format_cols.label] = (*it)->name();
493 WeakFormatPtr ptr (*it);
494 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_format_selection, this, _1, ptr), gui_context());
495 (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_format_compatibility, this, _1, ptr), gui_context());
497 /* Encoding options */
499 boost::shared_ptr<HasSampleFormat> hsf;
501 if ((hsf = boost::dynamic_pointer_cast<HasSampleFormat> (*it))) {
502 hsf->SampleFormatSelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_format_selection, this, _1, _2), gui_context());
503 hsf->SampleFormatCompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_format_compatibility, this, _1, _2), gui_context());
505 hsf->DitherTypeSelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_dither_type_selection, this, _1, _2), gui_context());
506 hsf->DitherTypeCompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_dither_type_compatibility, this, _1, _2), gui_context());
510 format_view.append_column ("", format_cols.label);
514 sample_rate_list = Gtk::ListStore::create (sample_rate_cols);
515 sample_rate_view.set_model (sample_rate_list);
517 ExportFormatManager::SampleRateList const & rates = manager.get_sample_rates ();
519 for (ExportFormatManager::SampleRateList::const_iterator it = rates.begin(); it != rates.end(); ++it) {
520 iter = sample_rate_list->append();
523 row[sample_rate_cols.ptr] = *it;
524 row[sample_rate_cols.color] = "white";
525 row[sample_rate_cols.label] = (*it)->name();
527 WeakSampleRatePtr ptr (*it);
528 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_rate_selection, this, _1, ptr), gui_context());
529 (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_rate_compatibility, this, _1, ptr), gui_context());
532 sample_rate_view.append_column ("", sample_rate_cols.label);
534 /* Color rendering */
536 Gtk::TreeViewColumn * label_col;
537 Gtk::CellRendererText * renderer;
539 label_col = quality_view.get_column(0);
540 renderer = dynamic_cast<Gtk::CellRendererText*> (quality_view.get_column_cell_renderer (0));
541 label_col->add_attribute(renderer->property_foreground(), quality_cols.color);
543 label_col = format_view.get_column(0);
544 renderer = dynamic_cast<Gtk::CellRendererText*> (format_view.get_column_cell_renderer (0));
545 label_col->add_attribute(renderer->property_foreground(), format_cols.color);
547 label_col = sample_rate_view.get_column(0);
548 renderer = dynamic_cast<Gtk::CellRendererText*> (sample_rate_view.get_column_cell_renderer (0));
549 label_col->add_attribute(renderer->property_foreground(), sample_rate_cols.color);
553 src_quality_list = Gtk::ListStore::create (src_quality_cols);
554 src_quality_combo.set_model (src_quality_list);
556 iter = src_quality_list->append();
558 row[src_quality_cols.id] = ExportFormatBase::SRC_SincBest;
559 row[src_quality_cols.label] = _("Best (sinc)");
561 iter = src_quality_list->append();
563 row[src_quality_cols.id] = ExportFormatBase::SRC_SincMedium;
564 row[src_quality_cols.label] = _("Medium (sinc)");
566 iter = src_quality_list->append();
568 row[src_quality_cols.id] = ExportFormatBase::SRC_SincFast;
569 row[src_quality_cols.label] = _("Fast (sinc)");
571 iter = src_quality_list->append();
573 row[src_quality_cols.id] = ExportFormatBase::SRC_Linear;
574 row[src_quality_cols.label] = _("Linear");
576 iter = src_quality_list->append();
578 row[src_quality_cols.id] = ExportFormatBase::SRC_ZeroOrderHold;
579 row[src_quality_cols.label] = _("Zero order hold");
581 src_quality_combo.pack_start (src_quality_cols.label);
582 src_quality_combo.set_active (0);
586 ExportFormatDialog::init_encoding_option_widgets ()
588 Gtk::TreeViewColumn * label_col;
589 Gtk::CellRendererText * renderer;
591 sample_format_list = Gtk::ListStore::create (sample_format_cols);
592 sample_format_view.set_model (sample_format_list);
593 sample_format_view.set_headers_visible (false);
594 sample_format_view.append_column ("", sample_format_cols.label);
595 label_col = sample_format_view.get_column(0);
596 renderer = dynamic_cast<Gtk::CellRendererText*> (sample_format_view.get_column_cell_renderer (0));
597 label_col->add_attribute(renderer->property_foreground(), sample_format_cols.color);
599 dither_type_list = Gtk::ListStore::create (dither_type_cols);
600 dither_type_view.set_model (dither_type_list);
601 dither_type_view.set_headers_visible (false);
602 dither_type_view.append_column ("", dither_type_cols.label);
603 label_col = dither_type_view.get_column(0);
604 renderer = dynamic_cast<Gtk::CellRendererText*> (dither_type_view.get_column_cell_renderer (0));
605 label_col->add_attribute(renderer->property_foreground(), dither_type_cols.color);
610 ExportFormatDialog::update_compatibility_selection (std::string const & path)
613 Gtk::TreeModel::iterator iter = compatibility_view.get_model ()->get_iter (path);
614 ExportFormatCompatibilityPtr ptr = iter->get_value (compatibility_cols.ptr);
615 bool state = iter->get_value (compatibility_cols.selected);
617 iter->set_value (compatibility_cols.selected, state);
618 ptr->set_selected (state);
623 ExportFormatDialog::update_quality_selection ()
625 update_selection<QualityCols> (quality_list, quality_view, quality_cols);
629 ExportFormatDialog::update_format_selection ()
631 update_selection<FormatCols> (format_list, format_view, format_cols);
635 ExportFormatDialog::update_sample_rate_selection ()
637 update_selection<SampleRateCols> (sample_rate_list, sample_rate_view, sample_rate_cols);
641 ExportFormatDialog::update_sample_format_selection ()
643 update_selection<SampleFormatCols> (sample_format_list, sample_format_view, sample_format_cols);
647 ExportFormatDialog::update_dither_type_selection ()
649 update_selection<DitherTypeCols> (dither_type_list, dither_type_view, dither_type_cols);
652 template<typename ColsT>
654 ExportFormatDialog::update_selection (Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols)
656 if (applying_changes_from_engine) {
660 Gtk::ListStore::Children::iterator it;
661 Glib::RefPtr<Gtk::TreeSelection> selection = view.get_selection();
663 for (it = list->children().begin(); it != list->children().end(); ++it) {
664 bool selected = selection->is_selected (it);
665 it->get_value (cols.ptr)->set_selected (selected);
668 set_codec_quality_selection ();
672 ExportFormatDialog::change_compatibility_selection (bool select, WeakCompatPtr compat)
674 ++applying_changes_from_engine;
676 ExportFormatCompatibilityPtr ptr = compat.lock();
678 for (Gtk::ListStore::Children::iterator it = compatibility_list->children().begin(); it != compatibility_list->children().end(); ++it) {
679 if (it->get_value (compatibility_cols.ptr) == ptr) {
680 it->set_value (compatibility_cols.selected, select);
685 --applying_changes_from_engine;
689 ExportFormatDialog::change_quality_selection (bool select, WeakQualityPtr quality)
691 change_selection<ExportFormatManager::QualityState, QualityCols> (select, quality, quality_list, quality_view, quality_cols);
695 ExportFormatDialog::change_format_selection (bool select, WeakFormatPtr format)
697 change_selection<ExportFormat, FormatCols> (select, format, format_list, format_view, format_cols);
699 ExportFormatPtr ptr = format.lock();
702 change_encoding_options (ptr);
707 ExportFormatDialog::change_sample_rate_selection (bool select, WeakSampleRatePtr rate)
709 change_selection<ExportFormatManager::SampleRateState, SampleRateCols> (select, rate, sample_rate_list, sample_rate_view, sample_rate_cols);
712 ExportFormatManager::SampleRatePtr ptr = rate.lock();
713 if (ptr && _session) {
714 src_quality_combo.set_sensitive ((uint32_t) ptr->rate != _session->sample_rate());
720 ExportFormatDialog::change_sample_format_selection (bool select, WeakSampleFormatPtr format)
722 change_selection<HasSampleFormat::SampleFormatState, SampleFormatCols> (select, format, sample_format_list, sample_format_view, sample_format_cols);
726 ExportFormatDialog::change_dither_type_selection (bool select, WeakDitherTypePtr type)
728 change_selection<HasSampleFormat::DitherTypeState, DitherTypeCols> (select, type, dither_type_list, dither_type_view, dither_type_cols);
731 template<typename T, typename ColsT>
733 ExportFormatDialog::change_selection (bool select, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols)
735 ++applying_changes_from_engine;
737 boost::shared_ptr<T> ptr = w_ptr.lock();
739 Gtk::ListStore::Children::iterator it;
740 Glib::RefPtr<Gtk::TreeSelection> selection;
742 selection = view.get_selection();
745 selection->unselect_all();
747 for (it = list->children().begin(); it != list->children().end(); ++it) {
748 if (it->get_value (cols.ptr) == ptr) {
750 selection->select (it);
752 selection->unselect (it);
759 --applying_changes_from_engine;
763 ExportFormatDialog::change_quality_compatibility (bool compatibility, WeakQualityPtr quality)
765 change_compatibility<ExportFormatManager::QualityState, QualityCols> (compatibility, quality, quality_list, quality_cols);
769 ExportFormatDialog::change_format_compatibility (bool compatibility, WeakFormatPtr format)
771 change_compatibility<ExportFormat, FormatCols> (compatibility, format, format_list, format_cols);
775 ExportFormatDialog::change_sample_rate_compatibility (bool compatibility, WeakSampleRatePtr rate)
777 change_compatibility<ExportFormatManager::SampleRateState, SampleRateCols> (compatibility, rate, sample_rate_list, sample_rate_cols);
781 ExportFormatDialog::change_sample_format_compatibility (bool compatibility, WeakSampleFormatPtr format)
783 change_compatibility<HasSampleFormat::SampleFormatState, SampleFormatCols> (compatibility, format, sample_format_list, sample_format_cols);
787 ExportFormatDialog::change_dither_type_compatibility (bool compatibility, WeakDitherTypePtr type)
789 change_compatibility<HasSampleFormat::DitherTypeState, DitherTypeCols> (compatibility, type, dither_type_list, dither_type_cols, "red");
792 template<typename T, typename ColsT>
794 ExportFormatDialog::change_compatibility (bool compatibility, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, ColsT & cols,
795 std::string const & c_incompatible, std::string const & c_compatible)
797 boost::shared_ptr<T> ptr = w_ptr.lock();
799 Gtk::ListStore::Children::iterator it;
800 for (it = list->children().begin(); it != list->children().end(); ++it) {
801 if (it->get_value (cols.ptr) == ptr) {
802 it->set_value (cols.color, compatibility ? c_compatible : c_incompatible);
809 ExportFormatDialog::update_with_cue ()
811 manager.select_with_cue (with_cue.get_active());
815 ExportFormatDialog::update_with_toc ()
817 manager.select_with_toc (with_toc.get_active());
821 ExportFormatDialog::update_with_mp4chaps ()
823 manager.select_with_mp4chaps (with_mp4chaps.get_active());
827 ExportFormatDialog::update_command ()
829 manager.set_command (command_entry.get_text());
833 ExportFormatDialog::update_description()
835 std::string text = ": " + format->description(false);
836 name_generated_part.set_text(text);
840 ExportFormatDialog::update_name ()
842 manager.set_name (name_entry.get_text());
846 ExportFormatDialog::update_trim_start_selection ()
848 manager.select_trim_beginning (trim_start_checkbox.get_active());
852 ExportFormatDialog::update_trim_end_selection ()
854 manager.select_trim_end (trim_end_checkbox.get_active());
858 ExportFormatDialog::update_normalize_sensitivity ()
860 bool en = normalize_checkbox.get_active();
861 bool loudness = normalize_loudness_rb.get_active();
862 normalize_dbfs_spinbutton.set_sensitive (!loudness && en);
863 normalize_lufs_spinbutton.set_sensitive (loudness && en);
864 normalize_dbtp_spinbutton.set_sensitive (loudness && en);
868 ExportFormatDialog::update_normalize_selection ()
870 manager.select_normalize (normalize_checkbox.get_active());
871 manager.select_normalize_loudness (normalize_loudness_rb.get_active());
872 manager.select_normalize_dbfs (normalize_dbfs_spinbutton.get_value ());
873 manager.select_normalize_lufs (normalize_lufs_spinbutton.get_value ());
874 manager.select_normalize_dbtp (normalize_dbtp_spinbutton.get_value ());
875 update_normalize_sensitivity ();
879 ExportFormatDialog::update_silence_start_selection ()
881 update_time (silence_start, silence_start_clock);
883 zero.type = AnyTime::Timecode;
884 manager.select_silence_beginning (silence_start_checkbox.get_active() ? silence_start : zero);
888 ExportFormatDialog::update_silence_end_selection ()
890 update_time (silence_end, silence_end_clock);
892 zero.type = AnyTime::Timecode;
893 manager.select_silence_end (silence_end_checkbox.get_active() ? silence_end : zero);
897 ExportFormatDialog::update_clock (AudioClock & clock, ARDOUR::AnyTime const & time)
900 clock.set (_session->convert_to_samples (time), true);
902 AudioClock::Mode mode(AudioClock::Timecode);
905 case AnyTime::Timecode:
906 mode = AudioClock::Timecode;
909 mode = AudioClock::BBT;
911 case AnyTime::Samples:
912 mode = AudioClock::Samples;
914 case AnyTime::Seconds:
915 mode = AudioClock::MinSec;
919 clock.set_mode (mode);
923 ExportFormatDialog::update_time (AnyTime & time, AudioClock const & clock)
929 samplecnt_t samples = clock.current_duration();
931 switch (clock.mode()) {
932 case AudioClock::Timecode:
933 time.type = AnyTime::Timecode;
934 _session->timecode_time (samples, time.timecode);
936 case AudioClock::BBT:
937 time.type = AnyTime::BBT;
938 _session->bbt_time (samples, time.bbt);
940 case AudioClock::Seconds:
941 case AudioClock::MinSec:
942 time.type = AnyTime::Seconds;
943 time.seconds = (double) samples / _session->sample_rate();
945 case AudioClock::Samples:
946 time.type = AnyTime::Samples;
947 time.samples = samples;
953 ExportFormatDialog::update_src_quality_selection ()
955 Gtk::TreeModel::const_iterator iter = src_quality_combo.get_active();
956 ExportFormatBase::SRCQuality quality = iter->get_value (src_quality_cols.id);
957 manager.select_src_quality (quality);
961 ExportFormatDialog::update_codec_quality_selection ()
963 Gtk::TreeModel::const_iterator iter = codec_quality_combo.get_active();
967 int quality = iter->get_value (codec_quality_cols.quality);
968 manager.select_codec_quality (quality);
972 ExportFormatDialog::update_tagging_selection ()
974 manager.select_tagging (tag_checkbox.get_active());
978 ExportFormatDialog::change_encoding_options (ExportFormatPtr ptr)
980 empty_encoding_option_table ();
982 boost::shared_ptr<ARDOUR::ExportFormatLinear> linear_ptr;
983 boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ogg_ptr;
984 boost::shared_ptr<ARDOUR::ExportFormatFLAC> flac_ptr;
985 boost::shared_ptr<ARDOUR::ExportFormatBWF> bwf_ptr;
986 boost::shared_ptr<ARDOUR::ExportFormatFFMPEG> ffmpeg_ptr;
988 if ((linear_ptr = boost::dynamic_pointer_cast<ExportFormatLinear> (ptr))) {
989 show_linear_enconding_options (linear_ptr);
990 } else if ((ogg_ptr = boost::dynamic_pointer_cast<ExportFormatOggVorbis> (ptr))) {
991 show_ogg_enconding_options (ogg_ptr);
992 } else if ((flac_ptr = boost::dynamic_pointer_cast<ExportFormatFLAC> (ptr))) {
993 show_flac_enconding_options (flac_ptr);
994 } else if ((bwf_ptr = boost::dynamic_pointer_cast<ExportFormatBWF> (ptr))) {
995 show_bwf_enconding_options (bwf_ptr);
996 } else if ((ffmpeg_ptr = boost::dynamic_pointer_cast<ExportFormatFFMPEG> (ptr))) {
997 show_ffmpeg_enconding_options (ffmpeg_ptr);
999 std::cout << "Unrecognized format!" << std::endl;
1004 ExportFormatDialog::empty_encoding_option_table ()
1006 encoding_options_table.foreach (sigc::bind (sigc::mem_fun (*this, &ExportFormatDialog::remove_widget), &encoding_options_table));
1010 ExportFormatDialog::remove_widget (Gtk::Widget & to_remove, Gtk::Container * remove_from)
1012 remove_from->remove (to_remove);
1016 ExportFormatDialog::show_linear_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatLinear> ptr)
1018 /* Set label and pack table */
1020 encoding_options_label.set_label (_("Linear encoding options"));
1022 encoding_options_table.resize (2, 2);
1023 encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
1024 encoding_options_table.attach (dither_label, 1, 2, 0, 1);
1025 encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
1026 encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
1028 fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
1030 show_all_children ();
1034 ExportFormatDialog::show_ogg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ptr)
1036 encoding_options_label.set_label (_("Ogg Vorbis options"));
1038 encoding_options_table.resize (2, 1);
1039 encoding_options_table.attach (codec_quality_combo, 0, 1, 0, 1);
1040 encoding_options_table.attach (tag_checkbox, 0, 1, 1, 2);
1041 fill_codec_quality_lists (ptr);
1042 show_all_children ();
1046 ExportFormatDialog::show_flac_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFLAC> ptr)
1048 encoding_options_label.set_label (_("FLAC options"));
1050 encoding_options_table.resize (3, 2);
1051 encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
1052 encoding_options_table.attach (dither_label, 1, 2, 0, 1);
1053 encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
1054 encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
1055 encoding_options_table.attach (tag_checkbox, 0, 2, 2, 3);
1057 fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
1059 show_all_children ();
1063 ExportFormatDialog::show_bwf_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatBWF> ptr)
1065 encoding_options_label.set_label (_("Broadcast Wave options"));
1067 encoding_options_table.resize (2, 2);
1068 encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
1069 encoding_options_table.attach (dither_label, 1, 2, 0, 1);
1070 encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
1071 encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
1073 fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
1075 show_all_children ();
1079 ExportFormatDialog::show_ffmpeg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFFMPEG> ptr)
1081 encoding_options_label.set_label (_("FFMPEG/MP3 options"));
1082 encoding_options_table.resize (1, 1);
1083 encoding_options_table.attach (codec_quality_combo, 0, 1, 0, 1);
1084 encoding_options_table.attach (tag_checkbox, 0, 1, 1, 2);
1085 fill_codec_quality_lists (ptr);
1086 show_all_children ();
1090 ExportFormatDialog::fill_sample_format_lists (boost::shared_ptr<ARDOUR::HasSampleFormat> ptr)
1094 Gtk::TreeModel::iterator iter;
1095 Gtk::TreeModel::Row row;
1097 sample_format_list->clear ();
1099 HasSampleFormat::SampleFormatList const & formats = ptr->get_sample_formats ();
1101 for (HasSampleFormat::SampleFormatList::const_iterator it = formats.begin(); it != formats.end(); ++it) {
1102 iter = sample_format_list->append();
1105 row[sample_format_cols.ptr] = *it;
1106 row[sample_format_cols.color] = (*it)->compatible() ? "white" : "red";
1107 row[sample_format_cols.label] = (*it)->name();
1109 if ((*it)->selected()) {
1110 sample_format_view.get_selection()->select (iter);
1114 dither_type_list->clear ();
1116 HasSampleFormat::DitherTypeList const & types = ptr->get_dither_types ();
1118 for (HasSampleFormat::DitherTypeList::const_iterator it = types.begin(); it != types.end(); ++it) {
1119 iter = dither_type_list->append();
1122 row[dither_type_cols.ptr] = *it;
1123 row[dither_type_cols.color] = "white";
1124 row[dither_type_cols.label] = (*it)->name();
1126 if ((*it)->selected()) {
1127 dither_type_view.get_selection()->select (iter);
1133 ExportFormatDialog::fill_codec_quality_lists (boost::shared_ptr<ARDOUR::HasCodecQuality> ptr)
1135 HasCodecQuality::CodecQualityList const & codecs = ptr->get_codec_qualities();
1137 codec_quality_list->clear();
1138 for (HasCodecQuality::CodecQualityList::const_iterator it = codecs.begin(); it != codecs.end(); ++it) {
1140 Gtk::TreeModel::iterator iter = codec_quality_list->append();
1141 Gtk::TreeModel::Row row = *iter;
1142 row[codec_quality_cols.quality] = (*it)->quality;
1143 row[codec_quality_cols.label] = (*it)->name;
1145 set_codec_quality_selection ();
1149 ExportFormatDialog::set_codec_quality_selection ()
1151 for (Gtk::ListStore::Children::iterator it = codec_quality_list->children().begin(); it != codec_quality_list->children().end(); ++it) {
1152 if (it->get_value (codec_quality_cols.quality) == format->codec_quality()) {
1153 codec_quality_combo.set_active (it);
1160 ExportFormatDialog::end_dialog ()
1166 ExportFormatDialog::prohibit_compatibility_selection ()
1168 compatibility_select_connection.block (true);
1169 compatibility_view.get_selection()->unselect_all ();
1170 compatibility_select_connection.block (false);