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 #include "ardour/session.h"
22 #include "ardour/export_format_specification.h"
24 #include "export_format_dialog.h"
25 #include "gui_thread.h"
29 using namespace ARDOUR;
31 ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
32 ArdourDialog (new_dialog ? _("New Export Format Profile") : _("Edit Export Format Profile")),
35 original_state (format->get_state()),
37 applying_changes_from_engine (0),
39 name_label (_("Label: "), Gtk::ALIGN_LEFT),
40 name_generated_part ("", Gtk::ALIGN_LEFT),
42 normalize_checkbox (_("Normalize:")),
43 normalize_peak_rb (_("Peak")),
44 normalize_loudness_rb (_("Loudness")),
45 normalize_dbfs_adjustment ( 0.00, -90.00, 0.00, 0.1, 0.2),
46 normalize_lufs_adjustment (-23.0, -90.00, 0.00, 0.1, 1.0),
47 normalize_dbtp_adjustment ( -1.0, -90.00, 0.00, 0.1, 0.2),
49 normalize_dbfs_label (_("dBFS"), Gtk::ALIGN_LEFT),
50 normalize_lufs_label (_("LUFS"), Gtk::ALIGN_LEFT),
51 normalize_dbtp_label (_("dBTP"), Gtk::ALIGN_LEFT),
54 trim_start_checkbox (_("Trim silence at start")),
55 silence_start_checkbox (_("Add silence at start:")),
56 silence_start_clock ("silence_start", true, "", true, false, true),
58 trim_end_checkbox (_("Trim silence at end")),
59 silence_end_checkbox (_("Add silence at end:")),
60 silence_end_clock ("silence_end", true, "", true, false, true),
62 command_label(_("Command to run post-export\n(%f=file path, %d=directory, %b=basename, see tooltip for more):"), Gtk::ALIGN_LEFT),
65 compatibility_label (_("Compatibility"), Gtk::ALIGN_LEFT),
66 quality_label (_("Quality"), Gtk::ALIGN_LEFT),
67 format_label (_("File format"), Gtk::ALIGN_LEFT),
68 sample_rate_label (_("Sample rate"), Gtk::ALIGN_LEFT),
69 src_quality_label (_("Sample rate conversion quality:"), Gtk::ALIGN_RIGHT),
71 encoding_options_label ("", Gtk::ALIGN_LEFT),
73 /* Changing encoding options from here on */
75 sample_format_label (_("Sample Format"), Gtk::ALIGN_LEFT),
76 dither_label (_("Dithering"), Gtk::ALIGN_LEFT),
78 with_cue (_("Create CUE file for disk-at-once CD/DVD creation")),
79 with_toc (_("Create TOC file for disk-at-once CD/DVD creation")),
80 with_mp4chaps (_("Create chapter mark file for MP4 chapter marks")),
82 tag_checkbox (_("Tag file with session's metadata"))
85 /* Pack containers in dialog */
87 get_vbox()->pack_start (silence_table, false, false, 6);
88 get_vbox()->pack_start (format_table, false, false, 6);
89 get_vbox()->pack_start (encoding_options_vbox, false, false, 0);
90 get_vbox()->pack_start (cue_toc_vbox, false, false, 0);
91 get_vbox()->pack_start (name_hbox, false, false, 6);
93 /* Name, new and remove */
95 name_hbox.pack_start (name_label, false, false, 0);
96 name_hbox.pack_start (name_entry, false, false, 0);
97 name_hbox.pack_start (name_generated_part, true, true, 0);
98 name_entry.set_width_chars(20);
100 manager.DescriptionChanged.connect(
101 *this, invalidator (*this),
102 boost::bind (&ExportFormatDialog::update_description, this), gui_context());
106 Gtk::RadioButtonGroup normalize_group = normalize_loudness_rb.get_group();
107 normalize_peak_rb.set_group (normalize_group);
109 normalize_hbox.pack_start (normalize_checkbox, false, false, 2);
110 normalize_hbox.pack_start (normalize_peak_rb, false, false, 0);
111 normalize_hbox.pack_start (normalize_dbfs_spinbutton, false, false, 2);
112 normalize_hbox.pack_start (normalize_dbfs_label, false, false, 0);
114 normalize_hbox.pack_start (*Gtk::manage (new Gtk::Label ("")), false, false, 6); // separator
116 normalize_hbox.pack_start (normalize_loudness_rb, false, false, 0);
117 normalize_hbox.pack_start (normalize_lufs_spinbutton, false, false, 2);
118 normalize_hbox.pack_start (normalize_lufs_label, false, false, 0);
119 normalize_hbox.pack_start (*Gtk::manage (new Gtk::Label (_("\u2227"))), false, false, 4);
120 normalize_hbox.pack_start (normalize_dbtp_spinbutton, false, false, 2);
121 normalize_hbox.pack_start (normalize_dbtp_label, false, false, 0);
123 ARDOUR_UI_UTILS::set_tooltip (normalize_loudness_rb,
124 _("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."));
126 normalize_dbfs_spinbutton.configure (normalize_dbfs_adjustment, 0.1, 2);
127 normalize_lufs_spinbutton.configure (normalize_lufs_adjustment, 0.1, 2);
128 normalize_dbtp_spinbutton.configure (normalize_dbtp_adjustment, 0.1, 2);
132 silence_table.set_row_spacings (6);
133 silence_table.set_col_spacings (12);
135 silence_table.attach (normalize_hbox, 0, 3, 0, 1);
137 silence_table.attach (trim_start_checkbox, 0, 1, 1, 2);
138 silence_table.attach (silence_start_checkbox, 1, 2, 1, 2);
139 silence_table.attach (silence_start_clock, 2, 3, 1, 2);
141 silence_table.attach (trim_end_checkbox, 0, 1, 2, 3);
142 silence_table.attach (silence_end_checkbox, 1, 2, 2, 3);
143 silence_table.attach (silence_end_clock, 2, 3, 2, 3);
145 /* Post-export hook script */
147 get_vbox()->pack_start (command_label, false, false);
148 get_vbox()->pack_start (command_entry, false, false);
150 ARDOUR_UI_UTILS::set_tooltip (command_entry,
153 "%b File's base-name\n"
155 "%d File's directory\n"
156 "%f File's full absolute path\n"
166 "%L Total track count\n"
181 /* Encoding options */
183 init_encoding_option_widgets();
185 encoding_options_table.set_spacings (1);
187 encoding_options_vbox.pack_start (encoding_options_label, false, false, 0);
188 encoding_options_vbox.pack_start (encoding_options_table, false, false, 12);
190 Pango::AttrList bold;
191 Pango::Attribute b = Pango::Attribute::create_attr_weight (Pango::WEIGHT_BOLD);
193 encoding_options_label.set_attributes (bold);
197 revert_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
198 revert_button->signal_clicked().connect (sigc::mem_fun(*this, &ExportFormatDialog::revert));
199 close_button = add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_APPLY);
200 close_button->set_sensitive (false);
201 close_button->signal_clicked().connect (sigc::mem_fun (*this, &ExportFormatDialog::end_dialog));
202 manager.CompleteChanged.connect (*this, invalidator (*this), boost::bind (&Gtk::Button::set_sensitive, close_button, _1), gui_context());
204 with_cue.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_cue));
205 with_toc.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_toc));
206 with_mp4chaps.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_mp4chaps));
207 command_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_command));
209 cue_toc_vbox.pack_start (with_cue, false, false);
210 cue_toc_vbox.pack_start (with_toc, false, false);
211 cue_toc_vbox.pack_start (with_mp4chaps, false, false);
213 /* Load state before hooking up the rest of the signals */
219 name_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_name));
221 /* Normalize, silence and src_quality signals */
223 trim_start_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_trim_start_selection));
224 trim_end_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_trim_end_selection));
226 normalize_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
227 normalize_peak_rb.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
228 normalize_loudness_rb.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
229 normalize_dbfs_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
230 normalize_lufs_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
231 normalize_dbtp_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
233 silence_start_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
234 silence_start_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
236 silence_end_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
237 silence_end_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
239 src_quality_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_src_quality_selection));
241 /* Format table signals */
243 Gtk::CellRendererToggle *toggle = dynamic_cast<Gtk::CellRendererToggle *>(compatibility_view.get_column_cell_renderer (0));
244 toggle->signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_compatibility_selection));
245 compatibility_select_connection = compatibility_view.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::prohibit_compatibility_selection));
247 quality_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_quality_selection));
248 format_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_format_selection));
249 sample_rate_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_sample_rate_selection));
251 /* Encoding option signals */
253 sample_format_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_sample_format_selection));
254 dither_type_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_dither_type_selection));
256 tag_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_tagging_selection));
261 update_normalize_sensitivity ();
264 ExportFormatDialog::~ExportFormatDialog ()
270 ExportFormatDialog::revert ()
272 ++applying_changes_from_engine;
274 format->set_state (original_state);
277 --applying_changes_from_engine;
281 ExportFormatDialog::set_session (ARDOUR::Session* s)
283 SessionHandlePtr::set_session (s);
284 silence_start_clock.set_session (s);
285 silence_end_clock.set_session (s);
291 update_clock (silence_start_clock, silence_start);
292 update_clock (silence_end_clock, silence_end);
294 /* Select native samplerate if no selection is yet made */
296 if (sample_rate_view.get_selection()->count_selected_rows() == 0) {
297 Gtk::ListStore::Children::iterator it;
298 for (it = sample_rate_list->children().begin(); it != sample_rate_list->children().end(); ++it) {
299 if ((framecnt_t) (*it)->get_value (sample_rate_cols.ptr)->rate == _session->nominal_frame_rate()) {
300 sample_rate_view.get_selection()->select (it);
308 ExportFormatDialog::load_state (FormatPtr spec)
310 name_entry.set_text (spec->name());
312 normalize_checkbox.set_active (spec->normalize());
313 normalize_peak_rb.set_active (!spec->normalize_loudness());
314 normalize_loudness_rb.set_active (spec->normalize_loudness());
315 normalize_dbfs_spinbutton.set_value (spec->normalize_dbfs());
316 normalize_lufs_spinbutton.set_value (spec->normalize_lufs());
317 normalize_dbtp_spinbutton.set_value (spec->normalize_dbtp());
319 trim_start_checkbox.set_active (spec->trim_beginning());
320 silence_start = spec->silence_beginning_time();
321 silence_start_checkbox.set_active (spec->silence_beginning_time().not_zero());
323 trim_end_checkbox.set_active (spec->trim_end());
324 silence_end = spec->silence_end_time();
325 silence_end_checkbox.set_active (spec->silence_end_time().not_zero());
327 with_cue.set_active (spec->with_cue());
328 with_toc.set_active (spec->with_toc());
329 with_mp4chaps.set_active (spec->with_mp4chaps());
331 for (Gtk::ListStore::Children::iterator it = src_quality_list->children().begin(); it != src_quality_list->children().end(); ++it) {
332 if (it->get_value (src_quality_cols.id) == spec->src_quality()) {
333 src_quality_combo.set_active (it);
338 for (Gtk::ListStore::Children::iterator it = format_list->children().begin(); it != format_list->children().end(); ++it) {
339 boost::shared_ptr<ARDOUR::ExportFormat> format_in_list = it->get_value (format_cols.ptr);
340 if (format_in_list->get_format_id() == spec->format_id() &&
341 // BWF has the same format id with wav, so we need to check this.
342 format_in_list->has_broadcast_info() == spec->has_broadcast_info()) {
344 format_in_list->set_selected (true);
349 for (Gtk::ListStore::Children::iterator it = sample_rate_list->children().begin(); it != sample_rate_list->children().end(); ++it) {
350 if (it->get_value (sample_rate_cols.ptr)->rate == spec->sample_rate()) {
351 it->get_value (sample_rate_cols.ptr)->set_selected (true);
356 if (spec->sample_format()) {
357 for (Gtk::ListStore::Children::iterator it = sample_format_list->children().begin(); it != sample_format_list->children().end(); ++it) {
358 if (it->get_value (sample_format_cols.ptr)->format == spec->sample_format()) {
359 it->get_value (sample_format_cols.ptr)->set_selected (true);
364 for (Gtk::ListStore::Children::iterator it = dither_type_list->children().begin(); it != dither_type_list->children().end(); ++it) {
365 if (it->get_value (dither_type_cols.ptr)->type == spec->dither_type()) {
366 it->get_value (dither_type_cols.ptr)->set_selected (true);
372 update_normalize_sensitivity ();
373 tag_checkbox.set_active (spec->tag());
374 command_entry.set_text (spec->command());
378 ExportFormatDialog::init_format_table ()
381 format_table.set_spacings (1);
383 format_table.attach (compatibility_label, 0, 1, 0, 1);
384 format_table.attach (quality_label, 1, 2, 0, 1);
385 format_table.attach (format_label, 2, 3, 0, 1);
386 format_table.attach (sample_rate_label, 3, 4, 0, 1);
388 format_table.attach (compatibility_view, 0, 1, 1, 2);
389 format_table.attach (quality_view, 1, 2, 1, 2);
390 format_table.attach (format_view, 2, 3, 1, 2);
391 format_table.attach (sample_rate_view, 3, 4, 1, 2);
393 format_table.attach (src_quality_label, 0, 3, 2, 3);
394 format_table.attach (src_quality_combo, 3, 4, 2, 3);
396 compatibility_view.set_headers_visible (false);
397 quality_view.set_headers_visible (false);
398 format_view.set_headers_visible (false);
399 sample_rate_view.set_headers_visible (false);
401 /*** Table entries ***/
403 Gtk::TreeModel::iterator iter;
404 Gtk::TreeModel::Row row;
406 /* Compatibilities */
408 compatibility_list = Gtk::ListStore::create (compatibility_cols);
409 compatibility_view.set_model (compatibility_list);
411 ExportFormatManager::CompatList const & compat_list = manager.get_compatibilities();
413 for (ExportFormatManager::CompatList::const_iterator it = compat_list.begin(); it != compat_list.end(); ++it) {
414 iter = compatibility_list->append();
417 row[compatibility_cols.ptr] = *it;
418 row[compatibility_cols.selected] = false;
419 row[compatibility_cols.label] = (*it)->name();
421 WeakCompatPtr ptr (*it);
422 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_compatibility_selection, this, _1, ptr), gui_context());
425 compatibility_view.append_column_editable ("", compatibility_cols.selected);
427 Gtk::CellRendererText* text_renderer = Gtk::manage (new Gtk::CellRendererText);
428 text_renderer->property_editable() = false;
430 Gtk::TreeView::Column* column = compatibility_view.get_column (0);
431 column->pack_start (*text_renderer);
432 column->add_attribute (text_renderer->property_text(), compatibility_cols.label);
436 quality_list = Gtk::ListStore::create (quality_cols);
437 quality_view.set_model (quality_list);
439 ExportFormatManager::QualityList const & qualities = manager.get_qualities ();
441 for (ExportFormatManager::QualityList::const_iterator it = qualities.begin(); it != qualities.end(); ++it) {
442 iter = quality_list->append();
445 row[quality_cols.ptr] = *it;
446 row[quality_cols.color] = "white";
447 row[quality_cols.label] = (*it)->name();
449 WeakQualityPtr ptr (*it);
450 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_quality_selection, this, _1, ptr), gui_context());
451 (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_quality_compatibility, this, _1, ptr), gui_context());
454 quality_view.append_column ("", quality_cols.label);
458 format_list = Gtk::ListStore::create (format_cols);
459 format_view.set_model (format_list);
461 ExportFormatManager::FormatList const & formats = manager.get_formats ();
463 for (ExportFormatManager::FormatList::const_iterator it = formats.begin(); it != formats.end(); ++it) {
464 iter = format_list->append();
467 row[format_cols.ptr] = *it;
468 row[format_cols.color] = "white";
469 row[format_cols.label] = (*it)->name();
471 WeakFormatPtr ptr (*it);
472 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_format_selection, this, _1, ptr), gui_context());
473 (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_format_compatibility, this, _1, ptr), gui_context());
475 /* Encoding options */
477 boost::shared_ptr<HasSampleFormat> hsf;
479 if ((hsf = boost::dynamic_pointer_cast<HasSampleFormat> (*it))) {
480 hsf->SampleFormatSelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_format_selection, this, _1, _2), gui_context());
481 hsf->SampleFormatCompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_format_compatibility, this, _1, _2), gui_context());
483 hsf->DitherTypeSelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_dither_type_selection, this, _1, _2), gui_context());
484 hsf->DitherTypeCompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_dither_type_compatibility, this, _1, _2), gui_context());
488 format_view.append_column ("", format_cols.label);
492 sample_rate_list = Gtk::ListStore::create (sample_rate_cols);
493 sample_rate_view.set_model (sample_rate_list);
495 ExportFormatManager::SampleRateList const & rates = manager.get_sample_rates ();
497 for (ExportFormatManager::SampleRateList::const_iterator it = rates.begin(); it != rates.end(); ++it) {
498 iter = sample_rate_list->append();
501 row[sample_rate_cols.ptr] = *it;
502 row[sample_rate_cols.color] = "white";
503 row[sample_rate_cols.label] = (*it)->name();
505 WeakSampleRatePtr ptr (*it);
506 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_rate_selection, this, _1, ptr), gui_context());
507 (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_rate_compatibility, this, _1, ptr), gui_context());
510 sample_rate_view.append_column ("", sample_rate_cols.label);
512 /* Color rendering */
514 Gtk::TreeViewColumn * label_col;
515 Gtk::CellRendererText * renderer;
517 label_col = quality_view.get_column(0);
518 renderer = dynamic_cast<Gtk::CellRendererText*> (quality_view.get_column_cell_renderer (0));
519 label_col->add_attribute(renderer->property_foreground(), quality_cols.color);
521 label_col = format_view.get_column(0);
522 renderer = dynamic_cast<Gtk::CellRendererText*> (format_view.get_column_cell_renderer (0));
523 label_col->add_attribute(renderer->property_foreground(), format_cols.color);
525 label_col = sample_rate_view.get_column(0);
526 renderer = dynamic_cast<Gtk::CellRendererText*> (sample_rate_view.get_column_cell_renderer (0));
527 label_col->add_attribute(renderer->property_foreground(), sample_rate_cols.color);
531 src_quality_list = Gtk::ListStore::create (src_quality_cols);
532 src_quality_combo.set_model (src_quality_list);
534 iter = src_quality_list->append();
536 row[src_quality_cols.id] = ExportFormatBase::SRC_SincBest;
537 row[src_quality_cols.label] = _("Best (sinc)");
539 iter = src_quality_list->append();
541 row[src_quality_cols.id] = ExportFormatBase::SRC_SincMedium;
542 row[src_quality_cols.label] = _("Medium (sinc)");
544 iter = src_quality_list->append();
546 row[src_quality_cols.id] = ExportFormatBase::SRC_SincFast;
547 row[src_quality_cols.label] = _("Fast (sinc)");
549 iter = src_quality_list->append();
551 row[src_quality_cols.id] = ExportFormatBase::SRC_Linear;
552 row[src_quality_cols.label] = _("Linear");
554 iter = src_quality_list->append();
556 row[src_quality_cols.id] = ExportFormatBase::SRC_ZeroOrderHold;
557 row[src_quality_cols.label] = _("Zero order hold");
559 src_quality_combo.pack_start (src_quality_cols.label);
560 src_quality_combo.set_active (0);
564 ExportFormatDialog::init_encoding_option_widgets ()
566 Gtk::TreeViewColumn * label_col;
567 Gtk::CellRendererText * renderer;
569 sample_format_list = Gtk::ListStore::create (sample_format_cols);
570 sample_format_view.set_model (sample_format_list);
571 sample_format_view.set_headers_visible (false);
572 sample_format_view.append_column ("", sample_format_cols.label);
573 label_col = sample_format_view.get_column(0);
574 renderer = dynamic_cast<Gtk::CellRendererText*> (sample_format_view.get_column_cell_renderer (0));
575 label_col->add_attribute(renderer->property_foreground(), sample_format_cols.color);
577 dither_type_list = Gtk::ListStore::create (dither_type_cols);
578 dither_type_view.set_model (dither_type_list);
579 dither_type_view.set_headers_visible (false);
580 dither_type_view.append_column ("", dither_type_cols.label);
581 label_col = dither_type_view.get_column(0);
582 renderer = dynamic_cast<Gtk::CellRendererText*> (dither_type_view.get_column_cell_renderer (0));
583 label_col->add_attribute(renderer->property_foreground(), dither_type_cols.color);
588 ExportFormatDialog::update_compatibility_selection (std::string const & path)
591 Gtk::TreeModel::iterator iter = compatibility_view.get_model ()->get_iter (path);
592 ExportFormatCompatibilityPtr ptr = iter->get_value (compatibility_cols.ptr);
593 bool state = iter->get_value (compatibility_cols.selected);
595 iter->set_value (compatibility_cols.selected, state);
596 ptr->set_selected (state);
601 ExportFormatDialog::update_quality_selection ()
603 update_selection<QualityCols> (quality_list, quality_view, quality_cols);
607 ExportFormatDialog::update_format_selection ()
609 update_selection<FormatCols> (format_list, format_view, format_cols);
613 ExportFormatDialog::update_sample_rate_selection ()
615 update_selection<SampleRateCols> (sample_rate_list, sample_rate_view, sample_rate_cols);
619 ExportFormatDialog::update_sample_format_selection ()
621 update_selection<SampleFormatCols> (sample_format_list, sample_format_view, sample_format_cols);
625 ExportFormatDialog::update_dither_type_selection ()
627 update_selection<DitherTypeCols> (dither_type_list, dither_type_view, dither_type_cols);
630 template<typename ColsT>
632 ExportFormatDialog::update_selection (Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols)
634 if (applying_changes_from_engine) {
638 Gtk::ListStore::Children::iterator it;
639 Glib::RefPtr<Gtk::TreeSelection> selection = view.get_selection();
641 for (it = list->children().begin(); it != list->children().end(); ++it) {
642 bool selected = selection->is_selected (it);
643 it->get_value (cols.ptr)->set_selected (selected);
648 ExportFormatDialog::change_compatibility_selection (bool select, WeakCompatPtr compat)
650 ++applying_changes_from_engine;
652 ExportFormatCompatibilityPtr ptr = compat.lock();
654 for (Gtk::ListStore::Children::iterator it = compatibility_list->children().begin(); it != compatibility_list->children().end(); ++it) {
655 if (it->get_value (compatibility_cols.ptr) == ptr) {
656 it->set_value (compatibility_cols.selected, select);
661 --applying_changes_from_engine;
665 ExportFormatDialog::change_quality_selection (bool select, WeakQualityPtr quality)
667 change_selection<ExportFormatManager::QualityState, QualityCols> (select, quality, quality_list, quality_view, quality_cols);
671 ExportFormatDialog::change_format_selection (bool select, WeakFormatPtr format)
673 change_selection<ExportFormat, FormatCols> (select, format, format_list, format_view, format_cols);
675 ExportFormatPtr ptr = format.lock();
678 change_encoding_options (ptr);
683 ExportFormatDialog::change_sample_rate_selection (bool select, WeakSampleRatePtr rate)
685 change_selection<ExportFormatManager::SampleRateState, SampleRateCols> (select, rate, sample_rate_list, sample_rate_view, sample_rate_cols);
688 ExportFormatManager::SampleRatePtr ptr = rate.lock();
689 if (ptr && _session) {
690 src_quality_combo.set_sensitive ((uint32_t) ptr->rate != _session->frame_rate());
696 ExportFormatDialog::change_sample_format_selection (bool select, WeakSampleFormatPtr format)
698 change_selection<HasSampleFormat::SampleFormatState, SampleFormatCols> (select, format, sample_format_list, sample_format_view, sample_format_cols);
702 ExportFormatDialog::change_dither_type_selection (bool select, WeakDitherTypePtr type)
704 change_selection<HasSampleFormat::DitherTypeState, DitherTypeCols> (select, type, dither_type_list, dither_type_view, dither_type_cols);
707 template<typename T, typename ColsT>
709 ExportFormatDialog::change_selection (bool select, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols)
711 ++applying_changes_from_engine;
713 boost::shared_ptr<T> ptr = w_ptr.lock();
715 Gtk::ListStore::Children::iterator it;
716 Glib::RefPtr<Gtk::TreeSelection> selection;
718 selection = view.get_selection();
721 selection->unselect_all();
723 for (it = list->children().begin(); it != list->children().end(); ++it) {
724 if (it->get_value (cols.ptr) == ptr) {
726 selection->select (it);
728 selection->unselect (it);
735 --applying_changes_from_engine;
739 ExportFormatDialog::change_quality_compatibility (bool compatibility, WeakQualityPtr quality)
741 change_compatibility<ExportFormatManager::QualityState, QualityCols> (compatibility, quality, quality_list, quality_cols);
745 ExportFormatDialog::change_format_compatibility (bool compatibility, WeakFormatPtr format)
747 change_compatibility<ExportFormat, FormatCols> (compatibility, format, format_list, format_cols);
751 ExportFormatDialog::change_sample_rate_compatibility (bool compatibility, WeakSampleRatePtr rate)
753 change_compatibility<ExportFormatManager::SampleRateState, SampleRateCols> (compatibility, rate, sample_rate_list, sample_rate_cols);
757 ExportFormatDialog::change_sample_format_compatibility (bool compatibility, WeakSampleFormatPtr format)
759 change_compatibility<HasSampleFormat::SampleFormatState, SampleFormatCols> (compatibility, format, sample_format_list, sample_format_cols);
763 ExportFormatDialog::change_dither_type_compatibility (bool compatibility, WeakDitherTypePtr type)
765 change_compatibility<HasSampleFormat::DitherTypeState, DitherTypeCols> (compatibility, type, dither_type_list, dither_type_cols, "red");
768 template<typename T, typename ColsT>
770 ExportFormatDialog::change_compatibility (bool compatibility, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, ColsT & cols,
771 std::string const & c_incompatible, std::string const & c_compatible)
773 boost::shared_ptr<T> ptr = w_ptr.lock();
775 Gtk::ListStore::Children::iterator it;
776 for (it = list->children().begin(); it != list->children().end(); ++it) {
777 if (it->get_value (cols.ptr) == ptr) {
778 it->set_value (cols.color, compatibility ? c_compatible : c_incompatible);
785 ExportFormatDialog::update_with_cue ()
787 manager.select_with_cue (with_cue.get_active());
791 ExportFormatDialog::update_with_toc ()
793 manager.select_with_toc (with_toc.get_active());
797 ExportFormatDialog::update_with_mp4chaps ()
799 manager.select_with_mp4chaps (with_mp4chaps.get_active());
803 ExportFormatDialog::update_command ()
805 manager.set_command (command_entry.get_text());
809 ExportFormatDialog::update_description()
811 std::string text = ": " + format->description(false);
812 name_generated_part.set_text(text);
816 ExportFormatDialog::update_name ()
818 manager.set_name (name_entry.get_text());
822 ExportFormatDialog::update_trim_start_selection ()
824 manager.select_trim_beginning (trim_start_checkbox.get_active());
828 ExportFormatDialog::update_trim_end_selection ()
830 manager.select_trim_end (trim_end_checkbox.get_active());
834 ExportFormatDialog::update_normalize_sensitivity ()
836 bool en = normalize_checkbox.get_active();
837 bool loudness = normalize_loudness_rb.get_active();
838 normalize_dbfs_spinbutton.set_sensitive (!loudness && en);
839 normalize_lufs_spinbutton.set_sensitive (loudness && en);
840 normalize_dbtp_spinbutton.set_sensitive (loudness && en);
844 ExportFormatDialog::update_normalize_selection ()
846 manager.select_normalize (normalize_checkbox.get_active());
847 manager.select_normalize_loudness (normalize_loudness_rb.get_active());
848 manager.select_normalize_dbfs (normalize_dbfs_spinbutton.get_value ());
849 manager.select_normalize_lufs (normalize_lufs_spinbutton.get_value ());
850 manager.select_normalize_dbtp (normalize_dbtp_spinbutton.get_value ());
851 update_normalize_sensitivity ();
855 ExportFormatDialog::update_silence_start_selection ()
857 update_time (silence_start, silence_start_clock);
859 zero.type = AnyTime::Timecode;
860 manager.select_silence_beginning (silence_start_checkbox.get_active() ? silence_start : zero);
864 ExportFormatDialog::update_silence_end_selection ()
866 update_time (silence_end, silence_end_clock);
868 zero.type = AnyTime::Timecode;
869 manager.select_silence_end (silence_end_checkbox.get_active() ? silence_end : zero);
873 ExportFormatDialog::update_clock (AudioClock & clock, ARDOUR::AnyTime const & time)
876 clock.set (_session->convert_to_frames (time), true);
878 AudioClock::Mode mode(AudioClock::Timecode);
881 case AnyTime::Timecode:
882 mode = AudioClock::Timecode;
885 mode = AudioClock::BBT;
887 case AnyTime::Frames:
888 mode = AudioClock::Frames;
890 case AnyTime::Seconds:
891 mode = AudioClock::MinSec;
895 clock.set_mode (mode);
899 ExportFormatDialog::update_time (AnyTime & time, AudioClock const & clock)
905 framecnt_t frames = clock.current_duration();
907 switch (clock.mode()) {
908 case AudioClock::Timecode:
909 time.type = AnyTime::Timecode;
910 _session->timecode_time (frames, time.timecode);
912 case AudioClock::BBT:
913 time.type = AnyTime::BBT;
914 _session->bbt_time (frames, time.bbt);
916 case AudioClock::MinSec:
917 time.type = AnyTime::Seconds;
918 time.seconds = (double) frames / _session->frame_rate();
920 case AudioClock::Frames:
921 time.type = AnyTime::Frames;
922 time.frames = frames;
928 ExportFormatDialog::update_src_quality_selection ()
930 Gtk::TreeModel::const_iterator iter = src_quality_combo.get_active();
931 ExportFormatBase::SRCQuality quality = iter->get_value (src_quality_cols.id);
932 manager.select_src_quality (quality);
936 ExportFormatDialog::update_tagging_selection ()
938 manager.select_tagging (tag_checkbox.get_active());
942 ExportFormatDialog::change_encoding_options (ExportFormatPtr ptr)
944 empty_encoding_option_table ();
946 boost::shared_ptr<ARDOUR::ExportFormatLinear> linear_ptr;
947 boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ogg_ptr;
948 boost::shared_ptr<ARDOUR::ExportFormatFLAC> flac_ptr;
949 boost::shared_ptr<ARDOUR::ExportFormatBWF> bwf_ptr;
951 if ((linear_ptr = boost::dynamic_pointer_cast<ExportFormatLinear> (ptr))) {
952 show_linear_enconding_options (linear_ptr);
953 } else if ((ogg_ptr = boost::dynamic_pointer_cast<ExportFormatOggVorbis> (ptr))) {
954 show_ogg_enconding_options (ogg_ptr);
955 } else if ((flac_ptr = boost::dynamic_pointer_cast<ExportFormatFLAC> (ptr))) {
956 show_flac_enconding_options (flac_ptr);
957 } else if ((bwf_ptr = boost::dynamic_pointer_cast<ExportFormatBWF> (ptr))) {
958 show_bwf_enconding_options (bwf_ptr);
960 std::cout << "Unrecognized format!" << std::endl;
965 ExportFormatDialog::empty_encoding_option_table ()
967 encoding_options_table.foreach (sigc::bind (sigc::mem_fun (*this, &ExportFormatDialog::remove_widget), &encoding_options_table));
971 ExportFormatDialog::remove_widget (Gtk::Widget & to_remove, Gtk::Container * remove_from)
973 remove_from->remove (to_remove);
977 ExportFormatDialog::show_linear_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatLinear> ptr)
979 /* Set label and pack table */
981 encoding_options_label.set_label (_("Linear encoding options"));
983 encoding_options_table.resize (2, 2);
984 encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
985 encoding_options_table.attach (dither_label, 1, 2, 0, 1);
986 encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
987 encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
989 fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
991 show_all_children ();
995 ExportFormatDialog::show_ogg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> /*ptr*/)
997 encoding_options_label.set_label (_("Ogg Vorbis options"));
999 encoding_options_table.resize (1, 1);
1000 encoding_options_table.attach (tag_checkbox, 0, 1, 0, 1);
1002 show_all_children ();
1006 ExportFormatDialog::show_flac_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFLAC> ptr)
1008 encoding_options_label.set_label (_("FLAC options"));
1010 encoding_options_table.resize (3, 2);
1011 encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
1012 encoding_options_table.attach (dither_label, 1, 2, 0, 1);
1013 encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
1014 encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
1015 encoding_options_table.attach (tag_checkbox, 0, 2, 2, 3);
1017 fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
1019 show_all_children ();
1023 ExportFormatDialog::show_bwf_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatBWF> ptr)
1025 encoding_options_label.set_label (_("Broadcast Wave options"));
1027 encoding_options_table.resize (2, 2);
1028 encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
1029 encoding_options_table.attach (dither_label, 1, 2, 0, 1);
1030 encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
1031 encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
1033 fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
1035 show_all_children ();
1039 ExportFormatDialog::fill_sample_format_lists (boost::shared_ptr<ARDOUR::HasSampleFormat> ptr)
1043 Gtk::TreeModel::iterator iter;
1044 Gtk::TreeModel::Row row;
1046 sample_format_list->clear ();
1048 HasSampleFormat::SampleFormatList const & formats = ptr->get_sample_formats ();
1050 for (HasSampleFormat::SampleFormatList::const_iterator it = formats.begin(); it != formats.end(); ++it) {
1051 iter = sample_format_list->append();
1054 row[sample_format_cols.ptr] = *it;
1055 row[sample_format_cols.color] = (*it)->compatible() ? "white" : "red";
1056 row[sample_format_cols.label] = (*it)->name();
1058 if ((*it)->selected()) {
1059 sample_format_view.get_selection()->select (iter);
1063 dither_type_list->clear ();
1065 HasSampleFormat::DitherTypeList const & types = ptr->get_dither_types ();
1067 for (HasSampleFormat::DitherTypeList::const_iterator it = types.begin(); it != types.end(); ++it) {
1068 iter = dither_type_list->append();
1071 row[dither_type_cols.ptr] = *it;
1072 row[dither_type_cols.color] = "white";
1073 row[dither_type_cols.label] = (*it)->name();
1075 if ((*it)->selected()) {
1076 dither_type_view.get_selection()->select (iter);
1082 ExportFormatDialog::end_dialog ()
1088 ExportFormatDialog::prohibit_compatibility_selection ()
1090 compatibility_select_connection.block (true);
1091 compatibility_view.get_selection()->unselect_all ();
1092 compatibility_select_connection.block (false);