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 <gtkmm/stock.h>
23 #include "ardour/session.h"
24 #include "ardour/export_format_specification.h"
26 #include "widgets/tooltips.h"
28 #include "export_format_dialog.h"
29 #include "gui_thread.h"
33 using namespace ARDOUR;
35 ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
36 ArdourDialog (new_dialog ? _("New Export Format Profile") : _("Edit Export Format Profile")),
39 original_state (format->get_state()),
41 applying_changes_from_engine (0),
43 name_label (_("Label: "), Gtk::ALIGN_LEFT),
44 name_generated_part ("", Gtk::ALIGN_LEFT),
46 normalize_checkbox (_("Normalize:")),
47 normalize_peak_rb (_("Peak")),
48 normalize_loudness_rb (_("Loudness")),
49 normalize_dbfs_adjustment ( 0.00, -90.00, 0.00, 0.1, 0.2),
50 normalize_lufs_adjustment (-23.0, -90.00, 0.00, 0.1, 1.0),
51 normalize_dbtp_adjustment ( -1.0, -90.00, 0.00, 0.1, 0.2),
53 normalize_dbfs_label (_("dBFS"), Gtk::ALIGN_LEFT),
54 normalize_lufs_label (_("LUFS"), Gtk::ALIGN_LEFT),
55 normalize_dbtp_label (_("dBTP"), Gtk::ALIGN_LEFT),
58 trim_start_checkbox (_("Trim silence at start")),
59 silence_start_checkbox (_("Add silence at start:")),
60 silence_start_clock ("silence_start", true, "", true, false, true),
62 trim_end_checkbox (_("Trim silence at end")),
63 silence_end_checkbox (_("Add silence at end:")),
64 silence_end_clock ("silence_end", true, "", true, false, true),
66 command_label(_("Command to run post-export\n(%f=file path, %d=directory, %b=basename, see tooltip for more):"), Gtk::ALIGN_LEFT),
69 compatibility_label (_("Compatibility"), Gtk::ALIGN_LEFT),
70 quality_label (_("Quality"), Gtk::ALIGN_LEFT),
71 format_label (_("File format"), Gtk::ALIGN_LEFT),
72 sample_rate_label (_("Sample rate"), Gtk::ALIGN_LEFT),
73 src_quality_label (_("Sample rate conversion quality:"), Gtk::ALIGN_RIGHT),
75 encoding_options_label ("", Gtk::ALIGN_LEFT),
77 /* Changing encoding options from here on */
79 sample_format_label (_("Sample Format"), Gtk::ALIGN_LEFT),
80 dither_label (_("Dithering"), Gtk::ALIGN_LEFT),
82 with_cue (_("Create CUE file for disk-at-once CD/DVD creation")),
83 with_toc (_("Create TOC file for disk-at-once CD/DVD creation")),
84 with_mp4chaps (_("Create chapter mark file for MP4 chapter marks")),
86 tag_checkbox (_("Tag file with session's metadata"))
89 /* Pack containers in dialog */
91 get_vbox()->pack_start (silence_table, false, false, 6);
92 get_vbox()->pack_start (format_table, false, false, 6);
93 get_vbox()->pack_start (encoding_options_vbox, false, false, 0);
94 get_vbox()->pack_start (cue_toc_vbox, false, false, 0);
95 get_vbox()->pack_start (name_hbox, false, false, 6);
97 /* Name, new and remove */
99 name_hbox.pack_start (name_label, false, false, 0);
100 name_hbox.pack_start (name_entry, false, false, 0);
101 name_hbox.pack_start (name_generated_part, true, true, 0);
102 name_entry.set_width_chars(20);
103 update_description();
104 manager.DescriptionChanged.connect(
105 *this, invalidator (*this),
106 boost::bind (&ExportFormatDialog::update_description, this), gui_context());
110 Gtk::RadioButtonGroup normalize_group = normalize_loudness_rb.get_group();
111 normalize_peak_rb.set_group (normalize_group);
113 normalize_hbox.pack_start (normalize_checkbox, false, false, 2);
114 normalize_hbox.pack_start (normalize_peak_rb, false, false, 0);
115 normalize_hbox.pack_start (normalize_dbfs_spinbutton, false, false, 2);
116 normalize_hbox.pack_start (normalize_dbfs_label, false, false, 0);
118 normalize_hbox.pack_start (*Gtk::manage (new Gtk::Label ("")), false, false, 6); // separator
120 normalize_hbox.pack_start (normalize_loudness_rb, false, false, 0);
121 normalize_hbox.pack_start (normalize_lufs_spinbutton, false, false, 2);
122 normalize_hbox.pack_start (normalize_lufs_label, false, false, 0);
123 normalize_hbox.pack_start (*Gtk::manage (new Gtk::Label (_("\u2227"))), false, false, 4);
124 normalize_hbox.pack_start (normalize_dbtp_spinbutton, false, false, 2);
125 normalize_hbox.pack_start (normalize_dbtp_label, false, false, 0);
127 ArdourWidgets::set_tooltip (normalize_loudness_rb,
128 _("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."));
130 normalize_dbfs_spinbutton.configure (normalize_dbfs_adjustment, 0.1, 2);
131 normalize_lufs_spinbutton.configure (normalize_lufs_adjustment, 0.1, 2);
132 normalize_dbtp_spinbutton.configure (normalize_dbtp_adjustment, 0.1, 2);
136 silence_table.set_row_spacings (6);
137 silence_table.set_col_spacings (12);
139 silence_table.attach (normalize_hbox, 0, 3, 0, 1);
141 silence_table.attach (trim_start_checkbox, 0, 1, 1, 2);
142 silence_table.attach (silence_start_checkbox, 1, 2, 1, 2);
143 silence_table.attach (silence_start_clock, 2, 3, 1, 2);
145 silence_table.attach (trim_end_checkbox, 0, 1, 2, 3);
146 silence_table.attach (silence_end_checkbox, 1, 2, 2, 3);
147 silence_table.attach (silence_end_clock, 2, 3, 2, 3);
149 /* Post-export hook script */
151 get_vbox()->pack_start (command_label, false, false);
152 get_vbox()->pack_start (command_entry, false, false);
154 ArdourWidgets::set_tooltip (command_entry,
157 "%b File's base-name\n"
159 "%d File's directory\n"
160 "%f File's full absolute path\n"
170 "%L Total track count\n"
185 /* Encoding options */
187 init_encoding_option_widgets();
189 encoding_options_table.set_spacings (1);
191 encoding_options_vbox.pack_start (encoding_options_label, false, false, 0);
192 encoding_options_vbox.pack_start (encoding_options_table, false, false, 12);
194 Pango::AttrList bold;
195 Pango::Attribute b = Pango::Attribute::create_attr_weight (Pango::WEIGHT_BOLD);
197 encoding_options_label.set_attributes (bold);
201 codec_quality_list = Gtk::ListStore::create (codec_quality_cols);
202 codec_quality_combo.set_model (codec_quality_list);
203 codec_quality_combo.pack_start (codec_quality_cols.label);
204 //codec_quality_combo.set_active (0);
208 revert_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
209 revert_button->signal_clicked().connect (sigc::mem_fun(*this, &ExportFormatDialog::revert));
210 close_button = add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_APPLY);
211 close_button->set_sensitive (false);
212 close_button->signal_clicked().connect (sigc::mem_fun (*this, &ExportFormatDialog::end_dialog));
213 manager.CompleteChanged.connect (*this, invalidator (*this), boost::bind (&Gtk::Button::set_sensitive, close_button, _1), gui_context());
215 with_cue.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_cue));
216 with_toc.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_toc));
217 with_mp4chaps.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_mp4chaps));
218 command_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_command));
220 cue_toc_vbox.pack_start (with_cue, false, false);
221 cue_toc_vbox.pack_start (with_toc, false, false);
222 cue_toc_vbox.pack_start (with_mp4chaps, false, false);
224 /* Load state before hooking up the rest of the signals */
230 name_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_name));
232 /* Normalize, silence and src_quality signals */
234 trim_start_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_trim_start_selection));
235 trim_end_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_trim_end_selection));
237 normalize_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
238 normalize_peak_rb.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
239 normalize_loudness_rb.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
240 normalize_dbfs_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
241 normalize_lufs_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
242 normalize_dbtp_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
244 silence_start_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
245 silence_start_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
247 silence_end_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
248 silence_end_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
250 src_quality_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_src_quality_selection));
251 codec_quality_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_codec_quality_selection));
253 /* Format table signals */
255 Gtk::CellRendererToggle *toggle = dynamic_cast<Gtk::CellRendererToggle *>(compatibility_view.get_column_cell_renderer (0));
256 toggle->signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_compatibility_selection));
257 compatibility_select_connection = compatibility_view.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::prohibit_compatibility_selection));
259 quality_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_quality_selection));
260 format_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_format_selection));
261 sample_rate_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_sample_rate_selection));
263 /* Encoding option signals */
265 sample_format_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_sample_format_selection));
266 dither_type_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_dither_type_selection));
268 tag_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_tagging_selection));
273 update_normalize_sensitivity ();
276 ExportFormatDialog::~ExportFormatDialog ()
282 ExportFormatDialog::revert ()
284 ++applying_changes_from_engine;
286 format->set_state (original_state);
289 --applying_changes_from_engine;
293 ExportFormatDialog::set_session (ARDOUR::Session* s)
295 SessionHandlePtr::set_session (s);
296 silence_start_clock.set_session (s);
297 silence_end_clock.set_session (s);
303 update_clock (silence_start_clock, silence_start);
304 update_clock (silence_end_clock, silence_end);
306 /* Select native samplerate if no selection is yet made */
308 if (sample_rate_view.get_selection()->count_selected_rows() == 0) {
309 Gtk::ListStore::Children::iterator it;
310 for (it = sample_rate_list->children().begin(); it != sample_rate_list->children().end(); ++it) {
311 if ((samplecnt_t) (*it)->get_value (sample_rate_cols.ptr)->rate == _session->nominal_sample_rate()) {
312 sample_rate_view.get_selection()->select (it);
320 ExportFormatDialog::load_state (FormatPtr spec)
322 name_entry.set_text (spec->name());
324 normalize_checkbox.set_active (spec->normalize());
325 normalize_peak_rb.set_active (!spec->normalize_loudness());
326 normalize_loudness_rb.set_active (spec->normalize_loudness());
327 normalize_dbfs_spinbutton.set_value (spec->normalize_dbfs());
328 normalize_lufs_spinbutton.set_value (spec->normalize_lufs());
329 normalize_dbtp_spinbutton.set_value (spec->normalize_dbtp());
331 trim_start_checkbox.set_active (spec->trim_beginning());
332 silence_start = spec->silence_beginning_time();
333 silence_start_checkbox.set_active (spec->silence_beginning_time().not_zero());
335 trim_end_checkbox.set_active (spec->trim_end());
336 silence_end = spec->silence_end_time();
337 silence_end_checkbox.set_active (spec->silence_end_time().not_zero());
339 with_cue.set_active (spec->with_cue());
340 with_toc.set_active (spec->with_toc());
341 with_mp4chaps.set_active (spec->with_mp4chaps());
343 for (Gtk::ListStore::Children::iterator it = src_quality_list->children().begin(); it != src_quality_list->children().end(); ++it) {
344 if (it->get_value (src_quality_cols.id) == spec->src_quality()) {
345 src_quality_combo.set_active (it);
350 for (Gtk::ListStore::Children::iterator it = codec_quality_list->children().begin(); it != codec_quality_list->children().end(); ++it) {
351 if (it->get_value (codec_quality_cols.quality) == spec->codec_quality()) {
352 codec_quality_combo.set_active (it);
357 for (Gtk::ListStore::Children::iterator it = format_list->children().begin(); it != format_list->children().end(); ++it) {
358 boost::shared_ptr<ARDOUR::ExportFormat> format_in_list = it->get_value (format_cols.ptr);
359 if (format_in_list->get_format_id() == spec->format_id() &&
360 // BWF has the same format id with wav, so we need to check this.
361 format_in_list->has_broadcast_info() == spec->has_broadcast_info()) {
363 format_in_list->set_selected (true);
368 for (Gtk::ListStore::Children::iterator it = sample_rate_list->children().begin(); it != sample_rate_list->children().end(); ++it) {
369 if (it->get_value (sample_rate_cols.ptr)->rate == spec->sample_rate()) {
370 it->get_value (sample_rate_cols.ptr)->set_selected (true);
375 if (spec->sample_format()) {
376 for (Gtk::ListStore::Children::iterator it = sample_format_list->children().begin(); it != sample_format_list->children().end(); ++it) {
377 if (it->get_value (sample_format_cols.ptr)->format == spec->sample_format()) {
378 it->get_value (sample_format_cols.ptr)->set_selected (true);
383 for (Gtk::ListStore::Children::iterator it = dither_type_list->children().begin(); it != dither_type_list->children().end(); ++it) {
384 if (it->get_value (dither_type_cols.ptr)->type == spec->dither_type()) {
385 it->get_value (dither_type_cols.ptr)->set_selected (true);
391 update_normalize_sensitivity ();
392 tag_checkbox.set_active (spec->tag());
393 command_entry.set_text (spec->command());
397 ExportFormatDialog::init_format_table ()
400 format_table.set_spacings (1);
402 format_table.attach (compatibility_label, 0, 1, 0, 1);
403 format_table.attach (quality_label, 1, 2, 0, 1);
404 format_table.attach (format_label, 2, 3, 0, 1);
405 format_table.attach (sample_rate_label, 3, 4, 0, 1);
407 format_table.attach (compatibility_view, 0, 1, 1, 2);
408 format_table.attach (quality_view, 1, 2, 1, 2);
409 format_table.attach (format_view, 2, 3, 1, 2);
410 format_table.attach (sample_rate_view, 3, 4, 1, 2);
412 format_table.attach (src_quality_label, 0, 3, 2, 3);
413 format_table.attach (src_quality_combo, 3, 4, 2, 3);
415 compatibility_view.set_headers_visible (false);
416 quality_view.set_headers_visible (false);
417 format_view.set_headers_visible (false);
418 sample_rate_view.set_headers_visible (false);
420 /*** Table entries ***/
422 Gtk::TreeModel::iterator iter;
423 Gtk::TreeModel::Row row;
425 /* Compatibilities */
427 compatibility_list = Gtk::ListStore::create (compatibility_cols);
428 compatibility_view.set_model (compatibility_list);
430 ExportFormatManager::CompatList const & compat_list = manager.get_compatibilities();
432 for (ExportFormatManager::CompatList::const_iterator it = compat_list.begin(); it != compat_list.end(); ++it) {
433 iter = compatibility_list->append();
436 row[compatibility_cols.ptr] = *it;
437 row[compatibility_cols.selected] = false;
438 row[compatibility_cols.label] = (*it)->name();
440 WeakCompatPtr ptr (*it);
441 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_compatibility_selection, this, _1, ptr), gui_context());
444 compatibility_view.append_column_editable ("", compatibility_cols.selected);
446 Gtk::CellRendererText* text_renderer = Gtk::manage (new Gtk::CellRendererText);
447 text_renderer->property_editable() = false;
449 Gtk::TreeView::Column* column = compatibility_view.get_column (0);
450 column->pack_start (*text_renderer);
451 column->add_attribute (text_renderer->property_text(), compatibility_cols.label);
455 quality_list = Gtk::ListStore::create (quality_cols);
456 quality_view.set_model (quality_list);
458 ExportFormatManager::QualityList const & qualities = manager.get_qualities ();
460 for (ExportFormatManager::QualityList::const_iterator it = qualities.begin(); it != qualities.end(); ++it) {
461 iter = quality_list->append();
464 row[quality_cols.ptr] = *it;
465 row[quality_cols.color] = "white";
466 row[quality_cols.label] = (*it)->name();
468 WeakQualityPtr ptr (*it);
469 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_quality_selection, this, _1, ptr), gui_context());
470 (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_quality_compatibility, this, _1, ptr), gui_context());
473 quality_view.append_column ("", quality_cols.label);
477 format_list = Gtk::ListStore::create (format_cols);
478 format_view.set_model (format_list);
480 ExportFormatManager::FormatList const & formats = manager.get_formats ();
482 for (ExportFormatManager::FormatList::const_iterator it = formats.begin(); it != formats.end(); ++it) {
483 iter = format_list->append();
486 row[format_cols.ptr] = *it;
487 row[format_cols.color] = "white";
488 row[format_cols.label] = (*it)->name();
490 WeakFormatPtr ptr (*it);
491 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_format_selection, this, _1, ptr), gui_context());
492 (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_format_compatibility, this, _1, ptr), gui_context());
494 /* Encoding options */
496 boost::shared_ptr<HasSampleFormat> hsf;
498 if ((hsf = boost::dynamic_pointer_cast<HasSampleFormat> (*it))) {
499 hsf->SampleFormatSelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_format_selection, this, _1, _2), gui_context());
500 hsf->SampleFormatCompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_format_compatibility, this, _1, _2), gui_context());
502 hsf->DitherTypeSelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_dither_type_selection, this, _1, _2), gui_context());
503 hsf->DitherTypeCompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_dither_type_compatibility, this, _1, _2), gui_context());
507 format_view.append_column ("", format_cols.label);
511 sample_rate_list = Gtk::ListStore::create (sample_rate_cols);
512 sample_rate_view.set_model (sample_rate_list);
514 ExportFormatManager::SampleRateList const & rates = manager.get_sample_rates ();
516 for (ExportFormatManager::SampleRateList::const_iterator it = rates.begin(); it != rates.end(); ++it) {
517 iter = sample_rate_list->append();
520 row[sample_rate_cols.ptr] = *it;
521 row[sample_rate_cols.color] = "white";
522 row[sample_rate_cols.label] = (*it)->name();
524 WeakSampleRatePtr ptr (*it);
525 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_rate_selection, this, _1, ptr), gui_context());
526 (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_rate_compatibility, this, _1, ptr), gui_context());
529 sample_rate_view.append_column ("", sample_rate_cols.label);
531 /* Color rendering */
533 Gtk::TreeViewColumn * label_col;
534 Gtk::CellRendererText * renderer;
536 label_col = quality_view.get_column(0);
537 renderer = dynamic_cast<Gtk::CellRendererText*> (quality_view.get_column_cell_renderer (0));
538 label_col->add_attribute(renderer->property_foreground(), quality_cols.color);
540 label_col = format_view.get_column(0);
541 renderer = dynamic_cast<Gtk::CellRendererText*> (format_view.get_column_cell_renderer (0));
542 label_col->add_attribute(renderer->property_foreground(), format_cols.color);
544 label_col = sample_rate_view.get_column(0);
545 renderer = dynamic_cast<Gtk::CellRendererText*> (sample_rate_view.get_column_cell_renderer (0));
546 label_col->add_attribute(renderer->property_foreground(), sample_rate_cols.color);
550 src_quality_list = Gtk::ListStore::create (src_quality_cols);
551 src_quality_combo.set_model (src_quality_list);
553 iter = src_quality_list->append();
555 row[src_quality_cols.id] = ExportFormatBase::SRC_SincBest;
556 row[src_quality_cols.label] = _("Best (sinc)");
558 iter = src_quality_list->append();
560 row[src_quality_cols.id] = ExportFormatBase::SRC_SincMedium;
561 row[src_quality_cols.label] = _("Medium (sinc)");
563 iter = src_quality_list->append();
565 row[src_quality_cols.id] = ExportFormatBase::SRC_SincFast;
566 row[src_quality_cols.label] = _("Fast (sinc)");
568 iter = src_quality_list->append();
570 row[src_quality_cols.id] = ExportFormatBase::SRC_Linear;
571 row[src_quality_cols.label] = _("Linear");
573 iter = src_quality_list->append();
575 row[src_quality_cols.id] = ExportFormatBase::SRC_ZeroOrderHold;
576 row[src_quality_cols.label] = _("Zero order hold");
578 src_quality_combo.pack_start (src_quality_cols.label);
579 src_quality_combo.set_active (0);
583 ExportFormatDialog::init_encoding_option_widgets ()
585 Gtk::TreeViewColumn * label_col;
586 Gtk::CellRendererText * renderer;
588 sample_format_list = Gtk::ListStore::create (sample_format_cols);
589 sample_format_view.set_model (sample_format_list);
590 sample_format_view.set_headers_visible (false);
591 sample_format_view.append_column ("", sample_format_cols.label);
592 label_col = sample_format_view.get_column(0);
593 renderer = dynamic_cast<Gtk::CellRendererText*> (sample_format_view.get_column_cell_renderer (0));
594 label_col->add_attribute(renderer->property_foreground(), sample_format_cols.color);
596 dither_type_list = Gtk::ListStore::create (dither_type_cols);
597 dither_type_view.set_model (dither_type_list);
598 dither_type_view.set_headers_visible (false);
599 dither_type_view.append_column ("", dither_type_cols.label);
600 label_col = dither_type_view.get_column(0);
601 renderer = dynamic_cast<Gtk::CellRendererText*> (dither_type_view.get_column_cell_renderer (0));
602 label_col->add_attribute(renderer->property_foreground(), dither_type_cols.color);
607 ExportFormatDialog::update_compatibility_selection (std::string const & path)
610 Gtk::TreeModel::iterator iter = compatibility_view.get_model ()->get_iter (path);
611 ExportFormatCompatibilityPtr ptr = iter->get_value (compatibility_cols.ptr);
612 bool state = iter->get_value (compatibility_cols.selected);
614 iter->set_value (compatibility_cols.selected, state);
615 ptr->set_selected (state);
620 ExportFormatDialog::update_quality_selection ()
622 update_selection<QualityCols> (quality_list, quality_view, quality_cols);
626 ExportFormatDialog::update_format_selection ()
628 update_selection<FormatCols> (format_list, format_view, format_cols);
632 ExportFormatDialog::update_sample_rate_selection ()
634 update_selection<SampleRateCols> (sample_rate_list, sample_rate_view, sample_rate_cols);
638 ExportFormatDialog::update_sample_format_selection ()
640 update_selection<SampleFormatCols> (sample_format_list, sample_format_view, sample_format_cols);
644 ExportFormatDialog::update_dither_type_selection ()
646 update_selection<DitherTypeCols> (dither_type_list, dither_type_view, dither_type_cols);
649 template<typename ColsT>
651 ExportFormatDialog::update_selection (Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols)
653 if (applying_changes_from_engine) {
657 Gtk::ListStore::Children::iterator it;
658 Glib::RefPtr<Gtk::TreeSelection> selection = view.get_selection();
660 for (it = list->children().begin(); it != list->children().end(); ++it) {
661 bool selected = selection->is_selected (it);
662 it->get_value (cols.ptr)->set_selected (selected);
665 set_codec_quality_selection ();
669 ExportFormatDialog::change_compatibility_selection (bool select, WeakCompatPtr compat)
671 ++applying_changes_from_engine;
673 ExportFormatCompatibilityPtr ptr = compat.lock();
675 for (Gtk::ListStore::Children::iterator it = compatibility_list->children().begin(); it != compatibility_list->children().end(); ++it) {
676 if (it->get_value (compatibility_cols.ptr) == ptr) {
677 it->set_value (compatibility_cols.selected, select);
682 --applying_changes_from_engine;
686 ExportFormatDialog::change_quality_selection (bool select, WeakQualityPtr quality)
688 change_selection<ExportFormatManager::QualityState, QualityCols> (select, quality, quality_list, quality_view, quality_cols);
692 ExportFormatDialog::change_format_selection (bool select, WeakFormatPtr format)
694 change_selection<ExportFormat, FormatCols> (select, format, format_list, format_view, format_cols);
696 ExportFormatPtr ptr = format.lock();
699 change_encoding_options (ptr);
704 ExportFormatDialog::change_sample_rate_selection (bool select, WeakSampleRatePtr rate)
706 change_selection<ExportFormatManager::SampleRateState, SampleRateCols> (select, rate, sample_rate_list, sample_rate_view, sample_rate_cols);
709 ExportFormatManager::SampleRatePtr ptr = rate.lock();
710 if (ptr && _session) {
711 src_quality_combo.set_sensitive ((uint32_t) ptr->rate != _session->sample_rate());
717 ExportFormatDialog::change_sample_format_selection (bool select, WeakSampleFormatPtr format)
719 change_selection<HasSampleFormat::SampleFormatState, SampleFormatCols> (select, format, sample_format_list, sample_format_view, sample_format_cols);
723 ExportFormatDialog::change_dither_type_selection (bool select, WeakDitherTypePtr type)
725 change_selection<HasSampleFormat::DitherTypeState, DitherTypeCols> (select, type, dither_type_list, dither_type_view, dither_type_cols);
728 template<typename T, typename ColsT>
730 ExportFormatDialog::change_selection (bool select, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols)
732 ++applying_changes_from_engine;
734 boost::shared_ptr<T> ptr = w_ptr.lock();
736 Gtk::ListStore::Children::iterator it;
737 Glib::RefPtr<Gtk::TreeSelection> selection;
739 selection = view.get_selection();
742 selection->unselect_all();
744 for (it = list->children().begin(); it != list->children().end(); ++it) {
745 if (it->get_value (cols.ptr) == ptr) {
747 selection->select (it);
749 selection->unselect (it);
756 --applying_changes_from_engine;
760 ExportFormatDialog::change_quality_compatibility (bool compatibility, WeakQualityPtr quality)
762 change_compatibility<ExportFormatManager::QualityState, QualityCols> (compatibility, quality, quality_list, quality_cols);
766 ExportFormatDialog::change_format_compatibility (bool compatibility, WeakFormatPtr format)
768 change_compatibility<ExportFormat, FormatCols> (compatibility, format, format_list, format_cols);
772 ExportFormatDialog::change_sample_rate_compatibility (bool compatibility, WeakSampleRatePtr rate)
774 change_compatibility<ExportFormatManager::SampleRateState, SampleRateCols> (compatibility, rate, sample_rate_list, sample_rate_cols);
778 ExportFormatDialog::change_sample_format_compatibility (bool compatibility, WeakSampleFormatPtr format)
780 change_compatibility<HasSampleFormat::SampleFormatState, SampleFormatCols> (compatibility, format, sample_format_list, sample_format_cols);
784 ExportFormatDialog::change_dither_type_compatibility (bool compatibility, WeakDitherTypePtr type)
786 change_compatibility<HasSampleFormat::DitherTypeState, DitherTypeCols> (compatibility, type, dither_type_list, dither_type_cols, "red");
789 template<typename T, typename ColsT>
791 ExportFormatDialog::change_compatibility (bool compatibility, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, ColsT & cols,
792 std::string const & c_incompatible, std::string const & c_compatible)
794 boost::shared_ptr<T> ptr = w_ptr.lock();
796 Gtk::ListStore::Children::iterator it;
797 for (it = list->children().begin(); it != list->children().end(); ++it) {
798 if (it->get_value (cols.ptr) == ptr) {
799 it->set_value (cols.color, compatibility ? c_compatible : c_incompatible);
806 ExportFormatDialog::update_with_cue ()
808 manager.select_with_cue (with_cue.get_active());
812 ExportFormatDialog::update_with_toc ()
814 manager.select_with_toc (with_toc.get_active());
818 ExportFormatDialog::update_with_mp4chaps ()
820 manager.select_with_mp4chaps (with_mp4chaps.get_active());
824 ExportFormatDialog::update_command ()
826 manager.set_command (command_entry.get_text());
830 ExportFormatDialog::update_description()
832 std::string text = ": " + format->description(false);
833 name_generated_part.set_text(text);
837 ExportFormatDialog::update_name ()
839 manager.set_name (name_entry.get_text());
843 ExportFormatDialog::update_trim_start_selection ()
845 manager.select_trim_beginning (trim_start_checkbox.get_active());
849 ExportFormatDialog::update_trim_end_selection ()
851 manager.select_trim_end (trim_end_checkbox.get_active());
855 ExportFormatDialog::update_normalize_sensitivity ()
857 bool en = normalize_checkbox.get_active();
858 bool loudness = normalize_loudness_rb.get_active();
859 normalize_dbfs_spinbutton.set_sensitive (!loudness && en);
860 normalize_lufs_spinbutton.set_sensitive (loudness && en);
861 normalize_dbtp_spinbutton.set_sensitive (loudness && en);
865 ExportFormatDialog::update_normalize_selection ()
867 manager.select_normalize (normalize_checkbox.get_active());
868 manager.select_normalize_loudness (normalize_loudness_rb.get_active());
869 manager.select_normalize_dbfs (normalize_dbfs_spinbutton.get_value ());
870 manager.select_normalize_lufs (normalize_lufs_spinbutton.get_value ());
871 manager.select_normalize_dbtp (normalize_dbtp_spinbutton.get_value ());
872 update_normalize_sensitivity ();
876 ExportFormatDialog::update_silence_start_selection ()
878 update_time (silence_start, silence_start_clock);
880 zero.type = AnyTime::Timecode;
881 manager.select_silence_beginning (silence_start_checkbox.get_active() ? silence_start : zero);
885 ExportFormatDialog::update_silence_end_selection ()
887 update_time (silence_end, silence_end_clock);
889 zero.type = AnyTime::Timecode;
890 manager.select_silence_end (silence_end_checkbox.get_active() ? silence_end : zero);
894 ExportFormatDialog::update_clock (AudioClock & clock, ARDOUR::AnyTime const & time)
897 clock.set (_session->convert_to_samples (time), true);
899 AudioClock::Mode mode(AudioClock::Timecode);
902 case AnyTime::Timecode:
903 mode = AudioClock::Timecode;
906 mode = AudioClock::BBT;
908 case AnyTime::Samples:
909 mode = AudioClock::Samples;
911 case AnyTime::Seconds:
912 mode = AudioClock::MinSec;
916 clock.set_mode (mode);
920 ExportFormatDialog::update_time (AnyTime & time, AudioClock const & clock)
926 samplecnt_t samples = clock.current_duration();
928 switch (clock.mode()) {
929 case AudioClock::Timecode:
930 time.type = AnyTime::Timecode;
931 _session->timecode_time (samples, time.timecode);
933 case AudioClock::BBT:
934 time.type = AnyTime::BBT;
935 _session->bbt_time (samples, time.bbt);
937 case AudioClock::Seconds:
938 case AudioClock::MinSec:
939 time.type = AnyTime::Seconds;
940 time.seconds = (double) samples / _session->sample_rate();
942 case AudioClock::Samples:
943 time.type = AnyTime::Samples;
944 time.samples = samples;
950 ExportFormatDialog::update_src_quality_selection ()
952 Gtk::TreeModel::const_iterator iter = src_quality_combo.get_active();
953 ExportFormatBase::SRCQuality quality = iter->get_value (src_quality_cols.id);
954 manager.select_src_quality (quality);
958 ExportFormatDialog::update_codec_quality_selection ()
960 Gtk::TreeModel::const_iterator iter = codec_quality_combo.get_active();
964 int quality = iter->get_value (codec_quality_cols.quality);
965 manager.select_codec_quality (quality);
969 ExportFormatDialog::update_tagging_selection ()
971 manager.select_tagging (tag_checkbox.get_active());
975 ExportFormatDialog::change_encoding_options (ExportFormatPtr ptr)
977 empty_encoding_option_table ();
979 boost::shared_ptr<ARDOUR::ExportFormatLinear> linear_ptr;
980 boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ogg_ptr;
981 boost::shared_ptr<ARDOUR::ExportFormatFLAC> flac_ptr;
982 boost::shared_ptr<ARDOUR::ExportFormatBWF> bwf_ptr;
983 boost::shared_ptr<ARDOUR::ExportFormatFFMPEG> ffmpeg_ptr;
985 if ((linear_ptr = boost::dynamic_pointer_cast<ExportFormatLinear> (ptr))) {
986 show_linear_enconding_options (linear_ptr);
987 } else if ((ogg_ptr = boost::dynamic_pointer_cast<ExportFormatOggVorbis> (ptr))) {
988 show_ogg_enconding_options (ogg_ptr);
989 } else if ((flac_ptr = boost::dynamic_pointer_cast<ExportFormatFLAC> (ptr))) {
990 show_flac_enconding_options (flac_ptr);
991 } else if ((bwf_ptr = boost::dynamic_pointer_cast<ExportFormatBWF> (ptr))) {
992 show_bwf_enconding_options (bwf_ptr);
993 } else if ((ffmpeg_ptr = boost::dynamic_pointer_cast<ExportFormatFFMPEG> (ptr))) {
994 show_ffmpeg_enconding_options (ffmpeg_ptr);
996 std::cout << "Unrecognized format!" << std::endl;
1001 ExportFormatDialog::empty_encoding_option_table ()
1003 encoding_options_table.foreach (sigc::bind (sigc::mem_fun (*this, &ExportFormatDialog::remove_widget), &encoding_options_table));
1007 ExportFormatDialog::remove_widget (Gtk::Widget & to_remove, Gtk::Container * remove_from)
1009 remove_from->remove (to_remove);
1013 ExportFormatDialog::show_linear_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatLinear> ptr)
1015 /* Set label and pack table */
1017 encoding_options_label.set_label (_("Linear encoding options"));
1019 encoding_options_table.resize (2, 2);
1020 encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
1021 encoding_options_table.attach (dither_label, 1, 2, 0, 1);
1022 encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
1023 encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
1025 fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
1027 show_all_children ();
1031 ExportFormatDialog::show_ogg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ptr)
1033 encoding_options_label.set_label (_("Ogg Vorbis options"));
1035 encoding_options_table.resize (2, 1);
1036 encoding_options_table.attach (codec_quality_combo, 0, 1, 0, 1);
1037 encoding_options_table.attach (tag_checkbox, 0, 1, 1, 2);
1038 fill_codec_quality_lists (ptr);
1039 show_all_children ();
1043 ExportFormatDialog::show_flac_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFLAC> ptr)
1045 encoding_options_label.set_label (_("FLAC options"));
1047 encoding_options_table.resize (3, 2);
1048 encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
1049 encoding_options_table.attach (dither_label, 1, 2, 0, 1);
1050 encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
1051 encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
1052 encoding_options_table.attach (tag_checkbox, 0, 2, 2, 3);
1054 fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
1056 show_all_children ();
1060 ExportFormatDialog::show_bwf_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatBWF> ptr)
1062 encoding_options_label.set_label (_("Broadcast Wave options"));
1064 encoding_options_table.resize (2, 2);
1065 encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
1066 encoding_options_table.attach (dither_label, 1, 2, 0, 1);
1067 encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
1068 encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
1070 fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
1072 show_all_children ();
1076 ExportFormatDialog::show_ffmpeg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFFMPEG> ptr)
1078 encoding_options_label.set_label (_("FFMPEG/MP3 options"));
1079 encoding_options_table.resize (1, 1);
1080 encoding_options_table.attach (codec_quality_combo, 0, 1, 0, 1);
1081 fill_codec_quality_lists (ptr);
1082 show_all_children ();
1086 ExportFormatDialog::fill_sample_format_lists (boost::shared_ptr<ARDOUR::HasSampleFormat> ptr)
1090 Gtk::TreeModel::iterator iter;
1091 Gtk::TreeModel::Row row;
1093 sample_format_list->clear ();
1095 HasSampleFormat::SampleFormatList const & formats = ptr->get_sample_formats ();
1097 for (HasSampleFormat::SampleFormatList::const_iterator it = formats.begin(); it != formats.end(); ++it) {
1098 iter = sample_format_list->append();
1101 row[sample_format_cols.ptr] = *it;
1102 row[sample_format_cols.color] = (*it)->compatible() ? "white" : "red";
1103 row[sample_format_cols.label] = (*it)->name();
1105 if ((*it)->selected()) {
1106 sample_format_view.get_selection()->select (iter);
1110 dither_type_list->clear ();
1112 HasSampleFormat::DitherTypeList const & types = ptr->get_dither_types ();
1114 for (HasSampleFormat::DitherTypeList::const_iterator it = types.begin(); it != types.end(); ++it) {
1115 iter = dither_type_list->append();
1118 row[dither_type_cols.ptr] = *it;
1119 row[dither_type_cols.color] = "white";
1120 row[dither_type_cols.label] = (*it)->name();
1122 if ((*it)->selected()) {
1123 dither_type_view.get_selection()->select (iter);
1129 ExportFormatDialog::fill_codec_quality_lists (boost::shared_ptr<ARDOUR::HasCodecQuality> ptr)
1131 HasCodecQuality::CodecQualityList const & codecs = ptr->get_codec_qualities();
1133 codec_quality_list->clear();
1134 for (HasCodecQuality::CodecQualityList::const_iterator it = codecs.begin(); it != codecs.end(); ++it) {
1136 Gtk::TreeModel::iterator iter = codec_quality_list->append();
1137 Gtk::TreeModel::Row row = *iter;
1138 row[codec_quality_cols.quality] = (*it)->quality;
1139 row[codec_quality_cols.label] = (*it)->name;
1141 set_codec_quality_selection ();
1145 ExportFormatDialog::set_codec_quality_selection ()
1147 for (Gtk::ListStore::Children::iterator it = codec_quality_list->children().begin(); it != codec_quality_list->children().end(); ++it) {
1148 if (it->get_value (codec_quality_cols.quality) == format->codec_quality()) {
1149 codec_quality_combo.set_active (it);
1156 ExportFormatDialog::end_dialog ()
1162 ExportFormatDialog::prohibit_compatibility_selection ()
1164 compatibility_select_connection.block (true);
1165 compatibility_view.get_selection()->unselect_all ();
1166 compatibility_select_connection.block (false);