From d06a0d9c9d2166e93eb94ddb35d3cf83786c9893 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 27 Nov 2022 01:58:11 +0100 Subject: [PATCH] Copy MIDI Source properties when cloning MIDI Regions --- libs/ardour/midi_region.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index 7a59bebaaa..1b6955dab3 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -37,6 +37,7 @@ #include "pbd/xml++.h" #include "pbd/basename.h" +#include "pbd/types_convert.h" #include "ardour/automation_control.h" #include "ardour/midi_cursor.h" @@ -60,6 +61,10 @@ using namespace std; using namespace ARDOUR; using namespace PBD; +namespace PBD { + DEFINE_ENUM_CONVERT(ARDOUR::Source::Flag); +} + /* Basic MidiRegion constructor (many channels) */ MidiRegion::MidiRegion (const SourceList& srcs) : Region (srcs) @@ -148,6 +153,19 @@ MidiRegion::clone (boost::shared_ptr newsrc, ThawList* tl) const { boost::shared_ptr ms = midi_source(0); + /* copy source state (cue markers, captured_for, CC/param interpolation */ + XMLNode& node (ms->get_state()); + /* these must be set, otherwise Source::set_state() returns early */ + node.set_property (X_("id"), newsrc->id()); + node.set_property (X_("name"), newsrc->name()); + node.set_property (X_("flags"), newsrc->flags ()); + node.set_property (X_("take-id"), newsrc->take_id()); + + /* compare to SMFSource::set_state */ + newsrc->MidiSource::set_state (node, Stateful::current_state_version); + newsrc->Source::set_state (node, Stateful::current_state_version); + delete &node; + /* Lock our source since we'll be reading from it. write_to() will take a lock on newsrc. */