summaryrefslogtreecommitdiff
path: root/libs/ardour/region.cc
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2015-12-30 00:39:10 +1100
committernick_m <mainsbridge@gmail.com>2016-05-27 23:38:10 +1000
commit885f1fd684da31a730f90ebad23ad9ff39baedb0 (patch)
treec8d4564d40cd29948d802357b29595a5916b6689 /libs/ardour/region.cc
parent772683d2df7ba96d27943140fe59c8797fd7bed3 (diff)
Tempo ramps - update midi regions and locations when dragging tempo.
- also make locations and regions use a double beat rather than bbt for musical position.
Diffstat (limited to 'libs/ardour/region.cc')
-rw-r--r--libs/ardour/region.cc30
1 files changed, 21 insertions, 9 deletions
diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc
index ee666e51f0..8db3aa097a 100644
--- a/libs/ardour/region.cc
+++ b/libs/ardour/region.cc
@@ -538,7 +538,7 @@ Region::set_position_lock_style (PositionLockStyle ps)
_position_lock_style = ps;
if (_position_lock_style == MusicTime) {
- _session.bbt_time (_position, _bbt_time);
+ _beat = _session.tempo_map().beat_at_frame (_position);
}
send_change (Properties::position_lock_style);
@@ -553,9 +553,8 @@ Region::update_after_tempo_map_change ()
if (!pl || _position_lock_style != MusicTime) {
return;
}
-
TempoMap& map (_session.tempo_map());
- framepos_t pos = map.frame_time (_bbt_time);
+ framepos_t pos = map.frame_at_beat (_beat);
set_position_internal (pos, false);
/* do this even if the position is the same. this helps out
@@ -651,7 +650,7 @@ void
Region::recompute_position_from_lock_style ()
{
if (_position_lock_style == MusicTime) {
- _session.bbt_time (_position, _bbt_time);
+ _beat = _session.tempo_map().beat_at_frame (_position);
}
}
@@ -1199,8 +1198,8 @@ Region::state ()
if (_position_lock_style != AudioTime) {
stringstream str;
- str << _bbt_time;
- node->add_property ("bbt-position", str.str());
+ str << _beat;
+ node->add_property ("beat", str.str());
}
for (uint32_t n=0; n < _sources.size(); ++n) {
@@ -1261,6 +1260,7 @@ int
Region::_set_state (const XMLNode& node, int /*version*/, PropertyChange& what_changed, bool send)
{
XMLProperty const * prop;
+ Timecode::BBT_Time bbt_time;
Stateful::save_extra_xml (node);
@@ -1274,9 +1274,21 @@ Region::_set_state (const XMLNode& node, int /*version*/, PropertyChange& what_c
_position_lock_style = AudioTime;
} else {
if (sscanf (prop->value().c_str(), "%d|%d|%d",
- &_bbt_time.bars,
- &_bbt_time.beats,
- &_bbt_time.ticks) != 3) {
+ &bbt_time.bars,
+ &bbt_time.beats,
+ &bbt_time.ticks) != 3) {
+ _position_lock_style = AudioTime;
+ }
+ _beat = _session.tempo_map().bbt_to_beats (bbt_time);
+ }
+ }
+
+ if (_position_lock_style == MusicTime) {
+ if ((prop = node.property ("beat")) == 0) {
+ /* missing BBT info, revert to audio time locking */
+ _position_lock_style = AudioTime;
+ } else {
+ if (sscanf (prop->value().c_str(), "%lf", &_beat) != 1) {
_position_lock_style = AudioTime;
}
}