55 if ((ar = boost::dynamic_pointer_cast<const AudioRegion>(region)) != 0) {
59 }
else if ((mr = boost::dynamic_pointer_cast<const MidiRegion>(region)) != 0) {
67 const std::string ancestor_name = mr->
sources().front()->ancestor_name();
72 ret = mr->
clone(source);
78 fatal <<
_(
"programming error: RegionFactory::create() called with unknown Region type")
87 if (ret->
session().
config.get_glue_new_regions_to_bars_and_beats ()) {
98 #ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
111 if ((other_a = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
115 }
else if ((other_m = boost::dynamic_pointer_cast<MidiRegion>(region)) != 0) {
120 fatal <<
_(
"programming error: RegionFactory::create() called with unknown Region type")
129 if (ret->
session().
config.get_glue_new_regions_to_bars_and_beats ()) {
135 CheckNewRegion (ret);
139 #ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
152 if ((other_a = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
156 }
else if ((other_m = boost::dynamic_pointer_cast<MidiRegion>(region)) != 0) {
161 fatal <<
_(
"programming error: RegionFactory::create() called with unknown Region type")
170 if (ret->
session().
config.get_glue_new_regions_to_bars_and_beats ()) {
176 CheckNewRegion (ret);
180 #ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
196 if ((other = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
203 fatal <<
_(
"programming error: RegionFactory::create() called with unknown Region type")
211 if (ret->
session().
config.get_glue_new_regions_to_bars_and_beats ()) {
217 CheckNewRegion (ret);
221 #ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
231 srcs.push_back (src);
232 return create (srcs, plist, announce);
242 if ((as = boost::dynamic_pointer_cast<AudioSource>(srcs[0])) != 0) {
246 }
else if ((ms = boost::dynamic_pointer_cast<MidiSource>(srcs[0])) != 0) {
255 if (ret->
session().
config.get_glue_new_regions_to_bars_and_beats ()) {
261 CheckNewRegion (ret);
265 #ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
306 CheckNewRegion (ret);
310 #ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
319 pair<ID,boost::shared_ptr<Region> > p;
325 region_map.insert (p);
328 if (!region_list_connections) {
335 add_to_region_name_maps (r);
347 RegionMap::iterator i = region_map.find (r->
id());
349 if (i != region_map.end()) {
350 remove_from_region_name_map (i->second->name ());
351 region_map.erase (i);
358 RegionMap::iterator i = region_map.find (
id);
360 if (i == region_map.end()) {
370 for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) {
371 if (i->second->whole_file() && i->second->name() ==
name) {
381 for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) {
382 if (i->second->name() ==
name) {
392 if (region_list_connections) {
393 region_list_connections->drop_connections ();
399 _compound_associations.clear ();
400 region_name_map.clear ();
419 for (RegionMap::iterator i = copy.begin(); i != copy.end(); ++i) {
420 i->second->drop_references ();
432 return region_map.size ();
439 update_region_name_number_map (region);
442 region_name_map[region->
name()] = region->
id ();
449 update_region_name_number_map (region);
453 map<string, PBD::ID>::iterator i = region_name_map.begin();
454 while (i != region_name_map.end() && i->second != region->
id ()) {
459 if (i != region_name_map.end()) {
460 region_name_map.erase (i);
461 region_name_map[region->
name()] = region->
id ();
469 map<string, PBD::ID>::iterator i = region_name_map.find (n);
470 if (i != region_name_map.end ()) {
471 region_name_map.erase (i);
479 string::size_type
const last_period = region->
name().find_last_of (
'.');
481 if (last_period != string::npos && last_period < region->
name().
length() - 1) {
483 string const base = region->
name().substr (0, last_period);
484 string const number = region->
name().substr (last_period + 1);
491 region_name_number_map[base] =
atoi (number.c_str ());
504 rename_in_region_name_maps (r);
514 if (base.find(
"/") != string::npos) {
515 base = base.substr(base.find_last_of(
"/") + 1);
529 string::size_type pos;
531 pos = base.find_last_of (
'.');
535 subbase = base.substr (0, pos);
542 map<string,uint32_t>::iterator x;
546 if ((x = region_name_number_map.find (subbase)) == region_name_number_map.end()) {
548 region_name_number_map[subbase] = 1;
551 snprintf (buf,
sizeof (buf),
".%d", x->second);
565 return string_compose (
_(
"%1 compound-%2 (%3)"), playlist, compound_ops+1, depth+1);
567 return string_compose (
_(
"%1 compound-%2.1 (%3)"), playlist, compound_ops+1, depth+1);
574 string::size_type last_period;
576 string::size_type len = old.length() + 64;
578 std::vector<char> buf(len);
580 if ((last_period = old.find_last_of (
'.')) == string::npos) {
585 last_period = old.length() - 1;
590 if (last_period < old.length() - 1) {
592 string period_to_end = old.substr (last_period+1);
596 string::size_type numerals_end = period_to_end.find_first_not_of (
"0123456789");
598 number =
atoi (period_to_end);
600 if (numerals_end < period_to_end.length() - 1) {
602 remainder = period_to_end.substr (numerals_end);
606 last_period = old.length();
611 while (number < (UINT_MAX-1)) {
617 snprintf (&buf[0], len,
"%s%" PRIu32
"%s", old.substr (0, last_period + 1).c_str(), number, remainder.c_str());
620 if (region_name_map.find (sbuf) == region_name_map.end ()) {
625 if (number != (UINT_MAX-1)) {
638 for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) {
639 if (i->second->uses_source (s)) {
640 r.insert (i->second);
650 RegionMap::iterator i = region_map.begin();
651 while (i != region_map.end()) {
653 RegionMap::iterator j = i;
656 if (i->second->uses_source (src)) {
657 remove_from_region_name_map (i->second->name ());
658 region_map.erase (i);
669 _compound_associations[copy] = orig;
std::map< PBD::ID, boost::shared_ptr< Region > > RegionMap
static std::map< std::string, PBD::ID > region_name_map
LIBPBD_API Transmitter fatal
static int region_name(std::string &, std::string, bool new_level=false)
int atoi(const string &s)
PBD::Signal0< void > DropReferences
PBD::Signal1< void, const PropertyChange & > PropertyChanged
static boost::shared_ptr< Region > region_by_name(const std::string &name)
Session & session() const
static void add_to_region_name_maps(boost::shared_ptr< Region >)
static void map_remove(boost::weak_ptr< Region >)
void set_ancestor_name(const std::string &name)
std::map< boost::shared_ptr< Region >, boost::shared_ptr< Region > > CompoundAssociations
LIBARDOUR_API PBD::PropertyDescriptor< std::string > name
boost::shared_ptr< MidiSource > create_midi_source_for_session(std::string const &)
static void remove_from_region_name_map(std::string)
static void delete_all_regions()
static void update_region_name_number_map(boost::shared_ptr< Region >)
const SourceList & sources() const
bool set_name(const std::string &str)
static Glib::Threads::Mutex region_name_maps_mutex
boost::shared_ptr< Region > XMLRegionFactory(const XMLNode &, bool full)
static std::map< std::string, uint32_t > region_name_number_map
static void add_compound_association(boost::shared_ptr< Region >, boost::shared_ptr< Region >)
LIBPBD_API Transmitter error
boost::shared_ptr< MidiRegion > clone(std::string path=std::string()) const
std::ostream & endmsg(std::ostream &ostr)
SessionConfiguration config
static Glib::Threads::Mutex region_map_lock
static uint32_t nregions()
static void map_add(boost::shared_ptr< Region >)
static std::string new_region_name(std::string)
virtual int set_state(const XMLNode &, int version)
virtual bool apply_changes(PropertyBase const &)
void set_position(framepos_t)
static CompoundAssociations _compound_associations
static PBD::ScopedConnectionList * region_list_connections
const PBD::ID & id() const
static boost::shared_ptr< Region > wholefile_region_by_name(const std::string &name)
static PBD::Signal1< void, boost::shared_ptr< Region > > CheckNewRegion
static int loading_state_version
static void remove_regions_using_source(boost::shared_ptr< Source >)
static std::string compound_region_name(const std::string &playlist, uint32_t compound_ops, uint32_t depth, bool whole_source)
framepos_t position() const
LIBPBD_API Glib::ustring basename_nosuffix(Glib::ustring)
static void region_changed(PBD::PropertyChange const &, boost::weak_ptr< Region >)
bool contains(PropertyDescriptor< T > p) const
void set_position_lock_style(PositionLockStyle ps)
static boost::shared_ptr< Region > region_by_id(const PBD::ID &)
static void rename_in_region_name_maps(boost::shared_ptr< Region >)
static void get_regions_using_source(boost::shared_ptr< Source >, std::set< boost::shared_ptr< Region > > &)
static boost::shared_ptr< Region > create(boost::shared_ptr< const Region > other, bool announce=false)
std::vector< boost::shared_ptr< Source > > SourceList
static RegionMap region_map
std::string string_compose(const std::string &fmt, const T1 &o1)
LIBARDOUR_API PBD::PropertyDescriptor< framecnt_t > length