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.
This commit is contained in:
Robin Gareus 2022-02-10 02:21:53 +01:00
parent bf273a90ca
commit 9f45e1a1fe
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
4 changed files with 34 additions and 0 deletions

View File

@ -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> 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;
}
}

View File

@ -1022,6 +1022,9 @@ TriggerBoxUI::drag_data_received (Glib::RefPtr<Gdk::DragContext> const& context,
for (std::vector<std::string>::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;
}
}

View File

@ -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<string>& paths, const SelectionDa
return !paths.empty ();
}
void
ARDOUR_UI_UTILS::copy_patch_changes (boost::shared_ptr<ARDOUR::Auditioner> a, boost::shared_ptr<ARDOUR::Trigger> t)
{
boost::shared_ptr<ARDOUR::MIDITrigger> mt = boost::dynamic_pointer_cast <ARDOUR::MIDITrigger> (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);
}
}
}

View File

@ -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<ARDOUR::Auditioner>, boost::shared_ptr<ARDOUR::Trigger>);
bool convert_drop_to_paths (std::vector<std::string>&, const Gtk::SelectionData&);
} // namespace