From 766a120a3c5aa78e524f13fce1fa6f4286d4e98a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 6 May 2016 16:02:04 +0200 Subject: [PATCH] add API to load Instrument Preset when creating a Midi track --- libs/ardour/ardour/session.h | 10 ++++++++-- libs/ardour/session.cc | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index f81ff3efcd..1a4ddeb562 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -68,6 +68,7 @@ #include "ardour/session_configuration.h" #include "ardour/session_event.h" #include "ardour/interpolation.h" +#include "ardour/plugin.h" #include "ardour/route.h" #include "ardour/route_graph.h" @@ -605,10 +606,15 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop const ChanCount& input, const ChanCount& output, boost::shared_ptr instrument = boost::shared_ptr(), TrackMode mode = Normal, - RouteGroup* route_group = 0, uint32_t how_many = 1, std::string name_template = "" + RouteGroup* route_group = 0, uint32_t how_many = 1, std::string name_template = "", + Plugin::PresetRecord* pset = 0 ); - RouteList new_midi_route (RouteGroup* route_group, uint32_t how_many, std::string name_template = "", boost::shared_ptr instrument = boost::shared_ptr()); + RouteList new_midi_route (RouteGroup* route_group, + uint32_t how_many, + std::string name_template = "", + boost::shared_ptr instrument = boost::shared_ptr(), + Plugin::PresetRecord* pset = 0); void remove_routes (boost::shared_ptr); void remove_route (boost::shared_ptr); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 0a402a3b2d..1e19b71755 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2425,7 +2425,7 @@ Session::default_track_name_pattern (DataType t) */ list > Session::new_midi_track (const ChanCount& input, const ChanCount& output, boost::shared_ptr instrument, - TrackMode mode, RouteGroup* route_group, uint32_t how_many, string name_template) + TrackMode mode, RouteGroup* route_group, uint32_t how_many, string name_template, Plugin::PresetRecord* pset) { string track_name; uint32_t track_id = 0; @@ -2517,6 +2517,9 @@ Session::new_midi_track (const ChanCount& input, const ChanCount& output, boost: if (instrument) { for (RouteList::iterator r = new_routes.begin(); r != new_routes.end(); ++r) { PluginPtr plugin = instrument->load (*this); + if (pset) { + plugin->load_preset (*pset); + } boost::shared_ptr p (new PluginInsert (*this, plugin)); (*r)->add_processor (p, PreFader); @@ -2528,7 +2531,7 @@ Session::new_midi_track (const ChanCount& input, const ChanCount& output, boost: } RouteList -Session::new_midi_route (RouteGroup* route_group, uint32_t how_many, string name_template, boost::shared_ptr instrument) +Session::new_midi_route (RouteGroup* route_group, uint32_t how_many, string name_template, boost::shared_ptr instrument, Plugin::PresetRecord* pset) { string bus_name; uint32_t bus_id = 0; @@ -2606,6 +2609,9 @@ Session::new_midi_route (RouteGroup* route_group, uint32_t how_many, string name if (instrument) { for (RouteList::iterator r = ret.begin(); r != ret.end(); ++r) { PluginPtr plugin = instrument->load (*this); + if (pset) { + plugin->load_preset (*pset); + } boost::shared_ptr p (new PluginInsert (*this, plugin)); (*r)->add_processor (p, PreFader); }