add API to load Instrument Preset when creating a Midi track
authorRobin Gareus <robin@gareus.org>
Fri, 6 May 2016 14:02:04 +0000 (16:02 +0200)
committerRobin Gareus <robin@gareus.org>
Fri, 6 May 2016 14:02:04 +0000 (16:02 +0200)
libs/ardour/ardour/session.h
libs/ardour/session.cc

index f81ff3efcd1b4bc40bcfb551161fe6840a21aaf8..1a4ddeb5625aeb5ef3f32625a2c65fb670232472 100644 (file)
@@ -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<PluginInfo> instrument = boost::shared_ptr<PluginInfo>(),
                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<PluginInfo> instrument = boost::shared_ptr<PluginInfo>());
+       RouteList new_midi_route (RouteGroup* route_group,
+                       uint32_t how_many,
+                       std::string name_template = "",
+                       boost::shared_ptr<PluginInfo> instrument = boost::shared_ptr<PluginInfo>(),
+                       Plugin::PresetRecord* pset = 0);
 
        void remove_routes (boost::shared_ptr<RouteList>);
        void remove_route (boost::shared_ptr<Route>);
index 0a402a3b2d5bf4cbb9ec8f9a14a3a0b2b61b0454..1e19b71755a6b9d9fa7e67f6e40bd84402bce510 100644 (file)
@@ -2425,7 +2425,7 @@ Session::default_track_name_pattern (DataType t)
  */
 list<boost::shared_ptr<MidiTrack> >
 Session::new_midi_track (const ChanCount& input, const ChanCount& output, boost::shared_ptr<PluginInfo> 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<Processor> 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<PluginInfo> instrument)
+Session::new_midi_route (RouteGroup* route_group, uint32_t how_many, string name_template, boost::shared_ptr<PluginInfo> 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<Processor> p (new PluginInsert (*this, plugin));
                                (*r)->add_processor (p, PreFader);
                        }