#include <sstream>
+#include <glibmm/miscutils.h>
+
#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"
string
AudioRegionImporter::get_info () const
{
- nframes_t length, position;
+ framecnt_t length, position;
Timecode::Time length_time, position_time;
std::ostringstream oss;
iss_position >> position;
// Convert to timecode
- session.sample_to_timecode(length, length_time, false);
- session.sample_to_timecode(position, position_time, false);
+ session.sample_to_timecode(length, length_time, true, false);
+ session.sample_to_timecode(position, position_time, true, false);
// return info
oss << _("Length: ") <<
{
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;
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;
}
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
}
// create region and update XML
- region.push_back (RegionFactory::create (source_list, xml_region));
+ boost::shared_ptr<Region> 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 {
// import files
// TODO: threading & exception handling
- session.import_audiofiles (status);
+ session.import_files (status);
// Add imported sources to handlers map
std::vector<string>::iterator file_it = status.paths.begin();