25 #include <glibmm/miscutils.h>
43 AudioRegionImportHandler::AudioRegionImportHandler (
XMLTree const & source,
Session & session) :
49 if (!(regions = root->
child (
X_(
"Regions")))) {
60 for (XMLNodeList::const_iterator it = children.begin(); it != children.end(); ++it) {
62 if (!(*it)->name().compare (
"Region") && (!type || type->
value() ==
"audio") ) {
75 return _(
"Audio Regions");
93 return (
sources.find (filename))->second;
105 return (
id_map.find (old_id))->second;
114 region_prepared (false),
115 sources_prepared (false)
131 Timecode::Time length_time, position_time;
132 std::ostringstream oss;
145 oss <<
_(
"Length: ") <<
187 bool name_ok =
false;
189 for (XMLPropertyList::const_iterator it = props.begin(); it != props.end(); ++it) {
190 string prop = (*it)->name();
191 if (!prop.compare (
"type") || !prop.compare (
"stretch") ||
192 !prop.compare (
"shift") || !prop.compare (
"first_edit") ||
193 !prop.compare (
"layer") || !prop.compare (
"flags") ||
194 !prop.compare (
"scale-gain") || !prop.compare(
"channels") ||
195 !prop.compare (
"first-edit") ||
196 prop.find (
"master-source-") == 0 || prop.find (
"source-") == 0) {
198 }
else if (!prop.compare (
"start") || !prop.compare (
"length") ||
199 !prop.compare (
"position") || !prop.compare (
"ancestral-start") ||
200 !prop.compare (
"ancestral-length") || !prop.compare (
"sync-position")) {
203 }
else if (!prop.compare(
"id")) {
206 (*it)->set_value (
id.to_s());
208 }
else if (!prop.compare(
"name")) {
210 name = (*it)->value();
212 (*it)->set_value (
name);
225 error <<
X_(
"AudioRegionImporter: did not find necessary XML-property \"name\"") <<
endmsg;
254 for (uint32_t i = 0; i < channels; ++i) {
255 bool source_found =
false;
258 snprintf (buf,
sizeof(buf),
X_(
"source-%d"), i);
264 string source_id = prop->
value();
267 for (XMLNodeList::const_iterator it = sources.begin(); it != sources.end(); ++it) {
268 prop = (*it)->property (
"id");
269 if (prop && !source_id.compare (prop->
value())) {
270 prop = (*it)->property (
"name");
275 filenames.push_back (Glib::build_filename (source_dir, prop->
value()));
308 for (std::list<string>::iterator it =
filenames.begin(); it !=
filenames.end(); ++it) {
314 if (
session.
config.get_glue_new_regions_to_bars_and_beats ()) {
344 for (std::list<string>::iterator it =
filenames.begin(); it !=
filenames.end(); ++it) {
356 std::vector<string>::iterator file_it =
status.
paths.begin();
383 for (std::list<string>::iterator it =
filenames.begin(); it !=
filenames.end(); ++it) {
AudioRegionImporter(XMLTree const &source, Session &session, AudioRegionImportHandler &handler, XMLNode const &node)
PBD::ID const & get_new_id(PBD::ID &old_id) const
std::pair< PBD::ID, PBD::ID > IdPair
int atoi(const string &s)
const XMLPropertyList & properties() const
std::string name
Name of element.
const std::string & value() const
boost::shared_ptr< Source > const & get_source(std::string const &filename) const
void add_sources_to_session()
std::list< XMLProperty * > XMLPropertyList
std::string get_info() const
LIBPBD_API Transmitter error
const XMLNodeList & children(const std::string &str=std::string()) const
std::ostream & endmsg(std::ostream &ostr)
SessionConfiguration config
bool check_source(std::string const &filename) const
ARDOUR::Session & session
Target session.
framecnt_t rate_convert_samples(framecnt_t samples) const
Converts samples so that times match the sessions sample rate.
AudioRegionImportHandler & handler
std::list< XMLNode * > XMLNodeList
std::list< std::string > filenames
static std::string new_region_name(std::string)
Virtual interface class for element importers.
std::pair< std::string, boost::shared_ptr< Source > > SourcePair
XMLProperty * property(const char *)
ARDOUR::Session & session
Destination session.
XMLTree const & source
Source session XML tree.
const std::string & filename() const
std::vector< boost::shared_ptr< Region > > region
XMLNode const & get_xml()
const std::string sound_path() const
std::string get_sound_dir(XMLTree const &tree)
LIBARDOUR_API PBD::PropertyDescriptor< bool > regions
std::string get_info() const
void sample_to_timecode(framepos_t sample, Timecode::Time &timecode, bool use_offset, bool use_subframes) const
void add_source(std::string const &filename, boost::shared_ptr< Source > const &source)
bool replace_existing_source
Virtual interface class for element import handlers.
std::list< ElementPtr > ElementList
ElementList elements
Elements this handler handles.
XMLTree const & source
Source XML-tree.
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > position
void _cancel_move()
Cancel move.
void add_source(boost::shared_ptr< Source >)
std::string timecode_to_string(Timecode::Time &time) const
Converts timecode time to a string.
void set_broken()
Set element broken.
void register_id(PBD::ID &old_id, PBD::ID &new_id)
XMLNode * child(const char *) const
static void set_errors()
Sets handler dirty.
void import_files(ImportStatus &)
void set_position_lock_style(PositionLockStyle ps)
void create_regions_from_children(XMLNode const &node, ElementList &list)
static boost::shared_ptr< Region > create(boost::shared_ptr< const Region > other, bool announce=false)
std::vector< std::string > paths
static void set_dirty()
Sets handler dirty.
std::vector< boost::shared_ptr< Source > > SourceList
bool broken()
Check if element is broken. Cannot be moved if broken.
std::string string_compose(const std::string &fmt, const T1 &o1)
LIBARDOUR_API PBD::PropertyDescriptor< framecnt_t > length