X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fexport_format_manager.cc;h=65544122739c7f0e08dfafd6d2efc50fd8b5b62a;hb=10a4de155034ffce6b3bc97d0cf91ba8f8e99812;hp=df787abafb9bd842e56c7ef4c5234d470375201e;hpb=ffadfff6506e507b09853e4c7e50bcedffa29cce;p=ardour.git diff --git a/libs/ardour/export_format_manager.cc b/libs/ardour/export_format_manager.cc index df787abafb..6554412273 100644 --- a/libs/ardour/export_format_manager.cc +++ b/libs/ardour/export_format_manager.cc @@ -20,7 +20,6 @@ #include "ardour/export_format_manager.h" -#include "ardour/types.h" #include "ardour/export_format_specification.h" #include "ardour/export_format_compatibility.h" @@ -31,7 +30,7 @@ using std::string; namespace ARDOUR { -ExportFormatManager::ExportFormatManager (SpecPtr specification) : +ExportFormatManager::ExportFormatManager (ExportFormatSpecPtr specification) : pending_selection_change (false), universal_set (new ExportFormatBase ()) { @@ -41,6 +40,8 @@ ExportFormatManager::ExportFormatManager (SpecPtr specification) : init_qualities (); init_formats (); init_sample_rates (); + + prev_description = current_selection->description(); } ExportFormatManager::~ExportFormatManager () @@ -51,7 +52,7 @@ ExportFormatManager::~ExportFormatManager () void ExportFormatManager::init_compatibilities () { - CompatPtr c_ptr; + ExportFormatCompatibilityPtr c_ptr; c_ptr.reset (new ExportFormatCompatibility (_("CD"))); c_ptr->add_sample_rate (ExportFormatBase::SR_44_1); @@ -115,7 +116,7 @@ ExportFormatManager::init_qualities () void ExportFormatManager::init_formats () { - FormatPtr f_ptr; + ExportFormatPtr f_ptr; ExportFormatLinear * fl_ptr; f_ptr.reset (fl_ptr = new ExportFormatLinear ("AIFF", ExportFormatBase::F_AIFF)); @@ -126,7 +127,7 @@ ExportFormatManager::init_formats () fl_ptr->add_sample_format (ExportFormatBase::SF_32); fl_ptr->add_sample_format (ExportFormatBase::SF_Float); fl_ptr->add_sample_format (ExportFormatBase::SF_Double); - fl_ptr->add_endianness (ExportFormatBase::E_Big); + fl_ptr->add_endianness (ExportFormatBase::E_Big); fl_ptr->set_default_sample_format (ExportFormatBase::SF_16); fl_ptr->set_extension ("aiff"); add_format (f_ptr); @@ -161,7 +162,7 @@ ExportFormatManager::init_formats () fl_ptr->add_sample_format (ExportFormatBase::SF_32); fl_ptr->add_sample_format (ExportFormatBase::SF_Float); fl_ptr->add_sample_format (ExportFormatBase::SF_Double); - fl_ptr->add_endianness (ExportFormatBase::E_Little); + fl_ptr->add_endianness (ExportFormatBase::E_Little); fl_ptr->set_default_sample_format (ExportFormatBase::SF_16); fl_ptr->set_extension ("wav"); add_format (f_ptr); @@ -177,6 +178,17 @@ ExportFormatManager::init_formats () fl_ptr->set_extension ("w64"); add_format (f_ptr); + f_ptr.reset (fl_ptr = new ExportFormatLinear ("CAF", ExportFormatBase::F_CAF)); + fl_ptr->add_sample_format (ExportFormatBase::SF_U8); + fl_ptr->add_sample_format (ExportFormatBase::SF_16); + fl_ptr->add_sample_format (ExportFormatBase::SF_24); + fl_ptr->add_sample_format (ExportFormatBase::SF_32); + fl_ptr->add_sample_format (ExportFormatBase::SF_Float); + fl_ptr->add_sample_format (ExportFormatBase::SF_Double); + fl_ptr->set_default_sample_format (ExportFormatBase::SF_Float); + fl_ptr->set_extension ("caf"); + add_format (f_ptr); + f_ptr.reset (fl_ptr = new ExportFormatLinear ("RAW", ExportFormatBase::F_RAW)); fl_ptr->add_sample_format (ExportFormatBase::SF_U8); fl_ptr->add_sample_format (ExportFormatBase::SF_8); @@ -204,6 +216,7 @@ void ExportFormatManager::init_sample_rates () { add_sample_rate (SampleRatePtr (new SampleRateState (ExportFormatBase::SR_Session, _("Session rate")))); + add_sample_rate (SampleRatePtr (new SampleRateState (ExportFormatBase::SR_8, "8 kHz"))); add_sample_rate (SampleRatePtr (new SampleRateState (ExportFormatBase::SR_22_05, "22,05 kHz"))); add_sample_rate (SampleRatePtr (new SampleRateState (ExportFormatBase::SR_44_1, "44,1 kHz"))); add_sample_rate (SampleRatePtr (new SampleRateState (ExportFormatBase::SR_48, "48 kHz"))); @@ -213,10 +226,12 @@ ExportFormatManager::init_sample_rates () } void -ExportFormatManager::add_compatibility (CompatPtr ptr) +ExportFormatManager::add_compatibility (ExportFormatCompatibilityPtr ptr) { compatibilities.push_back (ptr); - ptr->SelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_compatibility_selection, this, _1, WeakCompatPtr (ptr))); + ptr->SelectChanged.connect_same_thread (*this, + boost::bind (&ExportFormatManager::change_compatibility_selection, + this, _1, WeakExportFormatCompatibilityPtr (ptr))); } void @@ -227,17 +242,17 @@ ExportFormatManager::add_quality (QualityPtr ptr) } void -ExportFormatManager::add_format (FormatPtr ptr) +ExportFormatManager::add_format (ExportFormatPtr ptr) { formats.push_back (ptr); - ptr->SelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_format_selection, this, _1, WeakFormatPtr (ptr))); + ptr->SelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_format_selection, this, _1, WeakExportFormatPtr (ptr))); universal_set = universal_set->get_union (*ptr); /* Encoding options */ boost::shared_ptr hsf; - if (hsf = boost::dynamic_pointer_cast (ptr)) { + if ((hsf = boost::dynamic_pointer_cast (ptr))) { hsf->SampleFormatSelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_sample_format_selection, this, _1, _2)); hsf->DitherTypeSelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_dither_type_selection, this, _1, _2)); } @@ -254,65 +269,123 @@ void ExportFormatManager::set_name (string name) { current_selection->set_name (name); + check_for_description_change (); } void ExportFormatManager::select_src_quality (ExportFormatBase::SRCQuality value) { current_selection->set_src_quality (value); + check_for_description_change (); +} + +void +ExportFormatManager::select_with_cue (bool value) +{ + current_selection->set_with_cue (value); + check_for_description_change (); +} + +void +ExportFormatManager::select_with_toc (bool value) +{ + current_selection->set_with_toc (value); + check_for_description_change (); +} + +void +ExportFormatManager::select_with_mp4chaps (bool value) +{ + current_selection->set_with_mp4chaps (value); + check_for_description_change (); +} + +void +ExportFormatManager::set_command (std::string command) +{ + current_selection->set_command (command); + check_for_description_change (); } void ExportFormatManager::select_trim_beginning (bool value) { current_selection->set_trim_beginning (value); + check_for_description_change (); } void ExportFormatManager::select_silence_beginning (AnyTime const & time) { current_selection->set_silence_beginning (time); + check_for_description_change (); } void ExportFormatManager::select_trim_end (bool value) { current_selection->set_trim_end (value); + check_for_description_change (); } void ExportFormatManager::select_silence_end (AnyTime const & time) { current_selection->set_silence_end (time); + check_for_description_change (); } void ExportFormatManager::select_normalize (bool value) { current_selection->set_normalize (value); + check_for_description_change (); } void -ExportFormatManager::select_normalize_target (float value) +ExportFormatManager::select_normalize_loudness (bool value) { - current_selection->set_normalize_target (value); + current_selection->set_normalize_loudness (value); + check_for_description_change (); +} + +void +ExportFormatManager::select_normalize_dbfs (float value) +{ + current_selection->set_normalize_dbfs (value); + check_for_description_change (); +} + +void +ExportFormatManager::select_normalize_lufs (float value) +{ + current_selection->set_normalize_lufs (value); + check_for_description_change (); +} + +void +ExportFormatManager::select_normalize_dbtp (float value) +{ + current_selection->set_normalize_dbtp (value); + check_for_description_change (); } void ExportFormatManager::select_tagging (bool tag) { current_selection->set_tag (tag); + check_for_description_change (); } void -ExportFormatManager::change_compatibility_selection (bool select, WeakCompatPtr const & compat) +ExportFormatManager::change_compatibility_selection (bool select, WeakExportFormatCompatibilityPtr const & compat) { bool do_selection_changed = !pending_selection_change; if (!pending_selection_change) { pending_selection_change = true; } - CompatPtr ptr = compat.lock(); + ExportFormatCompatibilityPtr ptr = compat.lock(); if (ptr && select) { select_compatibility (ptr); @@ -341,9 +414,9 @@ ExportFormatManager::change_quality_selection (bool select, WeakQualityPtr const } void -ExportFormatManager::change_format_selection (bool select, WeakFormatPtr const & format) +ExportFormatManager::change_format_selection (bool select, WeakExportFormatPtr const & format) { - FormatPtr ptr = format.lock(); + ExportFormatPtr ptr = format.lock(); if (!ptr) { return; @@ -409,11 +482,11 @@ ExportFormatManager::change_dither_type_selection (bool select, WeakDitherTypePt } void -ExportFormatManager::select_compatibility (WeakCompatPtr const & /*compat*/) +ExportFormatManager::select_compatibility (WeakExportFormatCompatibilityPtr const & /*compat*/) { /* Calculate compatibility intersection for the selection */ - FormatBasePtr compat_intersect = get_compatibility_intersection (); + ExportFormatBasePtr compat_intersect = get_compatibility_intersection (); /* Unselect incompatible items */ @@ -426,7 +499,7 @@ ExportFormatManager::select_compatibility (WeakCompatPtr const & /*compat*/) select_intersect = compat_intersect->get_intersection (*current_selection); if (select_intersect->formats_empty()) { - select_format (FormatPtr()); + select_format (ExportFormatPtr()); } select_intersect = compat_intersect->get_intersection (*current_selection); @@ -453,7 +526,7 @@ ExportFormatManager::select_quality (QualityPtr const & quality) /* Deselect format if it is incompatible */ - FormatPtr format = get_selected_format(); + ExportFormatPtr format = get_selected_format(); if (format && !format->has_quality (quality->quality)) { format->set_selected (false); } @@ -479,7 +552,7 @@ ExportFormatManager::select_quality (QualityPtr const & quality) } void -ExportFormatManager::select_format (FormatPtr const & format) +ExportFormatManager::select_format (ExportFormatPtr const & format) { bool do_selection_changed = !pending_selection_change; if (!pending_selection_change) { @@ -525,7 +598,7 @@ ExportFormatManager::select_format (FormatPtr const & format) current_selection->set_sample_format (format_to_select); } else { - FormatPtr current_format = get_selected_format (); + ExportFormatPtr current_format = get_selected_format (); if (current_format) { current_format->set_selected (false); } @@ -627,7 +700,7 @@ ExportFormatManager::selection_changed () /* Mark compatibility for everything necessary */ std::set compatible_qualities; - FormatBasePtr compat_intersect = get_compatibility_intersection (); + ExportFormatBasePtr compat_intersect = get_compatibility_intersection (); ExportFormatCompatibility global_compat (*compat_intersect); for (FormatList::iterator it = formats.begin(); it != formats.end(); ++it) { @@ -668,7 +741,7 @@ ExportFormatManager::selection_changed () } boost::shared_ptr hsf; - if (hsf = boost::dynamic_pointer_cast (get_selected_format())) { + if ((hsf = boost::dynamic_pointer_cast (get_selected_format()))) { SampleFormatList sf_list = hsf->get_sample_formats(); for (SampleFormatList::iterator it = sf_list.begin(); it != sf_list.end(); ++it) { @@ -681,15 +754,26 @@ ExportFormatManager::selection_changed () } - /* Signal completeness */ + /* Signal completeness and possible description change */ CompleteChanged (current_selection->is_complete()); + check_for_description_change (); /* Reset pending state */ pending_selection_change = false; } +void +ExportFormatManager::check_for_description_change () +{ + std::string new_description = current_selection->description(); + if (new_description == prev_description) { return; } + + prev_description = new_description; + DescriptionChanged(); +} + ExportFormatManager::QualityPtr ExportFormatManager::get_selected_quality () { @@ -702,10 +786,10 @@ ExportFormatManager::get_selected_quality () return QualityPtr(); } -ExportFormatManager::FormatPtr +ExportFormatPtr ExportFormatManager::get_selected_format () { - FormatPtr format; + ExportFormatPtr format; for (FormatList::iterator it = formats.begin(); it != formats.end(); ++it) { if ((*it)->selected()) { @@ -733,7 +817,7 @@ ExportFormatManager::get_selected_sample_format () { boost::shared_ptr hsf; - if (hsf = boost::dynamic_pointer_cast (get_selected_format())) { + if ((hsf = boost::dynamic_pointer_cast (get_selected_format()))) { return hsf->get_selected_sample_format (); } else { return SampleFormatPtr (); @@ -741,10 +825,10 @@ ExportFormatManager::get_selected_sample_format () } -ExportFormatManager::FormatBasePtr +ExportFormatBasePtr ExportFormatManager::get_compatibility_intersection () { - FormatBasePtr compat_intersect = universal_set; + ExportFormatBasePtr compat_intersect = universal_set; for (CompatList::iterator it = compatibilities.begin(); it != compatibilities.end(); ++it) { if ((*it)->selected ()) {