X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Faudio_region_importer.cc;h=53367a35a443282d752ee5b99546b06b27ae97a5;hb=848db8fbd56dbae1ad286b7791dba293462b5f43;hp=19653f55c0a16a72a900c8a60b03b14dcfbf6746;hpb=bb9cc45cd22af67ac275a5e73accbe14fee664d8;p=ardour.git diff --git a/libs/ardour/audio_region_importer.cc b/libs/ardour/audio_region_importer.cc index 19653f55c0..53367a35a4 100644 --- a/libs/ardour/audio_region_importer.cc +++ b/libs/ardour/audio_region_importer.cc @@ -22,13 +22,14 @@ #include +#include + #include "pbd/failed_constructor.h" #include "pbd/compose.h" #include "pbd/error.h" #include "ardour/session.h" #include "ardour/region.h" -#include "ardour/source_factory.h" #include "ardour/region_factory.h" #include "ardour/session_directory.h" @@ -126,8 +127,8 @@ AudioRegionImporter::~AudioRegionImporter () string AudioRegionImporter::get_info () const { - nframes_t length, position; - SMPTE::Time length_time, position_time; + framecnt_t length, position; + Timecode::Time length_time, position_time; std::ostringstream oss; // Get sample positions @@ -136,15 +137,15 @@ AudioRegionImporter::get_info () const std::istringstream iss_position(xml_region.property ("position")->value()); iss_position >> position; - // Convert to smpte - session.sample_to_smpte(length, length_time, true, false); - session.sample_to_smpte(position, position_time, true, false); + // Convert to timecode + session.sample_to_timecode(length, length_time, true, false); + session.sample_to_timecode(position, position_time, true, false); // return info oss << _("Length: ") << - smpte_to_string(length_time) << + timecode_to_string(length_time) << _("\nPosition: ") << - smpte_to_string(position_time) << + timecode_to_string(position_time) << _("\nChannels: ") << xml_region.property ("channels")->value(); @@ -176,8 +177,6 @@ AudioRegionImporter::_move () if (broken()) { return; } - - session.add_regions (region); } bool @@ -209,7 +208,7 @@ AudioRegionImporter::parse_xml_region () } else if (!prop.compare("name")) { // rename region if necessary name = (*it)->value(); - name = session.new_region_name (name); + name = RegionFactory::new_region_name (name); (*it)->set_value (name); name_ok = true; } else { @@ -235,8 +234,7 @@ AudioRegionImporter::parse_source_xml () { uint32_t channels; char buf[128]; - PBD::sys::path source_dir = get_sound_dir (source); - PBD::sys::path source_path; + std::string source_dir(get_sound_dir (source)); XMLNode * source_node; XMLProperty *prop; @@ -252,7 +250,7 @@ AudioRegionImporter::parse_source_xml () return false; } - channels = atoi (prop->value()); + channels = atoi (prop->value().c_str()); for (uint32_t i = 0; i < channels; ++i) { bool source_found = false; @@ -266,18 +264,15 @@ AudioRegionImporter::parse_source_xml () string source_id = prop->value(); // Get source - for (XMLNodeList::const_iterator it = sources.begin(); it != sources.end(); it++) { + for (XMLNodeList::const_iterator it = sources.begin(); it != sources.end(); ++it) { prop = (*it)->property ("id"); if (prop && !source_id.compare (prop->value())) { - source_path = source_dir; prop = (*it)->property ("name"); if (!prop) { error << string_compose (X_("AudioRegionImporter (%1): source %2 has no \"name\" property"), name, source_id) << endmsg; return false; } - source_path /= prop->value(); - filenames.push_back (source_path.to_string()); - + filenames.push_back (Glib::build_filename (source_dir, prop->value())); source_found = true; break; } @@ -292,15 +287,11 @@ AudioRegionImporter::parse_source_xml () return true; } -PBD::sys::path +std::string AudioRegionImporter::get_sound_dir (XMLTree const & tree) { - PBD::sys::path source_dir = tree.filename(); - source_dir = source_dir.branch_path(); - SessionDirectory session_dir(source_dir); - source_dir = session_dir.sound_path(); - - return source_dir; + SessionDirectory session_dir(Glib::path_get_dirname (tree.filename())); + return session_dir.sound_path(); } void @@ -319,7 +310,11 @@ AudioRegionImporter::prepare_region () } // create region and update XML - region.push_back (RegionFactory::create (source_list, xml_region)); + boost::shared_ptr r = RegionFactory::create (source_list, xml_region); + if (session.config.get_glue_new_regions_to_bars_and_beats ()) { + r->set_position_lock_style (MusicTime); + } + region.push_back (r); if (*region.begin()) { xml_region = (*region.begin())->get_state(); } else { @@ -355,10 +350,10 @@ AudioRegionImporter::prepare_sources () // import files // TODO: threading & exception handling - session.import_audiofiles (status); + session.import_files (status); // Add imported sources to handlers map - std::vector::iterator file_it = status.paths.begin(); + std::vector::iterator file_it = status.paths.begin(); for (SourceList::iterator source_it = status.sources.begin(); source_it != status.sources.end(); ++source_it) { if (*source_it) { handler.add_source(*file_it, *source_it);