successfully import SMF files with badly-formed time signature events

This commit is contained in:
Paul Davis
2026-01-09 18:00:37 -07:00
parent 3890eb7f0e
commit 9d2c755f69

View File

@@ -860,11 +860,10 @@ SMF::tempo_map (bool& provided) const
Evoral::SMF::Tempo* t = nth_tempo (n);
assert (t);
Temporal::Tempo tempo (t->tempo(), 32.0 / (double) t->notes_per_note);
Temporal::Tempo tempo (t->tempo(), t->notes_per_note == 0 ? t->denominator : 32.0 / (double) t->notes_per_note);
Meter meter (t->numerator, t->denominator);
Beats beats (t->time_pulses / (uint64_t) ppqn(),
((t->time_pulses % (uint64_t) ppqn()) * ticks_per_beat) / ppqn());;
Beats beats (t->time_pulses / (uint64_t) ppqn(), ((t->time_pulses % (uint64_t) ppqn()) * ticks_per_beat) / ppqn());;
BBT_Argument bbt; /* 1|1|0 which is correct for the no-meter case */
superclock_t sc;
@@ -872,6 +871,7 @@ SMF::tempo_map (bool& provided) const
sc = 0;
} else {
sc = new_map->superclock_at (beats);
new_map->dump (std::cerr);
}
if (have_initial_meter) {
@@ -892,6 +892,10 @@ SMF::tempo_map (bool& provided) const
}
new_map->smf_end();
if (new_map->n_tempos() == 0 || new_map->n_meters() == 0) {
return nullptr;
}
provided = true;
return new_map;
}