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"
28 using namespace ARDOUR;
30 ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
31 ArdourDialog (new_dialog ? _("New Export Format Profile") : _("Edit Export Format Profile")),
34 original_state (format->get_state()),
36 applying_changes_from_engine (0),
38 name_label (_("Label: "), Gtk::ALIGN_LEFT),
40 normalize_checkbox (_("Normalize to:")),
41 normalize_adjustment (0.00, -90.00, 0.00, 0.1, 0.2),
42 normalize_db_label (_("dBFS"), Gtk::ALIGN_LEFT),
45 trim_start_checkbox (_("Trim silence at start")),
46 silence_start_checkbox (_("Add silence at start:")),
47 silence_start_clock ("silence_start", true, "", true, false, true),
49 trim_end_checkbox (_("Trim silence at end")),
50 silence_end_checkbox (_("Add silence at end:")),
51 silence_end_clock ("silence_end", true, "", true, false, true),
54 compatibility_label (_("Compatibility"), Gtk::ALIGN_LEFT),
55 quality_label (_("Quality"), Gtk::ALIGN_LEFT),
56 format_label (_("File format"), Gtk::ALIGN_LEFT),
57 sample_rate_label (_("Sample rate"), Gtk::ALIGN_LEFT),
58 src_quality_label (_("Sample rate conversion quality:"), Gtk::ALIGN_RIGHT),
60 encoding_options_label ("", Gtk::ALIGN_LEFT),
62 /* Changing encoding options from here on */
64 sample_format_label (_("Sample Format"), Gtk::ALIGN_LEFT),
65 dither_label (_("Dithering"), Gtk::ALIGN_LEFT),
67 with_cue (_("Create CUE file for disk-at-once CD/DVD creation")),
68 with_toc (_("Create TOC file for disk-at-once CD/DVD creation")),
70 tag_checkbox (_("Tag file with session's metadata"))
73 /* Pack containers in dialog */
75 get_vbox()->pack_start (name_hbox, false, false, 0);
76 get_vbox()->pack_start (silence_table, false, false, 6);
77 get_vbox()->pack_start (format_table, false, false, 6);
78 get_vbox()->pack_start (encoding_options_vbox, false, false, 0);
79 get_vbox()->pack_start (cue_toc_vbox, false, false, 0);
81 /* Name, new and remove */
83 name_hbox.pack_start (name_label, false, false, 0);
84 name_hbox.pack_start (name_entry, true, true, 0);
88 normalize_hbox.pack_start (normalize_checkbox, false, false, 0);
89 normalize_hbox.pack_start (normalize_spinbutton, false, false, 6);
90 normalize_hbox.pack_start (normalize_db_label, false, false, 0);
92 normalize_spinbutton.configure (normalize_adjustment, 0.1, 2);
96 silence_table.set_row_spacings (6);
97 silence_table.set_col_spacings (12);
99 silence_table.attach (normalize_hbox, 0, 3, 0, 1);
101 silence_table.attach (trim_start_checkbox, 0, 1, 1, 2);
102 silence_table.attach (silence_start_checkbox, 1, 2, 1, 2);
103 silence_table.attach (silence_start_clock, 2, 3, 1, 2);
105 silence_table.attach (trim_end_checkbox, 0, 1, 2, 3);
106 silence_table.attach (silence_end_checkbox, 1, 2, 2, 3);
107 silence_table.attach (silence_end_clock, 2, 3, 2, 3);
113 /* Encoding options */
115 init_encoding_option_widgets();
117 encoding_options_table.set_spacings (1);
119 encoding_options_vbox.pack_start (encoding_options_label, false, false, 0);
120 encoding_options_vbox.pack_start (encoding_options_table, false, false, 12);
122 Pango::AttrList bold;
123 Pango::Attribute b = Pango::Attribute::create_attr_weight (Pango::WEIGHT_BOLD);
125 encoding_options_label.set_attributes (bold);
129 revert_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
130 revert_button->signal_clicked().connect (sigc::mem_fun(*this, &ExportFormatDialog::revert));
131 close_button = add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_APPLY);
132 close_button->set_sensitive (false);
133 close_button->signal_clicked().connect (sigc::mem_fun (*this, &ExportFormatDialog::end_dialog));
134 manager.CompleteChanged.connect (*this, invalidator (*this), ui_bind (&Gtk::Button::set_sensitive, close_button, _1), gui_context());
136 with_cue.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_cue));
137 with_toc.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_toc));
139 cue_toc_vbox.pack_start (with_cue, false, false);
140 cue_toc_vbox.pack_start (with_toc, false, false);
142 /* Load state before hooking up the rest of the signals */
148 name_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_name));
150 /* Normalize, silence and src_quality signals */
152 trim_start_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_trim_start_selection));
153 trim_end_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_trim_end_selection));
155 normalize_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
156 normalize_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
158 silence_start_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
159 silence_start_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
161 silence_end_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
162 silence_end_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
164 src_quality_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_src_quality_selection));
166 /* Format table signals */
168 Gtk::CellRendererToggle *toggle = dynamic_cast<Gtk::CellRendererToggle *>(compatibility_view.get_column_cell_renderer (0));
169 toggle->signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_compatibility_selection));
170 compatibility_select_connection = compatibility_view.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::prohibit_compatibility_selection));
172 quality_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_quality_selection));
173 format_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_format_selection));
174 sample_rate_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_sample_rate_selection));
176 /* Encoding option signals */
178 sample_format_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_sample_format_selection));
179 dither_type_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_dither_type_selection));
181 tag_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_tagging_selection));
188 ExportFormatDialog::~ExportFormatDialog ()
194 ExportFormatDialog::revert ()
196 ++applying_changes_from_engine;
198 format->set_state (original_state);
201 --applying_changes_from_engine;
205 ExportFormatDialog::set_session (ARDOUR::Session* s)
207 SessionHandlePtr::set_session (s);
208 silence_start_clock.set_session (s);
209 silence_end_clock.set_session (s);
215 update_clock (silence_start_clock, silence_start);
216 update_clock (silence_end_clock, silence_end);
218 /* Select native samplerate if no selection is yet made */
220 if (sample_rate_view.get_selection()->count_selected_rows() == 0) {
221 Gtk::ListStore::Children::iterator it;
222 for (it = sample_rate_list->children().begin(); it != sample_rate_list->children().end(); ++it) {
223 if ((framecnt_t) (*it)->get_value (sample_rate_cols.ptr)->rate == _session->nominal_frame_rate()) {
224 sample_rate_view.get_selection()->select (it);
232 ExportFormatDialog::load_state (FormatPtr spec)
234 name_entry.set_text (spec->name());
236 normalize_checkbox.set_active (spec->normalize());
237 normalize_spinbutton.set_value (spec->normalize_target());
239 trim_start_checkbox.set_active (spec->trim_beginning());
240 silence_start = spec->silence_beginning_time();
241 silence_start_checkbox.set_active (spec->silence_beginning_time().not_zero());
243 trim_end_checkbox.set_active (spec->trim_end());
244 silence_end = spec->silence_end_time();
245 silence_end_checkbox.set_active (spec->silence_end_time().not_zero());
247 with_cue.set_active (spec->with_cue());
248 with_toc.set_active (spec->with_toc());
250 for (Gtk::ListStore::Children::iterator it = src_quality_list->children().begin(); it != src_quality_list->children().end(); ++it) {
251 if (it->get_value (src_quality_cols.id) == spec->src_quality()) {
252 src_quality_combo.set_active (it);
257 for (Gtk::ListStore::Children::iterator it = format_list->children().begin(); it != format_list->children().end(); ++it) {
258 boost::shared_ptr<ARDOUR::ExportFormat> format_in_list = it->get_value (format_cols.ptr);
259 if (format_in_list->get_format_id() == spec->format_id() &&
260 // BWF has the same format id with wav, so we need to check this.
261 format_in_list->has_broadcast_info() == spec->has_broadcast_info()) {
263 format_in_list->set_selected (true);
268 for (Gtk::ListStore::Children::iterator it = sample_rate_list->children().begin(); it != sample_rate_list->children().end(); ++it) {
269 if (it->get_value (sample_rate_cols.ptr)->rate == spec->sample_rate()) {
270 it->get_value (sample_rate_cols.ptr)->set_selected (true);
275 if (spec->sample_format()) {
276 for (Gtk::ListStore::Children::iterator it = sample_format_list->children().begin(); it != sample_format_list->children().end(); ++it) {
277 if (it->get_value (sample_format_cols.ptr)->format == spec->sample_format()) {
278 it->get_value (sample_format_cols.ptr)->set_selected (true);
283 for (Gtk::ListStore::Children::iterator it = dither_type_list->children().begin(); it != dither_type_list->children().end(); ++it) {
284 if (it->get_value (dither_type_cols.ptr)->type == spec->dither_type()) {
285 it->get_value (dither_type_cols.ptr)->set_selected (true);
291 tag_checkbox.set_active (spec->tag());
295 ExportFormatDialog::init_format_table ()
298 format_table.set_spacings (1);
300 format_table.attach (compatibility_label, 0, 1, 0, 1);
301 format_table.attach (quality_label, 1, 2, 0, 1);
302 format_table.attach (format_label, 2, 3, 0, 1);
303 format_table.attach (sample_rate_label, 3, 4, 0, 1);
305 format_table.attach (compatibility_view, 0, 1, 1, 2);
306 format_table.attach (quality_view, 1, 2, 1, 2);
307 format_table.attach (format_view, 2, 3, 1, 2);
308 format_table.attach (sample_rate_view, 3, 4, 1, 2);
310 format_table.attach (src_quality_label, 0, 3, 2, 3);
311 format_table.attach (src_quality_combo, 3, 4, 2, 3);
313 compatibility_view.set_headers_visible (false);
314 quality_view.set_headers_visible (false);
315 format_view.set_headers_visible (false);
316 sample_rate_view.set_headers_visible (false);
318 /*** Table entries ***/
320 Gtk::TreeModel::iterator iter;
321 Gtk::TreeModel::Row row;
323 /* Compatibilities */
325 compatibility_list = Gtk::ListStore::create (compatibility_cols);
326 compatibility_view.set_model (compatibility_list);
328 ExportFormatManager::CompatList const & compat_list = manager.get_compatibilities();
330 for (ExportFormatManager::CompatList::const_iterator it = compat_list.begin(); it != compat_list.end(); ++it) {
331 iter = compatibility_list->append();
334 row[compatibility_cols.ptr] = *it;
335 row[compatibility_cols.selected] = false;
336 row[compatibility_cols.label] = (*it)->name();
338 WeakCompatPtr ptr (*it);
339 (*it)->SelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_compatibility_selection, this, _1, ptr), gui_context());
342 compatibility_view.append_column_editable ("", compatibility_cols.selected);
344 Gtk::CellRendererText* text_renderer = Gtk::manage (new Gtk::CellRendererText);
345 text_renderer->property_editable() = false;
347 Gtk::TreeView::Column* column = compatibility_view.get_column (0);
348 column->pack_start (*text_renderer);
349 column->add_attribute (text_renderer->property_text(), compatibility_cols.label);
353 quality_list = Gtk::ListStore::create (quality_cols);
354 quality_view.set_model (quality_list);
356 ExportFormatManager::QualityList const & qualities = manager.get_qualities ();
358 for (ExportFormatManager::QualityList::const_iterator it = qualities.begin(); it != qualities.end(); ++it) {
359 iter = quality_list->append();
362 row[quality_cols.ptr] = *it;
363 row[quality_cols.color] = "white";
364 row[quality_cols.label] = (*it)->name();
366 WeakQualityPtr ptr (*it);
367 (*it)->SelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_quality_selection, this, _1, ptr), gui_context());
368 (*it)->CompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_quality_compatibility, this, _1, ptr), gui_context());
371 quality_view.append_column ("", quality_cols.label);
375 format_list = Gtk::ListStore::create (format_cols);
376 format_view.set_model (format_list);
378 ExportFormatManager::FormatList const & formats = manager.get_formats ();
380 for (ExportFormatManager::FormatList::const_iterator it = formats.begin(); it != formats.end(); ++it) {
381 iter = format_list->append();
384 row[format_cols.ptr] = *it;
385 row[format_cols.color] = "white";
386 row[format_cols.label] = (*it)->name();
388 WeakFormatPtr ptr (*it);
389 (*it)->SelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_format_selection, this, _1, ptr), gui_context());
390 (*it)->CompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_format_compatibility, this, _1, ptr), gui_context());
392 /* Encoding options */
394 boost::shared_ptr<HasSampleFormat> hsf;
396 if (hsf = boost::dynamic_pointer_cast<HasSampleFormat> (*it)) {
397 hsf->SampleFormatSelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_sample_format_selection, this, _1, _2), gui_context());
398 hsf->SampleFormatCompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_sample_format_compatibility, this, _1, _2), gui_context());
400 hsf->DitherTypeSelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_dither_type_selection, this, _1, _2), gui_context());
401 hsf->DitherTypeCompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_dither_type_compatibility, this, _1, _2), gui_context());
405 format_view.append_column ("", format_cols.label);
409 sample_rate_list = Gtk::ListStore::create (sample_rate_cols);
410 sample_rate_view.set_model (sample_rate_list);
412 ExportFormatManager::SampleRateList const & rates = manager.get_sample_rates ();
414 for (ExportFormatManager::SampleRateList::const_iterator it = rates.begin(); it != rates.end(); ++it) {
415 iter = sample_rate_list->append();
418 row[sample_rate_cols.ptr] = *it;
419 row[sample_rate_cols.color] = "white";
420 row[sample_rate_cols.label] = (*it)->name();
422 WeakSampleRatePtr ptr (*it);
423 (*it)->SelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_sample_rate_selection, this, _1, ptr), gui_context());
424 (*it)->CompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_sample_rate_compatibility, this, _1, ptr), gui_context());
427 sample_rate_view.append_column ("", sample_rate_cols.label);
429 /* Color rendering */
431 Gtk::TreeViewColumn * label_col;
432 Gtk::CellRendererText * renderer;
434 label_col = quality_view.get_column(0);
435 renderer = dynamic_cast<Gtk::CellRendererText*> (quality_view.get_column_cell_renderer (0));
436 label_col->add_attribute(renderer->property_foreground(), quality_cols.color);
438 label_col = format_view.get_column(0);
439 renderer = dynamic_cast<Gtk::CellRendererText*> (format_view.get_column_cell_renderer (0));
440 label_col->add_attribute(renderer->property_foreground(), format_cols.color);
442 label_col = sample_rate_view.get_column(0);
443 renderer = dynamic_cast<Gtk::CellRendererText*> (sample_rate_view.get_column_cell_renderer (0));
444 label_col->add_attribute(renderer->property_foreground(), sample_rate_cols.color);
448 src_quality_list = Gtk::ListStore::create (src_quality_cols);
449 src_quality_combo.set_model (src_quality_list);
451 iter = src_quality_list->append();
453 row[src_quality_cols.id] = ExportFormatBase::SRC_SincBest;
454 row[src_quality_cols.label] = _("Best (sinc)");
456 iter = src_quality_list->append();
458 row[src_quality_cols.id] = ExportFormatBase::SRC_SincMedium;
459 row[src_quality_cols.label] = _("Medium (sinc)");
461 iter = src_quality_list->append();
463 row[src_quality_cols.id] = ExportFormatBase::SRC_SincFast;
464 row[src_quality_cols.label] = _("Fast (sinc)");
466 iter = src_quality_list->append();
468 row[src_quality_cols.id] = ExportFormatBase::SRC_Linear;
469 row[src_quality_cols.label] = _("Linear");
471 iter = src_quality_list->append();
473 row[src_quality_cols.id] = ExportFormatBase::SRC_ZeroOrderHold;
474 row[src_quality_cols.label] = _("Zero order hold");
476 src_quality_combo.pack_start (src_quality_cols.label);
477 src_quality_combo.set_active (0);
481 ExportFormatDialog::init_encoding_option_widgets ()
483 Gtk::TreeViewColumn * label_col;
484 Gtk::CellRendererText * renderer;
486 sample_format_list = Gtk::ListStore::create (sample_format_cols);
487 sample_format_view.set_model (sample_format_list);
488 sample_format_view.set_headers_visible (false);
489 sample_format_view.append_column ("", sample_format_cols.label);
490 label_col = sample_format_view.get_column(0);
491 renderer = dynamic_cast<Gtk::CellRendererText*> (sample_format_view.get_column_cell_renderer (0));
492 label_col->add_attribute(renderer->property_foreground(), sample_format_cols.color);
494 dither_type_list = Gtk::ListStore::create (dither_type_cols);
495 dither_type_view.set_model (dither_type_list);
496 dither_type_view.set_headers_visible (false);
497 dither_type_view.append_column ("", dither_type_cols.label);
498 label_col = dither_type_view.get_column(0);
499 renderer = dynamic_cast<Gtk::CellRendererText*> (dither_type_view.get_column_cell_renderer (0));
500 label_col->add_attribute(renderer->property_foreground(), dither_type_cols.color);
505 ExportFormatDialog::update_compatibility_selection (std::string const & path)
508 Gtk::TreeModel::iterator iter = compatibility_view.get_model ()->get_iter (path);
509 ExportFormatCompatibilityPtr ptr = iter->get_value (compatibility_cols.ptr);
510 bool state = iter->get_value (compatibility_cols.selected);
512 iter->set_value (compatibility_cols.selected, state);
513 ptr->set_selected (state);
518 ExportFormatDialog::update_quality_selection ()
520 update_selection<QualityCols> (quality_list, quality_view, quality_cols);
524 ExportFormatDialog::update_format_selection ()
526 update_selection<FormatCols> (format_list, format_view, format_cols);
530 ExportFormatDialog::update_sample_rate_selection ()
532 update_selection<SampleRateCols> (sample_rate_list, sample_rate_view, sample_rate_cols);
536 ExportFormatDialog::update_sample_format_selection ()
538 update_selection<SampleFormatCols> (sample_format_list, sample_format_view, sample_format_cols);
542 ExportFormatDialog::update_dither_type_selection ()
544 update_selection<DitherTypeCols> (dither_type_list, dither_type_view, dither_type_cols);
547 template<typename ColsT>
549 ExportFormatDialog::update_selection (Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols)
551 if (applying_changes_from_engine) {
555 Gtk::ListStore::Children::iterator it;
556 Glib::RefPtr<Gtk::TreeSelection> selection = view.get_selection();
558 for (it = list->children().begin(); it != list->children().end(); ++it) {
559 bool selected = selection->is_selected (it);
560 it->get_value (cols.ptr)->set_selected (selected);
565 ExportFormatDialog::change_compatibility_selection (bool select, WeakCompatPtr compat)
567 ++applying_changes_from_engine;
569 ExportFormatCompatibilityPtr ptr = compat.lock();
571 for (Gtk::ListStore::Children::iterator it = compatibility_list->children().begin(); it != compatibility_list->children().end(); ++it) {
572 if (it->get_value (compatibility_cols.ptr) == ptr) {
573 it->set_value (compatibility_cols.selected, select);
578 --applying_changes_from_engine;
582 ExportFormatDialog::change_quality_selection (bool select, WeakQualityPtr quality)
584 change_selection<ExportFormatManager::QualityState, QualityCols> (select, quality, quality_list, quality_view, quality_cols);
588 ExportFormatDialog::change_format_selection (bool select, WeakFormatPtr format)
590 change_selection<ExportFormat, FormatCols> (select, format, format_list, format_view, format_cols);
592 ExportFormatPtr ptr = format.lock();
595 change_encoding_options (ptr);
600 ExportFormatDialog::change_sample_rate_selection (bool select, WeakSampleRatePtr rate)
602 change_selection<ExportFormatManager::SampleRateState, SampleRateCols> (select, rate, sample_rate_list, sample_rate_view, sample_rate_cols);
605 ExportFormatManager::SampleRatePtr ptr = rate.lock();
606 if (ptr && _session) {
607 src_quality_combo.set_sensitive ((uint32_t) ptr->rate != _session->frame_rate());
613 ExportFormatDialog::change_sample_format_selection (bool select, WeakSampleFormatPtr format)
615 change_selection<HasSampleFormat::SampleFormatState, SampleFormatCols> (select, format, sample_format_list, sample_format_view, sample_format_cols);
619 ExportFormatDialog::change_dither_type_selection (bool select, WeakDitherTypePtr type)
621 change_selection<HasSampleFormat::DitherTypeState, DitherTypeCols> (select, type, dither_type_list, dither_type_view, dither_type_cols);
624 template<typename T, typename ColsT>
626 ExportFormatDialog::change_selection (bool select, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols)
628 ++applying_changes_from_engine;
630 boost::shared_ptr<T> ptr = w_ptr.lock();
632 Gtk::ListStore::Children::iterator it;
633 Glib::RefPtr<Gtk::TreeSelection> selection;
635 selection = view.get_selection();
638 selection->unselect_all();
640 for (it = list->children().begin(); it != list->children().end(); ++it) {
641 if (it->get_value (cols.ptr) == ptr) {
643 selection->select (it);
645 selection->unselect (it);
652 --applying_changes_from_engine;
656 ExportFormatDialog::change_quality_compatibility (bool compatibility, WeakQualityPtr quality)
658 change_compatibility<ExportFormatManager::QualityState, QualityCols> (compatibility, quality, quality_list, quality_cols);
662 ExportFormatDialog::change_format_compatibility (bool compatibility, WeakFormatPtr format)
664 change_compatibility<ExportFormat, FormatCols> (compatibility, format, format_list, format_cols);
668 ExportFormatDialog::change_sample_rate_compatibility (bool compatibility, WeakSampleRatePtr rate)
670 change_compatibility<ExportFormatManager::SampleRateState, SampleRateCols> (compatibility, rate, sample_rate_list, sample_rate_cols);
674 ExportFormatDialog::change_sample_format_compatibility (bool compatibility, WeakSampleFormatPtr format)
676 change_compatibility<HasSampleFormat::SampleFormatState, SampleFormatCols> (compatibility, format, sample_format_list, sample_format_cols);
680 ExportFormatDialog::change_dither_type_compatibility (bool compatibility, WeakDitherTypePtr type)
682 change_compatibility<HasSampleFormat::DitherTypeState, DitherTypeCols> (compatibility, type, dither_type_list, dither_type_cols, "red");
685 template<typename T, typename ColsT>
687 ExportFormatDialog::change_compatibility (bool compatibility, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, ColsT & cols,
688 std::string const & c_incompatible, std::string const & c_compatible)
690 boost::shared_ptr<T> ptr = w_ptr.lock();
692 Gtk::ListStore::Children::iterator it;
693 for (it = list->children().begin(); it != list->children().end(); ++it) {
694 if (it->get_value (cols.ptr) == ptr) {
695 it->set_value (cols.color, compatibility ? c_compatible : c_incompatible);
702 ExportFormatDialog::update_with_cue ()
704 manager.select_with_cue (with_cue.get_active());
708 ExportFormatDialog::update_with_toc ()
710 manager.select_with_toc (with_toc.get_active());
714 ExportFormatDialog::update_name ()
716 manager.set_name (name_entry.get_text());
720 ExportFormatDialog::update_trim_start_selection ()
722 manager.select_trim_beginning (trim_start_checkbox.get_active());
726 ExportFormatDialog::update_trim_end_selection ()
728 manager.select_trim_end (trim_end_checkbox.get_active());
732 ExportFormatDialog::update_normalize_selection ()
734 manager.select_normalize (normalize_checkbox.get_active());
735 manager.select_normalize_target (normalize_spinbutton.get_value ());
739 ExportFormatDialog::update_silence_start_selection ()
741 update_time (silence_start, silence_start_clock);
743 zero.type = AnyTime::Timecode;
744 manager.select_silence_beginning (silence_start_checkbox.get_active() ? silence_start : zero);
748 ExportFormatDialog::update_silence_end_selection ()
750 update_time (silence_end, silence_end_clock);
752 zero.type = AnyTime::Timecode;
753 manager.select_silence_end (silence_end_checkbox.get_active() ? silence_end : zero);
757 ExportFormatDialog::update_clock (AudioClock & clock, ARDOUR::AnyTime const & time)
760 clock.set (_session->convert_to_frames (time), true);
762 AudioClock::Mode mode(AudioClock::Timecode);
765 case AnyTime::Timecode:
766 mode = AudioClock::Timecode;
769 mode = AudioClock::BBT;
771 case AnyTime::Frames:
772 mode = AudioClock::Frames;
774 case AnyTime::Seconds:
775 mode = AudioClock::MinSec;
779 clock.set_mode (mode);
783 ExportFormatDialog::update_time (AnyTime & time, AudioClock const & clock)
789 framecnt_t frames = clock.current_duration();
791 switch (clock.mode()) {
792 case AudioClock::Timecode:
793 time.type = AnyTime::Timecode;
794 _session->timecode_time (frames, time.timecode);
796 case AudioClock::BBT:
797 time.type = AnyTime::BBT;
798 _session->bbt_time (frames, time.bbt);
800 case AudioClock::MinSec:
801 time.type = AnyTime::Seconds;
802 time.seconds = (double) frames / _session->frame_rate();
804 case AudioClock::Frames:
805 time.type = AnyTime::Frames;
806 time.frames = frames;
812 ExportFormatDialog::update_src_quality_selection ()
814 Gtk::TreeModel::const_iterator iter = src_quality_combo.get_active();
815 ExportFormatBase::SRCQuality quality = iter->get_value (src_quality_cols.id);
816 manager.select_src_quality (quality);
820 ExportFormatDialog::update_tagging_selection ()
822 manager.select_tagging (tag_checkbox.get_active());
826 ExportFormatDialog::change_encoding_options (ExportFormatPtr ptr)
828 empty_encoding_option_table ();
830 boost::shared_ptr<ARDOUR::ExportFormatLinear> linear_ptr;
831 boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ogg_ptr;
832 boost::shared_ptr<ARDOUR::ExportFormatFLAC> flac_ptr;
833 boost::shared_ptr<ARDOUR::ExportFormatBWF> bwf_ptr;
835 if (linear_ptr = boost::dynamic_pointer_cast<ExportFormatLinear> (ptr)) {
836 show_linear_enconding_options (linear_ptr);
837 } else if (ogg_ptr = boost::dynamic_pointer_cast<ExportFormatOggVorbis> (ptr)) {
838 show_ogg_enconding_options (ogg_ptr);
839 } else if (flac_ptr = boost::dynamic_pointer_cast<ExportFormatFLAC> (ptr)) {
840 show_flac_enconding_options (flac_ptr);
841 } else if (bwf_ptr = boost::dynamic_pointer_cast<ExportFormatBWF> (ptr)) {
842 show_bwf_enconding_options (bwf_ptr);
844 std::cout << "Unrecognized format!" << std::endl;
849 ExportFormatDialog::empty_encoding_option_table ()
851 encoding_options_table.foreach (sigc::bind (sigc::mem_fun (*this, &ExportFormatDialog::remove_widget), &encoding_options_table));
855 ExportFormatDialog::remove_widget (Gtk::Widget & to_remove, Gtk::Container * remove_from)
857 remove_from->remove (to_remove);
861 ExportFormatDialog::show_linear_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatLinear> ptr)
863 /* Set label and pack table */
865 encoding_options_label.set_label (_("Linear encoding options"));
867 encoding_options_table.resize (2, 2);
868 encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
869 encoding_options_table.attach (dither_label, 1, 2, 0, 1);
870 encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
871 encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
873 fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
875 show_all_children ();
879 ExportFormatDialog::show_ogg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> /*ptr*/)
881 encoding_options_label.set_label (_("Ogg Vorbis options"));
883 encoding_options_table.resize (1, 1);
884 encoding_options_table.attach (tag_checkbox, 0, 1, 0, 1);
886 update_tagging_selection ();
888 show_all_children ();
892 ExportFormatDialog::show_flac_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFLAC> ptr)
894 encoding_options_label.set_label (_("FLAC options"));
896 encoding_options_table.resize (3, 2);
897 encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
898 encoding_options_table.attach (dither_label, 1, 2, 0, 1);
899 encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
900 encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
901 encoding_options_table.attach (tag_checkbox, 0, 2, 2, 3);
903 fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
905 show_all_children ();
909 ExportFormatDialog::show_bwf_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatBWF> ptr)
911 encoding_options_label.set_label (_("Broadcast Wave options"));
913 encoding_options_table.resize (2, 2);
914 encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
915 encoding_options_table.attach (dither_label, 1, 2, 0, 1);
916 encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
917 encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
919 fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
921 show_all_children ();
925 ExportFormatDialog::fill_sample_format_lists (boost::shared_ptr<ARDOUR::HasSampleFormat> ptr)
929 Gtk::TreeModel::iterator iter;
930 Gtk::TreeModel::Row row;
932 sample_format_list->clear ();
934 HasSampleFormat::SampleFormatList const & formats = ptr->get_sample_formats ();
936 for (HasSampleFormat::SampleFormatList::const_iterator it = formats.begin(); it != formats.end(); ++it) {
937 iter = sample_format_list->append();
940 row[sample_format_cols.ptr] = *it;
941 row[sample_format_cols.color] = (*it)->compatible() ? "white" : "red";
942 row[sample_format_cols.label] = (*it)->name();
944 if ((*it)->selected()) {
945 sample_format_view.get_selection()->select (iter);
949 dither_type_list->clear ();
951 HasSampleFormat::DitherTypeList const & types = ptr->get_dither_types ();
953 for (HasSampleFormat::DitherTypeList::const_iterator it = types.begin(); it != types.end(); ++it) {
954 iter = dither_type_list->append();
957 row[dither_type_cols.ptr] = *it;
958 row[dither_type_cols.color] = "white";
959 row[dither_type_cols.label] = (*it)->name();
961 if ((*it)->selected()) {
962 dither_type_view.get_selection()->select (iter);
968 ExportFormatDialog::end_dialog ()
974 ExportFormatDialog::prohibit_compatibility_selection ()
976 compatibility_select_connection.block (true);
977 compatibility_view.get_selection()->unselect_all ();
978 compatibility_select_connection.block (false);