summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-06-17 03:20:37 +1000
committernick_m <mainsbridge@gmail.com>2016-07-10 02:18:36 +1000
commit93c24e4433d69fe1de28d4d2ed2045aa7cb3596b (patch)
tree9cf3017f3075d57a1b7a3c5d9388b6554cbb0c7b /libs/ardour
parent94e0a15325278ec26dbeba4990a0e883db859338 (diff)
Paste uses exact beats. rework _start_beats calculation in copy-with-offset ctor.
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/playlist.h6
-rw-r--r--libs/ardour/ardour/region.h4
-rw-r--r--libs/ardour/midi_region.cc8
-rw-r--r--libs/ardour/playlist.cc22
4 files changed, 22 insertions, 18 deletions
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index 0a5f5e4ddc..09c31360ec 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -128,7 +128,7 @@ public:
/* Editing operations */
- void add_region (boost::shared_ptr<Region>, framepos_t position, float times = 1, bool auto_partition = false);
+ void add_region (boost::shared_ptr<Region>, framepos_t position, float times = 1, bool auto_partition = false, const int32_t& sub_num = 0);
void remove_region (boost::shared_ptr<Region>);
void get_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&);
void get_region_list_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&);
@@ -161,7 +161,7 @@ public:
boost::shared_ptr<Playlist> cut (std::list<AudioRange>&, bool result_is_hidden = true);
boost::shared_ptr<Playlist> copy (std::list<AudioRange>&, bool result_is_hidden = true);
- int paste (boost::shared_ptr<Playlist>, framepos_t position, float times);
+ int paste (boost::shared_ptr<Playlist>, framepos_t position, float times, const int32_t& sub_num);
const RegionListProperty& region_list_property () const { return regions; }
boost::shared_ptr<RegionList> region_list();
@@ -362,7 +362,7 @@ public:
virtual XMLNode& state (bool);
- bool add_region_internal (boost::shared_ptr<Region>, framepos_t position);
+ bool add_region_internal (boost::shared_ptr<Region>, framepos_t position, const int32_t& sub_num = 0);
int remove_region_internal (boost::shared_ptr<Region>);
void copy_regions (RegionList&) const;
diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h
index ec4f559a87..7f41cb6e5a 100644
--- a/libs/ardour/ardour/region.h
+++ b/libs/ardour/ardour/region.h
@@ -171,10 +171,12 @@ class LIBARDOUR_API Region
Trimmable::CanTrim can_trim () const;
PositionLockStyle position_lock_style () const { return _position_lock_style; }
- double beat () const { return _beat; }
void set_position_lock_style (PositionLockStyle ps);
void recompute_position_from_lock_style (const int32_t& sub_num);
+ double beat () const { return _beat; }
+ void set_beat (double beat) { _beat = beat; }
+
void suspend_property_changes ();
bool covers (framepos_t frame) const {
diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc
index 4d4c081c24..035c17c9de 100644
--- a/libs/ardour/midi_region.cc
+++ b/libs/ardour/midi_region.cc
@@ -107,8 +107,7 @@ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, frameoffset_t
, _start_beats (Properties::start_beats, Evoral::Beats())
, _length_beats (Properties::length_beats, other->_length_beats)
{
- const double offset_beat = _session.tempo_map().exact_beat_at_frame (other->_position + offset, sub_num) - other->beat();
- _start_beats = Evoral::Beats (other->_start_beats.val().to_double() + offset_beat);
+ _start_beats = Evoral::Beats (_session.tempo_map().exact_beat_at_frame (other->_position + offset - other->_start, sub_num) - other->beat());
update_length_beats (sub_num);
register_properties ();
@@ -163,7 +162,10 @@ MidiRegion::clone (boost::shared_ptr<MidiSource> newsrc) const
plist.add (Properties::length_beats, _length_beats);
plist.add (Properties::layer, 0);
- return boost::dynamic_pointer_cast<MidiRegion> (RegionFactory::create (newsrc, plist, true));
+ boost::shared_ptr<MidiRegion> ret (boost::dynamic_pointer_cast<MidiRegion> (RegionFactory::create (newsrc, plist, true)));
+ ret->set_beat (beat());
+
+ return ret;
}
void
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 3797f2f0c1..924c3b6141 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -665,7 +665,7 @@ Playlist::flush_notifications (bool from_undo)
/** Note: this calls set_layer (..., DBL_MAX) so it will reset the layering index of region */
void
- Playlist::add_region (boost::shared_ptr<Region> region, framepos_t position, float times, bool auto_partition)
+ Playlist::add_region (boost::shared_ptr<Region> region, framepos_t position, float times, bool auto_partition, const int32_t& sub_num)
{
RegionWriteLock rlock (this);
times = fabs (times);
@@ -679,7 +679,7 @@ Playlist::flush_notifications (bool from_undo)
}
if (itimes >= 1) {
- add_region_internal (region, pos);
+ add_region_internal (region, pos, sub_num);
set_layer (region, DBL_MAX);
pos += region->length();
--itimes;
@@ -692,7 +692,7 @@ Playlist::flush_notifications (bool from_undo)
for (int i = 0; i < itimes; ++i) {
boost::shared_ptr<Region> copy = RegionFactory::create (region, true);
- add_region_internal (copy, pos);
+ add_region_internal (copy, pos, sub_num);
set_layer (copy, DBL_MAX);
pos += region->length();
}
@@ -713,7 +713,7 @@ Playlist::flush_notifications (bool from_undo)
plist.add (Properties::layer, region->layer());
boost::shared_ptr<Region> sub = RegionFactory::create (region, plist);
- add_region_internal (sub, pos);
+ add_region_internal (sub, pos, sub_num);
set_layer (sub, DBL_MAX);
}
}
@@ -734,7 +734,7 @@ Playlist::flush_notifications (bool from_undo)
}
bool
- Playlist::add_region_internal (boost::shared_ptr<Region> region, framepos_t position)
+ Playlist::add_region_internal (boost::shared_ptr<Region> region, framepos_t position, const int32_t& sub_num)
{
if (region->data_type() != _type) {
return false;
@@ -747,7 +747,7 @@ Playlist::flush_notifications (bool from_undo)
region->set_playlist (boost::weak_ptr<Playlist>(foo));
}
- region->set_position (position);
+ region->set_position (position, sub_num);
regions.insert (upper_bound (regions.begin(), regions.end(), region, cmp), region);
all_regions.insert (region);
@@ -1146,7 +1146,7 @@ Playlist::flush_notifications (bool from_undo)
chopped.
*/
- ret->paste (pl, (*i).start - start, 1.0f);
+ ret->paste (pl, (*i).start - start, 1.0f, 0);
}
}
@@ -1208,7 +1208,7 @@ Playlist::flush_notifications (bool from_undo)
}
int
- Playlist::paste (boost::shared_ptr<Playlist> other, framepos_t position, float times)
+ Playlist::paste (boost::shared_ptr<Playlist> other, framepos_t position, float times, const int32_t& sub_num)
{
times = fabs (times);
@@ -1230,7 +1230,7 @@ Playlist::flush_notifications (bool from_undo)
the ordering they had in the original playlist.
*/
- add_region_internal (copy_of_region, (*i)->position() + pos);
+ add_region_internal (copy_of_region, (*i)->position() + pos, sub_num);
set_layer (copy_of_region, copy_of_region->layer() + top);
}
pos += shift;
@@ -1321,7 +1321,7 @@ Playlist::duplicate_range (AudioRange& range, float times)
{
boost::shared_ptr<Playlist> pl = copy (range.start, range.length(), true);
framecnt_t offset = range.end - range.start;
- paste (pl, range.start + offset, times);
+ paste (pl, range.start + offset, times, 0);
}
void
@@ -1345,7 +1345,7 @@ Playlist::duplicate_ranges (std::list<AudioRange>& ranges, float /* times */)
for (list<AudioRange>::iterator i = ranges.begin(); i != ranges.end(); ++i) {
boost::shared_ptr<Playlist> pl = copy ((*i).start, (*i).length(), true);
- paste (pl, (*i).start + offset, 1.0f); // times ??
+ paste (pl, (*i).start + offset, 1.0f, 0); // times ??
}
}