summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_region.cc
diff options
context:
space:
mode:
authornick_m <mainsbridge@gmail.com>2016-10-10 03:39:57 +1100
committernick_m <mainsbridge@gmail.com>2016-10-10 03:39:57 +1100
commit4faf44588f806eac46b5c7ae5cc8058fc47da3f1 (patch)
tree5a54dd61694eb04e7f15650cc592eb54f84458f7 /libs/ardour/midi_region.cc
parent631c8afc668f8b57af21ca85332ac8f012a3f59e (diff)
Interpret start & length_beats properties as double rather than Evoral::Beats.
- Evoral::Beats operator!= would prevent an increment of start_beats by intervals of less than a tick, so its possible that other subtle problems existed due to this kind of thing.
Diffstat (limited to 'libs/ardour/midi_region.cc')
-rw-r--r--libs/ardour/midi_region.cc40
1 files changed, 19 insertions, 21 deletions
diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc
index d4cf35e82a..7d7619680a 100644
--- a/libs/ardour/midi_region.cc
+++ b/libs/ardour/midi_region.cc
@@ -53,8 +53,8 @@ using namespace PBD;
namespace ARDOUR {
namespace Properties {
- PBD::PropertyDescriptor<Evoral::Beats> start_beats;
- PBD::PropertyDescriptor<Evoral::Beats> length_beats;
+ PBD::PropertyDescriptor<double> start_beats;
+ PBD::PropertyDescriptor<double> length_beats;
}
}
@@ -77,8 +77,8 @@ MidiRegion::register_properties ()
/* Basic MidiRegion constructor (many channels) */
MidiRegion::MidiRegion (const SourceList& srcs)
: Region (srcs)
- , _start_beats (Properties::start_beats, Evoral::Beats())
- , _length_beats (Properties::length_beats, midi_source(0)->length_beats())
+ , _start_beats (Properties::start_beats, 0.0)
+ , _length_beats (Properties::length_beats, midi_source(0)->length_beats().to_double())
{
register_properties ();
midi_source(0)->ModelChanged.connect_same_thread (_source_connection, boost::bind (&MidiRegion::model_changed, this));
@@ -103,10 +103,10 @@ MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other)
/** Create a new MidiRegion that is part of an existing one */
MidiRegion::MidiRegion (boost::shared_ptr<const MidiRegion> other, frameoffset_t offset, const int32_t sub_num)
: Region (other, offset, sub_num)
- , _start_beats (Properties::start_beats, Evoral::Beats())
+ , _start_beats (Properties::start_beats, 0.0)
, _length_beats (Properties::length_beats, other->_length_beats)
{
- _start_beats = Evoral::Beats (_session.tempo_map().exact_qn_at_frame (other->_position + offset, sub_num) - (other->pulse() * 4.0)) + other->_start_beats;
+ _start_beats = (_session.tempo_map().exact_qn_at_frame (other->_position + offset, sub_num) - (other->pulse() * 4.0)) + other->_start_beats;
update_length_beats (sub_num);
register_properties ();
@@ -223,7 +223,7 @@ MidiRegion::post_set (const PropertyChange& pc)
void
MidiRegion::set_start_beats_from_start_frames ()
{
- _start_beats = Evoral::Beats ((pulse() * 4.0) - _session.tempo_map().quarter_note_at_frame (_position - _start));
+ _start_beats = (pulse() * 4.0) - _session.tempo_map().quarter_note_at_frame (_position - _start);
}
void
@@ -265,10 +265,10 @@ MidiRegion::update_after_tempo_map_change (bool /* send */)
For now, the musical position at the region start is retained, but subsequent events
will maintain their beat distance according to the map.
*/
- _start = _position - _session.tempo_map().frame_at_pulse (pulse() - (_start_beats.val().to_double() / 4.0));
+ _start = _position - _session.tempo_map().frame_at_pulse (pulse() - (_start_beats / 4.0));
/* _length doesn't change for audio-locked regions. update length_beats to match. */
- _length_beats = Evoral::Beats (_session.tempo_map().quarter_note_at_frame (_position + _length) - _session.tempo_map().quarter_note_at_frame (_position));
+ _length_beats = _session.tempo_map().quarter_note_at_frame (_position + _length) - _session.tempo_map().quarter_note_at_frame (_position);
s_and_l.add (Properties::start);
s_and_l.add (Properties::length_beats);
@@ -280,7 +280,7 @@ MidiRegion::update_after_tempo_map_change (bool /* send */)
Region::update_after_tempo_map_change (false);
/* _start has now been updated. */
- _length = _session.tempo_map().frame_at_pulse (pulse() + (_length_beats.val().to_double() / 4.0)) - _position;
+ _length = _session.tempo_map().frame_at_pulse (pulse() + (_length_beats / 4.0)) - _position;
if (old_start != _start) {
s_and_l.add (Properties::start);
@@ -298,7 +298,7 @@ MidiRegion::update_after_tempo_map_change (bool /* send */)
void
MidiRegion::update_length_beats (const int32_t sub_num)
{
- _length_beats = Evoral::Beats (_session.tempo_map().exact_qn_at_frame (_position + _length, sub_num) - (pulse() * 4.0));
+ _length_beats = _session.tempo_map().exact_qn_at_frame (_position + _length, sub_num) - (pulse() * 4.0);
}
void
@@ -312,20 +312,20 @@ MidiRegion::set_position_internal (framepos_t pos, bool allow_bbt_recompute, con
}
/* set _start to new position in tempo map */
- _start = _position - _session.tempo_map().frame_at_pulse (pulse() - (_start_beats.val().to_double() / 4.0));
+ _start = _position - _session.tempo_map().frame_at_pulse (pulse() - (_start_beats / 4.0));
/* in construction from src */
- if (_length_beats == Evoral::Beats()) {
+ if (_length_beats == 0.0) {
update_length_beats (sub_num);
}
if (position_lock_style() == AudioTime) {
- _length_beats = Evoral::Beats (_session.tempo_map().quarter_note_at_frame (_position + _length) - _session.tempo_map().quarter_note_at_frame (_position));
+ _length_beats = _session.tempo_map().quarter_note_at_frame (_position + _length) - _session.tempo_map().quarter_note_at_frame (_position);
} else {
/* leave _length_beats alone, and change _length to reflect the state of things
at the new position (tempo map may dictate a different number of frames).
*/
- Region::set_length_internal (_session.tempo_map().frame_at_pulse (pulse() + (_length_beats.val().to_double() / 4.0)) - _position, sub_num);
+ Region::set_length_internal (_session.tempo_map().frame_at_pulse (pulse() + (_length_beats / 4.0)) - _position, sub_num);
}
}
@@ -425,7 +425,7 @@ MidiRegion::_read_at (const SourceList& /*srcs*/,
filter,
_filtered_parameters,
pulse(),
- _start_beats.val().to_double()
+ _start_beats
) != to_read) {
return 0; /* "read nothing" */
}
@@ -591,7 +591,7 @@ MidiRegion::fix_negative_start ()
model()->insert_silence_at_start (c.from (-_start));
_start = 0;
- _start_beats = Evoral::Beats();
+ _start_beats = 0.0;
}
void
@@ -630,16 +630,14 @@ MidiRegion::trim_to_internal (framepos_t position, framecnt_t length, const int3
set_position_internal (position, true, sub_num);
what_changed.add (Properties::position);
- double new_start_qn = start_beats().to_double() + (pos_qn - old_pos_qn);
+ double new_start_qn = start_beats() + (pos_qn - old_pos_qn);
const framepos_t new_start = _position - _session.tempo_map().frame_at_quarter_note (pos_qn - new_start_qn);
if (!verify_start_and_length (new_start, length)) {
return;
}
- /* at small deltas, (high zooms) the property will not change without this (tick resolution of Beats::operator!=)*/
- _start_beats += Evoral::Beats (new_start_qn) + start_beats().tick() * 2.0;
- _start_beats = Evoral::Beats (new_start_qn);
+ _start_beats = new_start_qn;
what_changed.add (Properties::start_beats);
set_start_internal (new_start, sub_num);