26 #include <glibmm/threads.h>
29 #include "ardour/debug.h"
77 PBD::Signal2<void,boost::shared_ptr<ARDOUR::Region>,
const PropertyChange&> Region::RegionPropertyChanged;
135 Region::register_properties ()
137 _xml_node_name =
X_(
"Region");
165 #define REGION_DEFAULT_STATE(s,l) \
166 _sync_marked (Properties::sync_marked, false) \
167 , _left_of_split (Properties::left_of_split, false) \
168 , _right_of_split (Properties::right_of_split, false) \
169 , _valid_transients (Properties::valid_transients, false) \
170 , _start (Properties::start, (s)) \
171 , _length (Properties::length, (l)) \
172 , _position (Properties::position, 0) \
173 , _sync_position (Properties::sync_position, (s)) \
174 , _muted (Properties::muted, false) \
175 , _opaque (Properties::opaque, true) \
176 , _locked (Properties::locked, false) \
177 , _video_locked (Properties::video_locked, false) \
178 , _automatic (Properties::automatic, false) \
179 , _whole_file (Properties::whole_file, false) \
180 , _import (Properties::import, false) \
181 , _external (Properties::external, false) \
182 , _hidden (Properties::hidden, false) \
183 , _position_locked (Properties::position_locked, false) \
184 , _ancestral_start (Properties::ancestral_start, (s)) \
185 , _ancestral_length (Properties::ancestral_length, (l)) \
186 , _stretch (Properties::stretch, 1.0) \
187 , _shift (Properties::shift, 1.0) \
188 , _position_lock_style (Properties::position_lock_style, _type == DataType::AUDIO ? AudioTime : MusicTime) \
189 , _layering_index (Properties::layering_index, 0)
191 #define REGION_COPY_STATE(other) \
192 _sync_marked (Properties::sync_marked, other->_sync_marked) \
193 , _left_of_split (Properties::left_of_split, other->_left_of_split) \
194 , _right_of_split (Properties::right_of_split, other->_right_of_split) \
195 , _valid_transients (Properties::valid_transients, other->_valid_transients) \
196 , _start(Properties::start, other->_start) \
197 , _length(Properties::length, other->_length) \
198 , _position(Properties::position, other->_position) \
199 , _sync_position(Properties::sync_position, other->_sync_position) \
200 , _muted (Properties::muted, other->_muted) \
201 , _opaque (Properties::opaque, other->_opaque) \
202 , _locked (Properties::locked, other->_locked) \
203 , _video_locked (Properties::video_locked, other->_video_locked) \
204 , _automatic (Properties::automatic, other->_automatic) \
205 , _whole_file (Properties::whole_file, other->_whole_file) \
206 , _import (Properties::import, other->_import) \
207 , _external (Properties::external, other->_external) \
208 , _hidden (Properties::hidden, other->_hidden) \
209 , _position_locked (Properties::position_locked, other->_position_locked) \
210 , _ancestral_start (Properties::ancestral_start, other->_ancestral_start) \
211 , _ancestral_length (Properties::ancestral_length, other->_ancestral_length) \
212 , _stretch (Properties::stretch, other->_stretch) \
213 , _shift (Properties::shift, other->_shift) \
214 , _position_lock_style (Properties::position_lock_style, other->_position_lock_style) \
215 , _layering_index (Properties::layering_index, other->_layering_index)
222 , _last_length (length)
227 register_properties ();
235 , _type (srcs.front()->type())
244 _type = srcs.front()->type();
249 assert (
_type == srcs.front()->type());
255 , _type (other->data_type())
257 , _last_length (other->_last_length)
258 , _last_position(other->_last_position) \
260 , _layer (other->_layer)
309 if (_sync_position < _start || _sync_position >=
_start +
_length) {
325 , _type (other->data_type())
327 , _last_length (other->_last_length)
328 , _last_position(other->_last_position) \
330 , _layer (other->_layer)
368 if (_sync_position < _start || _sync_position >=
_start +
_length) {
380 , _type (srcs.front()->type())
382 , _last_length (other->_last_length)
383 , _last_position (other->_last_position)
384 , _first_edit (EditChangesID)
385 , _layer (other->_layer)
421 assert(
_name == str);
437 if (
_length != len && len != 0) {
506 if (whole_file_region) {
526 if (whole_file_region) {
617 if (allow_bbt_recompute) {
714 new_start =
_start + distance;
721 }
else if (distance < 0) {
726 new_start =
_start + distance;
733 if (new_start ==
_start) {
779 if (new_position < end) {
786 new_position = max (new_position, source_zero);
867 if (start_shift > 0) {
872 new_start =
_start + start_shift;
875 }
else if (start_shift < 0) {
880 new_start =
_start + start_shift;
893 if (
_start != new_start) {
906 if (_position != position) {
929 if (what_changed.
contains (start_and_length)) {
933 if (!what_changed.empty()) {
1142 const char* fe = NULL;
1149 if (!strcmp(i->second->property_name(), (
const char*)
"Envelope"))
continue;
1150 if (!strcmp(i->second->property_name(), (
const char*)
"FadeIn"))
continue;
1151 if (!strcmp(i->second->property_name(), (
const char*)
"FadeOut"))
continue;
1152 if (!strcmp(i->second->property_name(), (
const char*)
"InverseFadeIn"))
continue;
1153 if (!strcmp(i->second->property_name(), (
const char*)
"InverseFadeOut"))
continue;
1154 i->second->get_value (*node);
1157 id().
print (buf,
sizeof (buf));
1186 for (uint32_t n=0; n <
_sources.size(); ++n) {
1187 snprintf (buf2,
sizeof(buf2),
"source-%d", n);
1188 _sources[n]->id().print (buf,
sizeof(buf));
1193 snprintf (buf2,
sizeof(buf2),
"master-source-%d", n);
1211 for (SourceList::const_iterator s =
_sources.begin(); s !=
_sources.end(); ++s) {
1237 return _set_state (node, version, what_changed,
true);
1252 if ((prop = node.
property (
"bbt-position")) == 0) {
1256 if (sscanf (prop->
value().c_str(),
"%d|%d|%d",
1282 if (string::npos != prop->
value().find(
"Muted")){
1313 if (what_changed.empty()) {
1382 SourceList::iterator i;
1384 vector<string> names;
1386 names.push_back((*i)->name());
1396 (*i)->dec_use_count ();
1403 (*i)->inc_use_count ();
1418 SourceList::const_iterator i;
1419 SourceList::const_iterator io;
1422 if ((*i)->id() != (*io)->id()) {
1428 if ((*i)->id() != (*io)->id()) {
1443 SourceList::const_iterator i;
1444 SourceList::const_iterator io;
1447 if ((*i)->id() == (*io)->id()) {
1463 SourceList::const_iterator i;
1466 res << (*i)->id() <<
":";
1470 res << (*i)->id() <<
":";
1479 for (SourceList::const_iterator i =
_sources.begin(); i !=
_sources.end(); ++i) {
1487 if (ps->
playlist()->uses_source (source)) {
1501 if (ps->
playlist()->uses_source (source)) {
1526 for (uint32_t n = 0; n <
_sources.size(); ++n) {
1530 len = min (len, maxlen);
1544 for (uint32_t n = 0; n <
_sources.size(); ++n) {
1548 new_length = min (new_length, maxlen);
1560 for (uint32_t n = 0; n <
_sources.size(); ++n) {
1575 for (uint32_t n = 0; n <
_sources.size(); ++n) {
1603 return filter.
run (shared_from_this(), progress);
1619 for (SourceList::const_iterator i =
_sources.begin (); i !=
_sources.end(); ++i) {
1620 (*i)->dec_use_count ();
1626 (*i)->dec_use_count ();
1635 set<boost::shared_ptr<Source> > unique_srcs;
1637 for (SourceList::const_iterator i = s.begin (); i != s.end(); ++i) {
1640 (*i)->inc_use_count ();
1642 (*i)->inc_use_count ();
1647 if (unique_srcs.find (*i) == unique_srcs.end ()) {
1648 unique_srcs.insert (*i);
1686 for (SourceList::const_iterator i =
_sources.begin(); i !=
_sources.end(); ++i) {
1687 lvl = max (lvl, (*i)->level());
1728 for (SourceList::const_iterator i =
_sources.begin(); i !=
_sources.end(); ++i) {
1732 minlen = min (minlen, (*i)->length (
_position));
virtual void set_playlist(boost::weak_ptr< ARDOUR::Playlist >)
AnalysisFeatureList _transients
PBD::Property< bool > _automatic
ARDOUR::Session & _session
PBD::Property< bool > _muted
bool property_changes_suspended() const
void trim_front(framepos_t new_position)
virtual void send_change(const PropertyChange &)
bool verify_start_and_length(framepos_t, framecnt_t &)
void set_position_locked(bool yn)
const std::string & value() const
PBD::Property< bool > _position_locked
PBD::Property< framepos_t > _ancestral_start
void save_extra_xml(const XMLNode &)
virtual void suspend_property_changes()
void set_ancestral_data(framepos_t start, framecnt_t length, float stretch, float shift)
LIBARDOUR_API PBD::PropertyDescriptor< layer_t > layer
void cut_end(framepos_t new_position)
LIBARDOUR_API uint64_t Destruction
LIBARDOUR_API PBD::PropertyDescriptor< bool > hidden
framepos_t _last_position
framepos_t latest_possible_frame() const
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > ancestral_start
LIBARDOUR_API PBD::PropertyDescriptor< bool > video_locked
bool uses_source(boost::shared_ptr< const Source >) const
void special_set_position(framepos_t)
const char * to_string() const
shared_ptr< T > dynamic_pointer_cast(shared_ptr< U > const &r)
LIBARDOUR_API PBD::PropertyDescriptor< std::string > name
bool equivalent(boost::shared_ptr< const Region >) const
void post_set(const PBD::PropertyChange &)
void move_start(frameoffset_t distance)
void raise_region(boost::shared_ptr< Region >)
void source_deleted(boost::weak_ptr< Source >)
bool set_name(const std::string &str)
boost::shared_ptr< Region > find_whole_file_parent(boost::shared_ptr< Region const >) const
XMLNode * add_child_copy(const XMLNode &)
virtual int run(boost::shared_ptr< ARDOUR::Region >, Progress *progress=0)=0
#define REGION_DEFAULT_STATE(s, l)
bool verify_length(framecnt_t &)
PBD::Property< bool > _whole_file
PBD::Property< framepos_t > _sync_position
boost::shared_ptr< Source > source(uint32_t n=0) const
void set_video_locked(bool yn)
void modify_end(framepos_t new_position, bool reset_fade)
PropertyChange set_values(XMLNode const &)
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > start
virtual int _set_state(const XMLNode &, int version, PBD::PropertyChange &what_changed, bool send_signal)
PBD::Property< bool > _left_of_split
LIBARDOUR_API PBD::PropertyDescriptor< float > stretch
void set_sync_position(framepos_t n)
framepos_t frame_time(const Timecode::BBT_Time &)
OwnedPropertyList * _properties
PBD::Property< float > _stretch
framepos_t sync_position() const
PBD::Property< bool > _valid_transients
PBD::Property< bool > _right_of_split
PBD::Property< bool > _locked
bool source_equivalent(boost::shared_ptr< const Region >) const
void use_sources(SourceList const &)
void trim_end(framepos_t new_position)
void trim_to_internal(framepos_t position, framecnt_t length)
virtual void update_after_tempo_map_change()
virtual void recompute_at_start()=0
void invalidate_transients()
static std::string new_region_name(std::string)
SourceList _master_sources
virtual int set_state(const XMLNode &, int version)
Region(const SourceList &srcs)
Trimmable::CanTrim can_trim() const
const DataType & data_type() const
LIBARDOUR_API PBD::PropertyDescriptor< bool > automatic
PBD::Property< framepos_t > _start
void set_master_sources(const SourceList &)
boost::shared_ptr< const Playlist > playlist() const
void set_layer(layer_t l)
virtual bool can_trim_start_before_source_start() const
XMLProperty * property(const char *)
void set_position(framepos_t)
bool video_locked() const
RegionEditState _first_edit
void cut_front(framepos_t new_position)
PBD::Property< bool > _sync_marked
virtual void set_position_internal(framepos_t pos, bool allow_bbt_recompute)
bool overlap_equivalent(boost::shared_ptr< const Region >) const
LIBARDOUR_API PBD::PropertyDescriptor< float > shift
void mid_thaw(const PBD::PropertyChange &)
void lower_region(boost::shared_ptr< Region >)
virtual void recompute_at_end()=0
const PBD::ID & id() const
bool position_locked() const
virtual bool set_name(const std::string &str)
std::vector< std::string > master_source_names()
bool verify_start(framepos_t)
LIBARDOUR_API PBD::PropertyDescriptor< bool > locked
void print(char *buf, uint32_t bufsize) const
bool set_id(const XMLNode &)
void lower_region_to_bottom(boost::shared_ptr< Region >)
std::vector< boost::shared_ptr< Source > > SourceList
PBD::EnumProperty< PositionLockStyle > _position_lock_style
bool deletion_in_progress() const
PBD::Property< bool > _opaque
Evoral::OverlapType coverage(framepos_t start, framepos_t end) const
LIBARDOUR_API PBD::PropertyDescriptor< bool > opaque
frameoffset_t sync_offset(int &dir) const
#define DEBUG_TRACE(bits, str)
std::string source_string() const
LIBARDOUR_API void make_property_quarks()
LIBARDOUR_API PBD::PropertyDescriptor< bool > external
RouteGroup::RouteGroup(Session &s, const string &n) add_property(_relative)
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r)
LIBARDOUR_API PBD::PropertyDescriptor< bool > right_of_split
bool region_list_equivalent(boost::shared_ptr< const Region >) const
framepos_t earliest_possible_position() const
static PBD::Signal1< void, boost::shared_ptr< Region > > CheckNewRegion
PBD::Property< std::string > _name
#define REGION_COPY_STATE(other)
virtual int adjust_transients(frameoffset_t)
framepos_t adjust_to_sync(framepos_t) const
void set_whole_file(bool yn)
LIBARDOUR_API RuntimeProfile * Profile
framecnt_t source_length(uint32_t n) const
framepos_t position() const
LIBPBD_API uint64_t Properties
Timecode::BBT_Time _bbt_time
bool verify_start_mutable(framepos_t &_start)
void register_properties()
XMLProperty * add_property(const char *name, const std::string &value)
void trim_to(framepos_t position, framecnt_t length)
void raise_region_to_top(boost::shared_ptr< Region >)
LIBARDOUR_API PBD::PropertyDescriptor< uint64_t > layering_index
LIBARDOUR_API PBD::PropertyDescriptor< bool > import
virtual XMLNode & state()
void add_child_nocopy(XMLNode &)
void set_length(framecnt_t)
void recompute_position_from_lock_style()
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > position
LIBARDOUR_API PBD::PropertyDescriptor< framecnt_t > ancestral_length
LIBARDOUR_API PBD::PropertyDescriptor< framecnt_t > sync_position
virtual void set_start_internal(framecnt_t)
void send_change(const PBD::PropertyChange &)
LIBARDOUR_API PBD::PropertyDescriptor< bool > sync_marked
PBD::Property< float > _shift
void set_automatic(bool yn)
bool contains(PropertyDescriptor< T > p) const
void clear_sync_position()
void modify_front(framepos_t new_position, bool reset_fade)
framecnt_t length() const
static const framepos_t max_framepos
framepos_t first_frame() const
void set_position_lock_style(PositionLockStyle ps)
PBD::Property< bool > _hidden
void nudge_position(frameoffset_t)
static const framecnt_t max_framecnt
LIBARDOUR_API PBD::PropertyDescriptor< PositionLockStyle > position_lock_style
virtual void set_length_internal(framecnt_t)
uint32_t max_source_level() const
bool size_equivalent(boost::shared_ptr< const Region >) const
int apply(Filter &, Progress *progress=0)
PBD::Property< framecnt_t > _ancestral_length
bool at_natural_position() const
static PBD::Signal2< void, boost::shared_ptr< ARDOUR::Region >, const PBD::PropertyChange & > RegionPropertyChanged
LIBARDOUR_API PBD::PropertyDescriptor< bool > valid_transients
void bbt_time(framepos_t when, Timecode::BBT_Time &)
LIBARDOUR_API PBD::PropertyDescriptor< bool > muted
LIBARDOUR_API PBD::PropertyDescriptor< bool > position_locked
LIBARDOUR_API PBD::PropertyDescriptor< bool > whole_file
PBD::Property< bool > _video_locked
virtual boost::shared_ptr< Region > get_parent() const
void move_to_natural_position()
void set_start(framepos_t)
std::string string_compose(const std::string &fmt, const T1 &o1)
LIBARDOUR_API PBD::PropertyDescriptor< bool > left_of_split
boost::shared_ptr< ARDOUR::Playlist > playlist() const
boost::weak_ptr< ARDOUR::Playlist > _playlist
PBD::Property< framepos_t > _position
void suspend_property_changes()
PBD::Property< framecnt_t > _length
framepos_t last_frame() const
LIBARDOUR_API PBD::PropertyDescriptor< framecnt_t > length
bool any_source_equivalent(boost::shared_ptr< const Region >) const