From 9f45e1a1fe2051c559519a4eb61f995829903ea4 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 10 Feb 2022 02:21:53 +0100 Subject: [PATCH] Copy Bank/Patch changes from auditioner to trigger-slot This will need some refinement, we should only copy the settings if the file in question was previously auditioned, and perhaps only if GMsynth.lv2 is used. --- gtk2_ardour/editor_audio_import.cc | 4 ++++ gtk2_ardour/triggerbox_ui.cc | 3 +++ gtk2_ardour/utils.cc | 19 +++++++++++++++++++ gtk2_ardour/utils.h | 8 ++++++++ 4 files changed, 34 insertions(+) diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index acb0b33846..6cf326b9cf 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -67,6 +67,7 @@ #include "interthread_progress_window.h" #include "mouse_cursors.h" #include "editor_cursors.h" +#include "utils.h" #include "pbd/i18n.h" @@ -1161,6 +1162,9 @@ Editor::finish_bringing_in_material (boost::shared_ptr region, for (int s = 0; s < default_triggers_per_box; ++s) { if (!existing_track->triggerbox ()->trigger (s)->region ()) { existing_track->triggerbox ()->set_from_selection (s, copy); +#if 1 /* assume drop from sidebar */ + ARDOUR_UI_UTILS::copy_patch_changes (_session->the_auditioner (), existing_track->triggerbox ()->trigger (s)); +#endif break; } } diff --git a/gtk2_ardour/triggerbox_ui.cc b/gtk2_ardour/triggerbox_ui.cc index 607325a1ab..f2481b9912 100644 --- a/gtk2_ardour/triggerbox_ui.cc +++ b/gtk2_ardour/triggerbox_ui.cc @@ -1022,6 +1022,9 @@ TriggerBoxUI::drag_data_received (Glib::RefPtr const& context, for (std::vector::iterator s = paths.begin (); s != paths.end (); ++s) { /* this will do nothing if n is too large */ _triggerbox.set_from_path (n, *s); +#if 1 /* assume drop from sidebar -- TODO use a special data.get_target() ? */ + ARDOUR_UI_UTILS::copy_patch_changes (_triggerbox.session().the_auditioner (), _triggerbox.trigger (n)); +#endif ++n; } } diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index 58723d6059..f2b9334192 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -52,9 +52,11 @@ #include "pbd/basename.h" #include "pbd/file_utils.h" +#include "ardour/auditioner.h" #include "ardour/audioengine.h" #include "ardour/filesystem_paths.h" #include "ardour/search_paths.h" +#include "ardour/triggerbox.h" #include "gtkmm2ext/colors.h" #include "gtkmm2ext/utils.h" @@ -985,3 +987,20 @@ ARDOUR_UI_UTILS::convert_drop_to_paths (vector& paths, const SelectionDa return !paths.empty (); } + +void +ARDOUR_UI_UTILS::copy_patch_changes (boost::shared_ptr a, boost::shared_ptr t) +{ + boost::shared_ptr mt = boost::dynamic_pointer_cast (t); + + if (!mt || !a) { + return; + } + for (uint8_t c = 0; c < 16; ++c) { + if (a->patch_change (c).is_set()) { + mt->set_patch_change (a->patch_change (c)); + } else { + mt->unset_patch_change (c); + } + } +} diff --git a/gtk2_ardour/utils.h b/gtk2_ardour/utils.h index c742b681be..18ff6f7b82 100644 --- a/gtk2_ardour/utils.h +++ b/gtk2_ardour/utils.h @@ -42,6 +42,7 @@ #include "canvas/types.h" namespace PBD { + class Controllable; class Controllable; class ScopedConnectionList; } @@ -56,6 +57,11 @@ namespace ArdourCanvas { class Item; } +namespace ARDOUR { + class Auditioner; + class Trigger; +} + namespace ARDOUR_UI_UTILS { gint just_hide_it (GdkEventAny*, Gtk::Window*); @@ -112,6 +118,8 @@ bool running_from_source_tree (); void inhibit_screensaver (bool); +void copy_patch_changes (boost::shared_ptr, boost::shared_ptr); + bool convert_drop_to_paths (std::vector&, const Gtk::SelectionData&); } // namespace