From 65c8d673a2f88db61c68bf119f9dccbe82efd9ff Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 18 Jan 2012 21:56:06 +0000 Subject: restore ability to create TOC and CUE files during export. this is an option in a given export format, not a per-export choice. so you need export formats with them set (or not) in order to utilize this choice. the resulting CUE/TOC files have not been checked with a burner (e.g. cdrdao) and testing of them would be appreciated - i (paul) have no CD burner h/w git-svn-id: svn://localhost/ardour2/branches/3.0@11266 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/export_format_dialog.cc | 25 +++++++++++++++++++++++ gtk2_ardour/export_format_dialog.h | 8 ++++++++ libs/ardour/ardour/export_format_manager.h | 2 ++ libs/ardour/ardour/export_format_specification.h | 6 ++++++ libs/ardour/export_format_manager.cc | 12 +++++++++++ libs/ardour/export_format_specification.cc | 22 +++++++++++++++++++- libs/ardour/export_handler.cc | 26 +++++++++++++++++------- libs/ardour/session_export.cc | 5 ++++- libs/ardour/utils.cc | 3 ++- 9 files changed, 99 insertions(+), 10 deletions(-) diff --git a/gtk2_ardour/export_format_dialog.cc b/gtk2_ardour/export_format_dialog.cc index 1a8ecf8ffa..68c3f3c41f 100644 --- a/gtk2_ardour/export_format_dialog.cc +++ b/gtk2_ardour/export_format_dialog.cc @@ -64,6 +64,9 @@ 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")), + tag_checkbox (_("Tag file with session's metadata")) { @@ -73,6 +76,7 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) : 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); /* Name, new and remove */ @@ -129,6 +133,12 @@ ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) : 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()); + 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)); + + cue_toc_vbox.pack_start (with_cue, false, false); + cue_toc_vbox.pack_start (with_toc, false, false); + /* Load state before hooking up the rest of the signals */ load_state (format); @@ -234,6 +244,9 @@ 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()); + 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); @@ -685,6 +698,18 @@ ExportFormatDialog::change_compatibility (bool compatibility, boost::weak_ptr } } +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_name () { diff --git a/gtk2_ardour/export_format_dialog.h b/gtk2_ardour/export_format_dialog.h index 0371b77544..9e395da01d 100644 --- a/gtk2_ardour/export_format_dialog.h +++ b/gtk2_ardour/export_format_dialog.h @@ -297,6 +297,14 @@ class ExportFormatDialog : public ArdourDialog, public PBD::ScopedConnectionList Gtk::Label sample_format_label; Gtk::Label dither_label; + Gtk::CheckButton with_cue; + Gtk::CheckButton with_toc; + + Gtk::VBox cue_toc_vbox; + + void update_with_toc (); + void update_with_cue (); + Gtk::TreeView sample_format_view; Gtk::TreeView dither_type_view; diff --git a/libs/ardour/ardour/export_format_manager.h b/libs/ardour/ardour/export_format_manager.h index 019a986f35..33a5553203 100644 --- a/libs/ardour/ardour/export_format_manager.h +++ b/libs/ardour/ardour/export_format_manager.h @@ -97,6 +97,8 @@ class ExportFormatManager : public PBD::ScopedConnectionList void set_name (std::string name); + void select_with_cue (bool); + void select_with_toc (bool); void select_src_quality (ExportFormatBase::SRCQuality value); void select_trim_beginning (bool value); void select_silence_beginning (AnyTime const & time); diff --git a/libs/ardour/ardour/export_format_specification.h b/libs/ardour/ardour/export_format_specification.h index 7afb0bc734..4bf3ed4013 100644 --- a/libs/ardour/ardour/export_format_specification.h +++ b/libs/ardour/ardour/export_format_specification.h @@ -93,6 +93,8 @@ class ExportFormatSpecification : public ExportFormatBase { void set_normalize_target (float value) { _normalize_target = value; } void set_tag (bool tag_it) { _tag = tag_it; } + void set_with_cue (bool yn) { _with_cue = yn; } + void set_with_toc (bool yn) { _with_toc = yn; } void set_silence_beginning (AnyTime const & value) { _silence_beginning = value; } void set_silence_end (AnyTime const & value) { _silence_end = value; } @@ -120,6 +122,8 @@ class ExportFormatSpecification : public ExportFormatBase { bool trim_end () const { return _trim_end; } bool normalize () const { return _normalize; } float normalize_target () const { return _normalize_target; } + bool with_toc() const { return _with_toc; } + bool with_cue() const { return _with_cue; } bool tag () const { return _tag && supports_tagging; } @@ -167,6 +171,8 @@ class ExportFormatSpecification : public ExportFormatBase { bool _normalize; float _normalize_target; + bool _with_toc; + bool _with_cue; /* serialization helpers */ diff --git a/libs/ardour/export_format_manager.cc b/libs/ardour/export_format_manager.cc index c77e301a23..f995bc1b0e 100644 --- a/libs/ardour/export_format_manager.cc +++ b/libs/ardour/export_format_manager.cc @@ -264,6 +264,18 @@ ExportFormatManager::select_src_quality (ExportFormatBase::SRCQuality value) current_selection->set_src_quality (value); } +void +ExportFormatManager::select_with_cue (bool value) +{ + current_selection->set_with_cue (value); +} + +void +ExportFormatManager::select_with_toc (bool value) +{ + current_selection->set_with_toc (value); +} + void ExportFormatManager::select_trim_beginning (bool value) { diff --git a/libs/ardour/export_format_specification.cc b/libs/ardour/export_format_specification.cc index 619c50b9f9..6fad14d86a 100644 --- a/libs/ardour/export_format_specification.cc +++ b/libs/ardour/export_format_specification.cc @@ -167,6 +167,8 @@ ExportFormatSpecification::ExportFormatSpecification (Session & s) , _normalize (false) , _normalize_target (1.0) + , _with_toc (false) + , _with_cue (false) { format_ids.insert (F_None); endiannesses.insert (E_FileDefault); @@ -235,6 +237,8 @@ ExportFormatSpecification::get_state () root->add_property ("name", _name); root->add_property ("id", _id.to_s()); + root->add_property ("with-cue", _with_cue ? "true" : "false"); + root->add_property ("with-toc", _with_toc ? "true" : "false"); node = root->add_child ("Encoding"); node->add_property ("id", enum_2_string (format_id())); @@ -300,6 +304,18 @@ ExportFormatSpecification::set_state (const XMLNode & root) _id = prop->value(); } + if ((prop = root.property ("with-cue"))) { + _with_cue = string_is_affirmative (prop->value()); + } else { + _with_cue = false; + } + + if ((prop = root.property ("with-toc"))) { + _with_toc = string_is_affirmative (prop->value()); + } else { + _with_toc = false; + } + /* Encoding and SRC */ if ((child = root.child ("Encoding"))) { @@ -320,7 +336,11 @@ ExportFormatSpecification::set_state (const XMLNode & root) } if ((prop = child->property ("has-sample-format"))) { - has_sample_format = !prop->value().compare ("true"); + has_sample_format = string_is_affirmative (prop->value()); + } + + if ((prop = child->property ("has-sample-format"))) { + has_sample_format = string_is_affirmative (prop->value()); } if ((prop = child->property ("channel-limit"))) { diff --git a/libs/ardour/export_handler.cc b/libs/ardour/export_handler.cc index 91b3429bff..f19dfe048c 100644 --- a/libs/ardour/export_handler.cc +++ b/libs/ardour/export_handler.cc @@ -237,6 +237,17 @@ void ExportHandler::finish_timespan () { while (config_map.begin() != timespan_bounds.second) { + + ExportFormatSpecPtr fmt = config_map.begin()->second.format; + + if (fmt->with_cue()) { + export_cd_marker_file (current_timespan, fmt, config_map.begin()->second.filename->get_path(fmt), CDMarkerCUE); + } + + if (fmt->with_toc()) { + export_cd_marker_file (current_timespan, fmt, config_map.begin()->second.filename->get_path(fmt), CDMarkerTOC); + } + config_map.erase (config_map.begin()); } @@ -256,12 +267,11 @@ ExportHandler::export_cd_marker_file (ExportTimespanPtr timespan, ExportFormatSp std::string filename, CDMarkerFormat format) { string filepath; - string basename = Glib::path_get_basename(filename); - size_t ext_pos = basename.rfind('.'); - if (ext_pos != string::npos) { - basename = basename.substr(0, ext_pos); /* strip file extension, if there is one */ - } + /* do not strip file suffix because there may be more than one format, + and we do not want the CD marker file from one format to overwrite + another (e.g. foo.wav.cue > foo.aiff.cue) + */ void (ExportHandler::*header_func) (CDMarkerStatus &); void (ExportHandler::*track_func) (CDMarkerStatus &); @@ -269,13 +279,15 @@ ExportHandler::export_cd_marker_file (ExportTimespanPtr timespan, ExportFormatSp switch (format) { case CDMarkerTOC: - filepath = Glib::build_filename(Glib::path_get_dirname(filename), basename + ".toc"); + filepath = filename; + filepath += ".toc"; header_func = &ExportHandler::write_toc_header; track_func = &ExportHandler::write_track_info_toc; index_func = &ExportHandler::write_index_info_toc; break; case CDMarkerCUE: - filepath = Glib::build_filename(Glib::path_get_dirname(filename), basename + ".cue"); + filepath = filename; + filepath += ".cue"; header_func = &ExportHandler::write_cue_header; track_func = &ExportHandler::write_track_info_cue; index_func = &ExportHandler::write_index_info_cue; diff --git a/libs/ardour/session_export.cc b/libs/ardour/session_export.cc index 7737e95279..4f46535a97 100644 --- a/libs/ardour/session_export.cc +++ b/libs/ardour/session_export.cc @@ -178,7 +178,7 @@ Session::process_export (pframes_t nframes) ProcessExport (nframes); } catch (std::exception & e) { - std::cout << e.what() << std::endl; + error << string_compose (_("Export ended unexpectedly: %1"), e.what()) << endmsg; export_status->abort (true); } } @@ -222,6 +222,9 @@ Session::finalize_audio_export () _engine.freewheel (false); export_freewheel_connection.disconnect(); + + /* maybe write CUE/TOC */ + export_handler.reset(); export_status.reset(); diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc index cc02386bf4..1c52a6f638 100644 --- a/libs/ardour/utils.cc +++ b/libs/ardour/utils.cc @@ -643,7 +643,8 @@ string_is_affirmative (const std::string& str) * in the way we desire when doing it in C. */ - return str == "1" || str == "y" || str == "Y" || (!g_strncasecmp(str.c_str(), "yes", str.length())); + return str == "1" || str == "y" || str == "Y" || (!g_strncasecmp(str.c_str(), "yes", str.length())) || + (!g_strncasecmp(str.c_str(), "true", str.length())); } const char* -- cgit v1.2.3