Load midi region length and start correctly in sessions modified by v5.0 -> 5.3-41
This commit is contained in:
parent
d6e0e75f3c
commit
3f4d49fd2f
@ -1128,6 +1128,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
|
||||
|
||||
VCAManager& vca_manager() { return *_vca_manager; }
|
||||
|
||||
bool midi_regions_use_bbt_beats () { return _midi_regions_use_bbt_beats; }
|
||||
|
||||
protected:
|
||||
friend class AudioEngine;
|
||||
void set_block_size (pframes_t nframes);
|
||||
@ -2016,6 +2018,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
|
||||
boost::shared_ptr<Route> get_midi_nth_route_by_id (PresentationInfo::order_t n) const;
|
||||
|
||||
std::string created_with;
|
||||
|
||||
bool _midi_regions_use_bbt_beats;
|
||||
};
|
||||
|
||||
|
||||
|
@ -439,10 +439,18 @@ MidiRegion::set_state (const XMLNode& node, int version)
|
||||
if (position_lock_style() == AudioTime) {
|
||||
update_length_beats (0);
|
||||
}
|
||||
|
||||
if (_session.midi_regions_use_bbt_beats()) {
|
||||
info << _("Updating midi region start and length beats") << endmsg;
|
||||
TempoMap& map (_session.tempo_map());
|
||||
_start_beats = Evoral::Beats ((map.pulse_at_beat (_beat) - map.pulse_at_beat (_beat - _start_beats.val().to_double())) * 4.0);
|
||||
_length_beats = Evoral::Beats ((map.pulse_at_beat (_beat + _length_beats.val().to_double()) - map.pulse_at_beat (_beat)) * 4.0);
|
||||
|
||||
}
|
||||
|
||||
_start_pulse = _start_beats.val().to_double() / 4.0;
|
||||
_length_pulse = _length_beats.val().to_double() / 4.0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -318,6 +318,7 @@ Session::Session (AudioEngine &eng,
|
||||
, _midi_ports (0)
|
||||
, _mmc (0)
|
||||
, _vca_manager (new VCAManager (*this))
|
||||
, _midi_regions_use_bbt_beats (false)
|
||||
{
|
||||
uint32_t sr = 0;
|
||||
|
||||
@ -477,10 +478,10 @@ Session::Session (AudioEngine &eng,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
_midi_regions_use_bbt_beats = false;
|
||||
|
||||
_is_new = false;
|
||||
session_loaded ();
|
||||
|
||||
BootMessage (_("Session loading complete"));
|
||||
}
|
||||
|
||||
|
@ -1000,6 +1000,20 @@ Session::load_state (string snapshot_name)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
XMLNode* child;
|
||||
if ((child = find_named_node (root, "ProgramVersion")) != 0) {
|
||||
if ((prop = child->property ("modified-with")) != 0) {
|
||||
std::string modified_with = prop->value ();
|
||||
|
||||
const double modified_with_version = atof (modified_with.substr ( modified_with.find(" ", 0) + 1, string::npos).c_str());
|
||||
const int modified_with_revision = atoi (modified_with.substr (modified_with.find("-", 0) + 1, string::npos).c_str());
|
||||
|
||||
if (modified_with_version <= 5.3 && !(modified_with_version == 5.3 && modified_with_revision >= 42)) {
|
||||
_midi_regions_use_bbt_beats = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
save_snapshot_name (snapshot_name);
|
||||
|
Loading…
Reference in New Issue
Block a user