Enable Menu > Quit to work again after startup on macOS
[ardour.git] / gtk2_ardour / export_format_dialog.cc
index 89762be583521ff35c9506a404880bfcf2d850a3..48f8aa5aa4c25f6efda448dd0136e3cd6b8b185d 100644 (file)
@@ -1,29 +1,37 @@
 /*
-    Copyright (C) 2008 Paul Davis
-    Author: Sakari Bergen
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
+ * Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
+ * Copyright (C) 2009-2013 Sakari Bergen <sakari.bergen@beatwaves.net>
+ * Copyright (C) 2013-2014 Colin Fletcher <colin.m.fletcher@googlemail.com>
+ * Copyright (C) 2016-2019 Robin Gareus <robin@gareus.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gtkmm/stock.h>
 
 #include "ardour/session.h"
 #include "ardour/export_format_specification.h"
 
+#include "widgets/tooltips.h"
+
 #include "export_format_dialog.h"
 #include "gui_thread.h"
-#include "i18n.h"
+
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
 
@@ -36,19 +44,29 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
   applying_changes_from_engine (0),
 
   name_label (_("Label: "), Gtk::ALIGN_LEFT),
+  name_generated_part ("", Gtk::ALIGN_LEFT),
+
+  normalize_checkbox (_("Normalize:")),
+  normalize_peak_rb (_("Peak")),
+  normalize_loudness_rb (_("Loudness")),
+  normalize_dbfs_adjustment ( 0.00, -90.00, 0.00, 0.1, 0.2),
+  normalize_lufs_adjustment (-23.0, -90.00, 0.00, 0.1, 1.0),
+  normalize_dbtp_adjustment ( -1.0, -90.00, 0.00, 0.1, 0.2),
 
-  normalize_checkbox (_("Normalize to:")),
-  normalize_adjustment (0.00, -90.00, 0.00, 0.1, 0.2),
-  normalize_db_label (_("dBFS"), Gtk::ALIGN_LEFT),
+  normalize_dbfs_label (_("dBFS"), Gtk::ALIGN_LEFT),
+  normalize_lufs_label (_("LUFS"), Gtk::ALIGN_LEFT),
+  normalize_dbtp_label (_("dBTP"), Gtk::ALIGN_LEFT),
 
   silence_table (2, 4),
   trim_start_checkbox (_("Trim silence at start")),
   silence_start_checkbox (_("Add silence at start:")),
-  silence_start_clock ("silence_start", true, "PreRollClock", true, false, true),
+  silence_start_clock ("silence_start", true, "", true, false, true),
 
   trim_end_checkbox (_("Trim silence at end")),
   silence_end_checkbox (_("Add silence at end:")),
-  silence_end_clock ("silence_end", true, "PreRollClock", true, false, true),
+  silence_end_clock ("silence_end", true, "", true, false, true),
+
+  command_label(_("Command to run post-export\n(%f=file path, %d=directory, %b=basename, see tooltip for more):"), Gtk::ALIGN_LEFT),
 
   format_table (3, 4),
   compatibility_label (_("Compatibility"), Gtk::ALIGN_LEFT),
@@ -64,28 +82,57 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
   sample_format_label (_("Sample Format"), Gtk::ALIGN_LEFT),
   dither_label (_("Dithering"), Gtk::ALIGN_LEFT),
 
+  with_cue (_("Create CUE file for disk-at-once CD/DVD creation")),
+  with_toc (_("Create TOC file for disk-at-once CD/DVD creation")),
+  with_mp4chaps (_("Create chapter mark file for MP4 chapter marks")),
+
   tag_checkbox (_("Tag file with session's metadata"))
 {
 
        /* Pack containers in dialog */
 
-       get_vbox()->pack_start (name_hbox, false, false, 0);
        get_vbox()->pack_start (silence_table, false, false, 6);
        get_vbox()->pack_start (format_table, false, false, 6);
        get_vbox()->pack_start (encoding_options_vbox, false, false, 0);
+       get_vbox()->pack_start (cue_toc_vbox, false, false, 0);
+       get_vbox()->pack_start (name_hbox, false, false, 6);
 
        /* Name, new and remove */
 
        name_hbox.pack_start (name_label, false, false, 0);
-       name_hbox.pack_start (name_entry, true, true, 0);
+       name_hbox.pack_start (name_entry, false, false, 0);
+       name_hbox.pack_start (name_generated_part, true, true, 0);
+       name_entry.set_width_chars(20);
+       update_description();
+       manager.DescriptionChanged.connect(
+               *this, invalidator (*this),
+               boost::bind (&ExportFormatDialog::update_description, this), gui_context());
 
        /* Normalize */
 
-       normalize_hbox.pack_start (normalize_checkbox, false, false, 0);
-       normalize_hbox.pack_start (normalize_spinbutton, false, false, 6);
-       normalize_hbox.pack_start (normalize_db_label, false, false, 0);
+       Gtk::RadioButtonGroup normalize_group = normalize_loudness_rb.get_group();
+       normalize_peak_rb.set_group (normalize_group);
+
+       normalize_hbox.pack_start (normalize_checkbox, false, false, 2);
+       normalize_hbox.pack_start (normalize_peak_rb, false, false, 0);
+       normalize_hbox.pack_start (normalize_dbfs_spinbutton, false, false, 2);
+       normalize_hbox.pack_start (normalize_dbfs_label, false, false, 0);
 
-       normalize_spinbutton.configure (normalize_adjustment, 0.1, 2);
+       normalize_hbox.pack_start (*Gtk::manage (new Gtk::Label ("")), false, false, 6); // separator
+
+       normalize_hbox.pack_start (normalize_loudness_rb, false, false, 0);
+       normalize_hbox.pack_start (normalize_lufs_spinbutton, false, false, 2);
+       normalize_hbox.pack_start (normalize_lufs_label, false, false, 0);
+       normalize_hbox.pack_start (*Gtk::manage (new Gtk::Label (_("\u2227"))), false, false, 4);
+       normalize_hbox.pack_start (normalize_dbtp_spinbutton, false, false, 2);
+       normalize_hbox.pack_start (normalize_dbtp_label, false, false, 0);
+
+       ArdourWidgets::set_tooltip (normalize_loudness_rb,
+                       _("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."));
+
+       normalize_dbfs_spinbutton.configure (normalize_dbfs_adjustment, 0.1, 2);
+       normalize_lufs_spinbutton.configure (normalize_lufs_adjustment, 0.1, 2);
+       normalize_dbtp_spinbutton.configure (normalize_dbtp_adjustment, 0.1, 2);
 
        /* Silence  */
 
@@ -102,6 +149,38 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
        silence_table.attach (silence_end_checkbox, 1, 2, 2, 3);
        silence_table.attach (silence_end_clock, 2, 3, 2, 3);
 
+       /* Post-export hook script */
+
+       get_vbox()->pack_start (command_label, false, false);
+       get_vbox()->pack_start (command_entry, false, false);
+
+       ArdourWidgets::set_tooltip (command_entry,
+                       _(
+                               "%a Artist name\n"
+                               "%b File's base-name\n"
+                               "%c Copyright\n"
+                               "%d File's directory\n"
+                               "%f File's full absolute path\n"
+                               "%l Lyricist\n"
+                               "%n Session name\n"
+                               "%o Conductor\n"
+                               "%t Title\n"
+                               "%z Organization\n"
+                               "%A Album\n"
+                               "%C Comment\n"
+                               "%E Engineer\n"
+                               "%G Genre\n"
+                               "%L Total track count\n"
+                               "%M Mixer\n"
+                               "%N Timespan name\n"
+                               "%O Composer\n"
+                               "%P Producer\n"
+                               "%S Disc subtitle\n"
+                               "%T Track number\n"
+                               "%Y Year\n"
+                               "%Z Country"
+                        ));
+
        /* Format table */
 
        init_format_table();
@@ -120,6 +199,13 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
        bold.insert (b);
        encoding_options_label.set_attributes (bold);
 
+       /* Codec options */
+
+       codec_quality_list = Gtk::ListStore::create (codec_quality_cols);
+       codec_quality_combo.set_model (codec_quality_list);
+       codec_quality_combo.pack_start (codec_quality_cols.label);
+       //codec_quality_combo.set_active (0);
+
        /* Buttons */
 
        revert_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
@@ -127,7 +213,16 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
        close_button = add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_APPLY);
        close_button->set_sensitive (false);
        close_button->signal_clicked().connect (sigc::mem_fun (*this, &ExportFormatDialog::end_dialog));
-       manager.CompleteChanged.connect (*this, invalidator (*this), ui_bind (&Gtk::Button::set_sensitive, close_button, _1), gui_context());
+       manager.CompleteChanged.connect (*this, invalidator (*this), boost::bind (&Gtk::Button::set_sensitive, close_button, _1), gui_context());
+
+       with_cue.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_cue));
+       with_toc.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_toc));
+       with_mp4chaps.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_mp4chaps));
+       command_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_command));
+
+       cue_toc_vbox.pack_start (with_cue, false, false);
+       cue_toc_vbox.pack_start (with_toc, false, false);
+       cue_toc_vbox.pack_start (with_mp4chaps, false, false);
 
        /* Load state before hooking up the rest of the signals */
 
@@ -143,7 +238,11 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
        trim_end_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_trim_end_selection));
 
        normalize_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
-       normalize_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
+       normalize_peak_rb.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
+       normalize_loudness_rb.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
+       normalize_dbfs_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
+       normalize_lufs_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
+       normalize_dbtp_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
 
        silence_start_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
        silence_start_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
@@ -152,6 +251,7 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
        silence_end_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
 
        src_quality_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_src_quality_selection));
+       codec_quality_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_codec_quality_selection));
 
        /* Format table signals */
 
@@ -173,6 +273,7 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
        /* Finalize */
 
        show_all_children();
+       update_normalize_sensitivity ();
 }
 
 ExportFormatDialog::~ExportFormatDialog ()
@@ -210,7 +311,7 @@ ExportFormatDialog::set_session (ARDOUR::Session* s)
        if (sample_rate_view.get_selection()->count_selected_rows() == 0) {
                Gtk::ListStore::Children::iterator it;
                for (it = sample_rate_list->children().begin(); it != sample_rate_list->children().end(); ++it) {
-                       if ((framecnt_t) (*it)->get_value (sample_rate_cols.ptr)->rate == _session->nominal_frame_rate()) {
+                       if ((samplecnt_t) (*it)->get_value (sample_rate_cols.ptr)->rate == _session->nominal_sample_rate()) {
                                sample_rate_view.get_selection()->select (it);
                                break;
                        }
@@ -224,7 +325,11 @@ ExportFormatDialog::load_state (FormatPtr spec)
        name_entry.set_text (spec->name());
 
        normalize_checkbox.set_active (spec->normalize());
-       normalize_spinbutton.set_value (spec->normalize_target());
+       normalize_peak_rb.set_active (!spec->normalize_loudness());
+       normalize_loudness_rb.set_active (spec->normalize_loudness());
+       normalize_dbfs_spinbutton.set_value (spec->normalize_dbfs());
+       normalize_lufs_spinbutton.set_value (spec->normalize_lufs());
+       normalize_dbtp_spinbutton.set_value (spec->normalize_dbtp());
 
        trim_start_checkbox.set_active (spec->trim_beginning());
        silence_start = spec->silence_beginning_time();
@@ -234,6 +339,10 @@ ExportFormatDialog::load_state (FormatPtr spec)
        silence_end = spec->silence_end_time();
        silence_end_checkbox.set_active (spec->silence_end_time().not_zero());
 
+       with_cue.set_active (spec->with_cue());
+       with_toc.set_active (spec->with_toc());
+       with_mp4chaps.set_active (spec->with_mp4chaps());
+
        for (Gtk::ListStore::Children::iterator it = src_quality_list->children().begin(); it != src_quality_list->children().end(); ++it) {
                if (it->get_value (src_quality_cols.id) == spec->src_quality()) {
                        src_quality_combo.set_active (it);
@@ -241,6 +350,13 @@ ExportFormatDialog::load_state (FormatPtr spec)
                }
        }
 
+       for (Gtk::ListStore::Children::iterator it = codec_quality_list->children().begin(); it != codec_quality_list->children().end(); ++it) {
+               if (it->get_value (codec_quality_cols.quality) == spec->codec_quality()) {
+                       codec_quality_combo.set_active (it);
+                       break;
+               }
+       }
+
        for (Gtk::ListStore::Children::iterator it = format_list->children().begin(); it != format_list->children().end(); ++it) {
                boost::shared_ptr<ARDOUR::ExportFormat> format_in_list = it->get_value (format_cols.ptr);
                if (format_in_list->get_format_id() == spec->format_id() &&
@@ -275,7 +391,9 @@ ExportFormatDialog::load_state (FormatPtr spec)
                }
        }
 
+       update_normalize_sensitivity ();
        tag_checkbox.set_active (spec->tag());
+       command_entry.set_text (spec->command());
 }
 
 void
@@ -323,7 +441,7 @@ ExportFormatDialog::init_format_table ()
                row[compatibility_cols.label] = (*it)->name();
 
                WeakCompatPtr ptr (*it);
-               (*it)->SelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_compatibility_selection, this, _1, ptr), gui_context());
+               (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_compatibility_selection, this, _1, ptr), gui_context());
        }
 
        compatibility_view.append_column_editable ("", compatibility_cols.selected);
@@ -351,8 +469,8 @@ ExportFormatDialog::init_format_table ()
                row[quality_cols.label] = (*it)->name();
 
                WeakQualityPtr ptr (*it);
-               (*it)->SelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_quality_selection, this, _1, ptr), gui_context());
-               (*it)->CompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_quality_compatibility, this, _1, ptr), gui_context());
+               (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_quality_selection, this, _1, ptr), gui_context());
+               (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_quality_compatibility, this, _1, ptr), gui_context());
        }
 
        quality_view.append_column ("", quality_cols.label);
@@ -373,19 +491,19 @@ ExportFormatDialog::init_format_table ()
                row[format_cols.label] = (*it)->name();
 
                WeakFormatPtr ptr (*it);
-               (*it)->SelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_format_selection, this, _1, ptr), gui_context());
-               (*it)->CompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_format_compatibility, this, _1, ptr), gui_context());
+               (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_format_selection, this, _1, ptr), gui_context());
+               (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_format_compatibility, this, _1, ptr), gui_context());
 
                /* Encoding options */
 
                boost::shared_ptr<HasSampleFormat> hsf;
 
-               if (hsf = boost::dynamic_pointer_cast<HasSampleFormat> (*it)) {
-                       hsf->SampleFormatSelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_sample_format_selection, this, _1, _2), gui_context());
-                       hsf->SampleFormatCompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_sample_format_compatibility, this, _1, _2), gui_context());
+               if ((hsf = boost::dynamic_pointer_cast<HasSampleFormat> (*it))) {
+                       hsf->SampleFormatSelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_format_selection, this, _1, _2), gui_context());
+                       hsf->SampleFormatCompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_format_compatibility, this, _1, _2), gui_context());
 
-                       hsf->DitherTypeSelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_dither_type_selection, this, _1, _2), gui_context());
-                       hsf->DitherTypeCompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_dither_type_compatibility, this, _1, _2), gui_context());
+                       hsf->DitherTypeSelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_dither_type_selection, this, _1, _2), gui_context());
+                       hsf->DitherTypeCompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_dither_type_compatibility, this, _1, _2), gui_context());
                }
        }
 
@@ -405,10 +523,10 @@ ExportFormatDialog::init_format_table ()
                row[sample_rate_cols.ptr] = *it;
                row[sample_rate_cols.color] = "white";
                row[sample_rate_cols.label] = (*it)->name();
-               
+
                WeakSampleRatePtr ptr (*it);
-               (*it)->SelectChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_sample_rate_selection, this, _1, ptr), gui_context());
-               (*it)->CompatibleChanged.connect (*this, invalidator (*this), ui_bind (&ExportFormatDialog::change_sample_rate_compatibility, this, _1, ptr), gui_context());
+               (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_rate_selection, this, _1, ptr), gui_context());
+               (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_rate_compatibility, this, _1, ptr), gui_context());
        }
 
        sample_rate_view.append_column ("", sample_rate_cols.label);
@@ -493,7 +611,7 @@ ExportFormatDialog::update_compatibility_selection (std::string const & path)
 {
 
        Gtk::TreeModel::iterator iter = compatibility_view.get_model ()->get_iter (path);
-       ExportFormatManager::CompatPtr ptr = iter->get_value (compatibility_cols.ptr);
+       ExportFormatCompatibilityPtr ptr = iter->get_value (compatibility_cols.ptr);
        bool state = iter->get_value (compatibility_cols.selected);
 
        iter->set_value (compatibility_cols.selected, state);
@@ -546,6 +664,8 @@ ExportFormatDialog::update_selection (Glib::RefPtr<Gtk::ListStore> & list, Gtk::
                bool selected = selection->is_selected (it);
                it->get_value (cols.ptr)->set_selected (selected);
        }
+
+       set_codec_quality_selection ();
 }
 
 void
@@ -553,7 +673,7 @@ ExportFormatDialog::change_compatibility_selection (bool select, WeakCompatPtr c
 {
        ++applying_changes_from_engine;
 
-       ExportFormatManager::CompatPtr ptr = compat.lock();
+       ExportFormatCompatibilityPtr ptr = compat.lock();
 
        for (Gtk::ListStore::Children::iterator it = compatibility_list->children().begin(); it != compatibility_list->children().end(); ++it) {
                if (it->get_value (compatibility_cols.ptr) == ptr) {
@@ -576,7 +696,7 @@ ExportFormatDialog::change_format_selection (bool select, WeakFormatPtr format)
 {
        change_selection<ExportFormat, FormatCols> (select, format, format_list, format_view, format_cols);
 
-       ExportFormatManager::FormatPtr ptr = format.lock();
+       ExportFormatPtr ptr = format.lock();
 
        if (select && ptr) {
                change_encoding_options (ptr);
@@ -591,7 +711,7 @@ ExportFormatDialog::change_sample_rate_selection (bool select, WeakSampleRatePtr
        if (select) {
                ExportFormatManager::SampleRatePtr ptr = rate.lock();
                if (ptr && _session) {
-                       src_quality_combo.set_sensitive ((uint32_t) ptr->rate != _session->frame_rate());
+                       src_quality_combo.set_sensitive ((uint32_t) ptr->rate != _session->sample_rate());
                }
        }
 }
@@ -685,6 +805,37 @@ ExportFormatDialog::change_compatibility (bool compatibility, boost::weak_ptr<T>
        }
 }
 
+void
+ExportFormatDialog::update_with_cue ()
+{
+       manager.select_with_cue (with_cue.get_active());
+}
+
+void
+ExportFormatDialog::update_with_toc ()
+{
+       manager.select_with_toc (with_toc.get_active());
+}
+
+void
+ExportFormatDialog::update_with_mp4chaps ()
+{
+       manager.select_with_mp4chaps (with_mp4chaps.get_active());
+}
+
+void
+ExportFormatDialog::update_command ()
+{
+       manager.set_command (command_entry.get_text());
+}
+
+void
+ExportFormatDialog::update_description()
+{
+       std::string text = ": " + format->description(false);
+       name_generated_part.set_text(text);
+}
+
 void
 ExportFormatDialog::update_name ()
 {
@@ -703,11 +854,25 @@ ExportFormatDialog::update_trim_end_selection ()
        manager.select_trim_end (trim_end_checkbox.get_active());
 }
 
+void
+ExportFormatDialog::update_normalize_sensitivity ()
+{
+       bool en = normalize_checkbox.get_active();
+       bool loudness = normalize_loudness_rb.get_active();
+       normalize_dbfs_spinbutton.set_sensitive (!loudness && en);
+       normalize_lufs_spinbutton.set_sensitive (loudness && en);
+       normalize_dbtp_spinbutton.set_sensitive (loudness && en);
+}
+
 void
 ExportFormatDialog::update_normalize_selection ()
 {
        manager.select_normalize (normalize_checkbox.get_active());
-       manager.select_normalize_target (normalize_spinbutton.get_value ());
+       manager.select_normalize_loudness (normalize_loudness_rb.get_active());
+       manager.select_normalize_dbfs (normalize_dbfs_spinbutton.get_value ());
+       manager.select_normalize_lufs (normalize_lufs_spinbutton.get_value ());
+       manager.select_normalize_dbtp (normalize_dbtp_spinbutton.get_value ());
+       update_normalize_sensitivity ();
 }
 
 void
@@ -732,7 +897,7 @@ void
 ExportFormatDialog::update_clock (AudioClock & clock, ARDOUR::AnyTime const & time)
 {
        // TODO position
-       clock.set (_session->convert_to_frames (time), true);
+       clock.set (_session->convert_to_samples (time), true);
 
        AudioClock::Mode mode(AudioClock::Timecode);
 
@@ -743,8 +908,8 @@ ExportFormatDialog::update_clock (AudioClock & clock, ARDOUR::AnyTime const & ti
          case AnyTime::BBT:
                mode = AudioClock::BBT;
                break;
-         case AnyTime::Frames:
-               mode = AudioClock::Frames;
+         case AnyTime::Samples:
+               mode = AudioClock::Samples;
                break;
          case AnyTime::Seconds:
                mode = AudioClock::MinSec;
@@ -761,28 +926,26 @@ ExportFormatDialog::update_time (AnyTime & time, AudioClock const & clock)
                return;
        }
 
-       framecnt_t frames = clock.current_duration();
+       samplecnt_t samples = clock.current_duration();
 
        switch (clock.mode()) {
          case AudioClock::Timecode:
                time.type = AnyTime::Timecode;
-               _session->timecode_time (frames, time.timecode);
+               _session->timecode_time (samples, time.timecode);
                break;
          case AudioClock::BBT:
                time.type = AnyTime::BBT;
-               _session->bbt_time (frames, time.bbt);
+               _session->bbt_time (samples, time.bbt);
                break;
+         case AudioClock::Seconds:
          case AudioClock::MinSec:
                time.type = AnyTime::Seconds;
-               time.seconds = (double) frames / _session->frame_rate();
+               time.seconds = (double) samples / _session->sample_rate();
                break;
-         case AudioClock::Frames:
-               time.type = AnyTime::Frames;
-               time.frames = frames;
+         case AudioClock::Samples:
+               time.type = AnyTime::Samples;
+               time.samples = samples;
                break;
-         case AudioClock::Off:
-               silence_end_checkbox.set_active (false);
-               return;
        }
 }
 
@@ -794,6 +957,17 @@ ExportFormatDialog::update_src_quality_selection ()
        manager.select_src_quality (quality);
 }
 
+void
+ExportFormatDialog::update_codec_quality_selection ()
+{
+       Gtk::TreeModel::const_iterator iter = codec_quality_combo.get_active();
+       if (!iter) {
+               return;
+       }
+       int quality = iter->get_value (codec_quality_cols.quality);
+       manager.select_codec_quality (quality);
+}
+
 void
 ExportFormatDialog::update_tagging_selection ()
 {
@@ -801,7 +975,7 @@ ExportFormatDialog::update_tagging_selection ()
 }
 
 void
-ExportFormatDialog::change_encoding_options (ExportFormatManager::FormatPtr ptr)
+ExportFormatDialog::change_encoding_options (ExportFormatPtr ptr)
 {
        empty_encoding_option_table ();
 
@@ -809,15 +983,18 @@ ExportFormatDialog::change_encoding_options (ExportFormatManager::FormatPtr ptr)
        boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ogg_ptr;
        boost::shared_ptr<ARDOUR::ExportFormatFLAC> flac_ptr;
        boost::shared_ptr<ARDOUR::ExportFormatBWF> bwf_ptr;
+       boost::shared_ptr<ARDOUR::ExportFormatFFMPEG> ffmpeg_ptr;
 
-       if (linear_ptr = boost::dynamic_pointer_cast<ExportFormatLinear> (ptr)) {
+       if ((linear_ptr = boost::dynamic_pointer_cast<ExportFormatLinear> (ptr))) {
                show_linear_enconding_options (linear_ptr);
-       } else if (ogg_ptr = boost::dynamic_pointer_cast<ExportFormatOggVorbis> (ptr)) {
+       } else if ((ogg_ptr = boost::dynamic_pointer_cast<ExportFormatOggVorbis> (ptr))) {
                show_ogg_enconding_options (ogg_ptr);
-       } else if (flac_ptr = boost::dynamic_pointer_cast<ExportFormatFLAC> (ptr)) {
+       } else if ((flac_ptr = boost::dynamic_pointer_cast<ExportFormatFLAC> (ptr))) {
                show_flac_enconding_options (flac_ptr);
-       } else if (bwf_ptr = boost::dynamic_pointer_cast<ExportFormatBWF> (ptr)) {
+       } else if ((bwf_ptr = boost::dynamic_pointer_cast<ExportFormatBWF> (ptr))) {
                show_bwf_enconding_options (bwf_ptr);
+       } else if ((ffmpeg_ptr = boost::dynamic_pointer_cast<ExportFormatFFMPEG> (ptr))) {
+               show_ffmpeg_enconding_options (ffmpeg_ptr);
        } else {
                std::cout << "Unrecognized format!" << std::endl;
        }
@@ -854,15 +1031,14 @@ ExportFormatDialog::show_linear_enconding_options (boost::shared_ptr<ARDOUR::Exp
 }
 
 void
-ExportFormatDialog::show_ogg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> /*ptr*/)
+ExportFormatDialog::show_ogg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ptr)
 {
        encoding_options_label.set_label (_("Ogg Vorbis options"));
 
-       encoding_options_table.resize (1, 1);
-       encoding_options_table.attach (tag_checkbox, 0, 1, 0, 1);
-
-       update_tagging_selection ();
-
+       encoding_options_table.resize (2, 1);
+       encoding_options_table.attach (codec_quality_combo, 0, 1, 0, 1);
+       encoding_options_table.attach (tag_checkbox, 0, 1, 1, 2);
+       fill_codec_quality_lists (ptr);
        show_all_children ();
 }
 
@@ -899,6 +1075,17 @@ ExportFormatDialog::show_bwf_enconding_options (boost::shared_ptr<ARDOUR::Export
        show_all_children ();
 }
 
+void
+ExportFormatDialog::show_ffmpeg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFFMPEG> ptr)
+{
+       encoding_options_label.set_label (_("FFMPEG/MP3 options"));
+       encoding_options_table.resize (1, 1);
+       encoding_options_table.attach (codec_quality_combo, 0, 1, 0, 1);
+       encoding_options_table.attach (tag_checkbox, 0, 1, 1, 2);
+       fill_codec_quality_lists (ptr);
+       show_all_children ();
+}
+
 void
 ExportFormatDialog::fill_sample_format_lists (boost::shared_ptr<ARDOUR::HasSampleFormat> ptr)
 {
@@ -942,6 +1129,33 @@ ExportFormatDialog::fill_sample_format_lists (boost::shared_ptr<ARDOUR::HasSampl
        }
 }
 
+void
+ExportFormatDialog::fill_codec_quality_lists (boost::shared_ptr<ARDOUR::HasCodecQuality> ptr)
+{
+       HasCodecQuality::CodecQualityList const & codecs = ptr->get_codec_qualities();
+
+       codec_quality_list->clear();
+       for (HasCodecQuality::CodecQualityList::const_iterator it = codecs.begin(); it != codecs.end(); ++it) {
+
+       Gtk::TreeModel::iterator iter = codec_quality_list->append();
+       Gtk::TreeModel::Row row = *iter;
+               row[codec_quality_cols.quality] = (*it)->quality;
+               row[codec_quality_cols.label] = (*it)->name;
+       }
+       set_codec_quality_selection ();
+}
+
+void
+ExportFormatDialog::set_codec_quality_selection ()
+{
+       for (Gtk::ListStore::Children::iterator it = codec_quality_list->children().begin(); it != codec_quality_list->children().end(); ++it) {
+               if (it->get_value (codec_quality_cols.quality) == format->codec_quality()) {
+                       codec_quality_combo.set_active (it);
+                       break;
+               }
+       }
+}
+
 void
 ExportFormatDialog::end_dialog ()
 {