From a50f38d164dd3fc7b5541a41531a3ee5b011983f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 15 Aug 2023 10:27:21 -0600 Subject: [PATCH] domain bounce handling for sysex and patch changes --- libs/ardour/midi_model.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc index 08cb077323..7570db229b 100644 --- a/libs/ardour/midi_model.cc +++ b/libs/ardour/midi_model.cc @@ -1800,6 +1800,11 @@ MidiModel::create_mapping_stash (Temporal::Beats const & src_pos_offset) tempo_mapping_stash.insert (std::make_pair (s.get(), audio_time)); } + for (auto & pc : patch_changes()) { + superclock_t audio_time = tmap->superclock_at (src_pos_offset + pc->time()); + tempo_mapping_stash.insert (std::make_pair (pc.get(), audio_time)); + } + for (uint8_t chan = 0; chan < 16; ++chan) { for (auto const & p : pitches(chan)) { superclock_t audio_time = tmap->superclock_at (src_pos_offset + p->time()); @@ -1849,15 +1854,30 @@ MidiModel::rebuild_from_mapping_stash (Temporal::Beats const & src_pos_offset) apply_diff_command_as_subcommand (_midi_source.session(), note_cmd); -#warning paul midi model tempo mapping stash still needs sysex and pitch bend work + SysExDiffCommand* sysex_cmd = new_sysex_diff_command (_("conform to tempo map")); for (auto & s : sysexes()) { TempoMappingStash::iterator tms (tempo_mapping_stash.find (s.get())); assert (tms != tempo_mapping_stash.end()); Beats beat_time (tmap->quarters_at_superclock (tms->second) - src_pos_offset); - s->set_time (beat_time); + sysex_cmd->change (s, beat_time); } + apply_diff_command_as_subcommand (_midi_source.session(), sysex_cmd); + + PatchChangeDiffCommand* pc_cmd = new_patch_change_diff_command (_("conform to tempo map")); + + for (auto & pc : patch_changes()) { + TempoMappingStash::iterator tms (tempo_mapping_stash.find (pc.get())); + assert (tms != tempo_mapping_stash.end()); + Beats beat_time (tmap->quarters_at_superclock (tms->second) - src_pos_offset); + pc_cmd->change_time (pc, beat_time); + } + + apply_diff_command_as_subcommand (_midi_source.session(), pc_cmd); + +#warning paul midi model tempo mapping stash still pitch bend work + for (uint8_t chan = 0; chan < 16; ++chan) { for (auto & p : pitches(chan)) { TempoMappingStash::iterator tms (tempo_mapping_stash.find (p.get()));