MIDI regions attempt to get their tempo & meter from their source file

This commit is contained in:
Paul Davis 2025-08-18 16:35:37 -06:00 committed by Edgar Aichinger
parent f3fd8d6e40
commit 06751f64b4

View file

@ -39,6 +39,7 @@
#include "pbd/basename.h" #include "pbd/basename.h"
#include "pbd/types_convert.h" #include "pbd/types_convert.h"
#include "ardour/file_source.h"
#include "ardour/automation_control.h" #include "ardour/automation_control.h"
#include "ardour/midi_cursor.h" #include "ardour/midi_cursor.h"
#include "ardour/midi_model.h" #include "ardour/midi_model.h"
@ -98,6 +99,7 @@ MidiRegion::MidiRegion (std::shared_ptr<const MidiRegion> other, timecnt_t const
: Region (other, offset) : Region (other, offset)
, _ignore_shift (false) , _ignore_shift (false)
{ {
set_tempo_stuff_from_source ();
assert(_name.val().find("/") == string::npos); assert(_name.val().find("/") == string::npos);
midi_source(0)->ModelChanged.connect_same_thread (_source_connection, std::bind (&MidiRegion::model_changed, this)); midi_source(0)->ModelChanged.connect_same_thread (_source_connection, std::bind (&MidiRegion::model_changed, this));
@ -118,7 +120,9 @@ MidiRegion::set_tempo_stuff_from_source ()
Temporal::TempoMap::SharedPtr new_map (smf->tempo_map (provided)); Temporal::TempoMap::SharedPtr new_map (smf->tempo_map (provided));
if (!provided) { if (!provided) {
new_map.reset (new Temporal::TempoMap()); _tempo = Temporal::Tempo (120, 4);
_meter = Temporal::Meter (4, 4);
return;
} }
Temporal::TempoPoint const tp (new_map->tempo_at (start())); Temporal::TempoPoint const tp (new_map->tempo_at (start()));