add API to load Instrument Preset when creating a Midi track

This commit is contained in:
Robin Gareus 2016-05-06 16:02:04 +02:00
parent b15ed28f79
commit 766a120a3c
2 changed files with 16 additions and 4 deletions

View 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>);

View 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);
}