13
0

temporal: use "pulses" info from old tempo maps

Note: pulses are whole notes
This commit is contained in:
Paul Davis 2023-11-13 22:30:23 -07:00
parent f8d86c8d19
commit fbc578fdb6
2 changed files with 16 additions and 4 deletions

View File

@ -4499,14 +4499,18 @@ TempoMap::parse_tempo_state_3x (const XMLNode& node, LegacyTempoState& lts)
} }
} }
/* position is the only data we extract from older XML */
if (!node.get_property ("frame", lts.sample)) { if (!node.get_property ("frame", lts.sample)) {
error << _("Legacy tempo section XML does not have a \"frame\" node - map will be ignored") << endmsg; error << _("Legacy tempo section XML does not have a \"frame\" node - map will be ignored") << endmsg;
cerr << _("Legacy tempo section XML does not have a \"frame\" node - map will be ignored") << endl; cerr << _("Legacy tempo section XML does not have a \"frame\" node - map will be ignored") << endl;
return -1; return -1;
} }
if (!node.get_property ("pulse", lts.pulses)) {
error << _("Legacy tempo section XML does not have a \"pulse\" node - map will be ignored") << endmsg;
cerr << _("Legacy tempo section XML does not have a \"pulse\" node - map will be ignored") << endl;
return -1;
}
if (node.get_property ("beats-per-minute", lts.note_types_per_minute)) { if (node.get_property ("beats-per-minute", lts.note_types_per_minute)) {
if (lts.note_types_per_minute < 0.0) { if (lts.note_types_per_minute < 0.0) {
error << _("TempoSection XML node has an illegal \"beats_per_minute\" value") << endmsg; error << _("TempoSection XML node has an illegal \"beats_per_minute\" value") << endmsg;
@ -4575,6 +4579,12 @@ TempoMap::parse_meter_state_3x (const XMLNode& node, LegacyMeterState& lms)
return -1; return -1;
} }
if (!node.get_property ("pulse", lms.pulses)) {
error << _("Legacy meter section XML does not have a \"pulse\" node - map will be ignored") << endmsg;
cerr << _("Legacy meter section XML does not have a \"pulse\" node - map will be ignored") << endl;
return -1;
}
if (!node.get_property ("beat", lms.beat)) { if (!node.get_property ("beat", lms.beat)) {
lms.beat = 0.0; lms.beat = 0.0;
} }
@ -4653,7 +4663,7 @@ TempoMap::set_state_3x (const XMLNode& node)
Tempo t (lts.note_types_per_minute, Tempo t (lts.note_types_per_minute,
lts.end_note_types_per_minute, lts.end_note_types_per_minute,
lts.note_type); lts.note_type);
TempoPoint* tp = new TempoPoint (*this, t, samples_to_superclock (0, TEMPORAL_SAMPLE_RATE), Beats(), BBT_Time()); TempoPoint* tp = new TempoPoint (*this, t, samples_to_superclock (0, TEMPORAL_SAMPLE_RATE), Beats::from_double (lts.pulses * 4.0), BBT_Time());
tp->set_continuing (lts.continuing); tp->set_continuing (lts.continuing);
@ -4730,7 +4740,7 @@ TempoMap::set_state_3x (const XMLNode& node)
lts.end_note_types_per_minute, lts.end_note_types_per_minute,
lts.note_type); lts.note_type);
set_tempo (t, timepos_t (lts.sample)); set_tempo (t, timepos_t (lts.sample), Beats::from_double (lts.pulses * 4.0));
} else if (child->name() == Meter::xml_node_name) { } else if (child->name() == Meter::xml_node_name) {

View File

@ -1162,6 +1162,7 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
struct LegacyTempoState struct LegacyTempoState
{ {
samplepos_t sample; samplepos_t sample;
double pulses;
double note_types_per_minute; double note_types_per_minute;
double end_note_types_per_minute; double end_note_types_per_minute;
double note_type; double note_type;
@ -1171,6 +1172,7 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible
struct LegacyMeterState struct LegacyMeterState
{ {
samplepos_t sample; samplepos_t sample;
double pulses;
BBT_Time bbt; BBT_Time bbt;
double beat; double beat;
double divisions_per_bar; double divisions_per_bar;