add a way to create a new MIDI track with an instrument pre-selected
git-svn-id: svn://localhost/ardour2/branches/3.0@11421 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include "pbd/error.h"
|
||||
#include "pbd/convert.h"
|
||||
#include "gtkmm2ext/utils.h"
|
||||
|
||||
#include "ardour/plugin_manager.h"
|
||||
#include "ardour/profile.h"
|
||||
#include "ardour/template_utils.h"
|
||||
#include "ardour/route_group.h"
|
||||
@@ -50,7 +52,9 @@ AddRouteDialog::AddRouteDialog (Session* s)
|
||||
: ArdourDialog (_("Add Track or Bus"))
|
||||
, routes_adjustment (1, 1, 128, 1, 4)
|
||||
, routes_spinner (routes_adjustment)
|
||||
, configuration_label (_("Configuration:"))
|
||||
, mode_label (_("Track mode:"))
|
||||
, instrument_label (_("Instrument:"))
|
||||
{
|
||||
set_session (s);
|
||||
|
||||
@@ -76,6 +80,12 @@ AddRouteDialog::AddRouteDialog (Session* s)
|
||||
track_bus_combo.append_text (_("Busses"));
|
||||
track_bus_combo.set_active (0);
|
||||
|
||||
build_instrument_list ();
|
||||
instrument_combo.set_model (instrument_list);
|
||||
instrument_combo.pack_start (instrument_list_columns.name);
|
||||
instrument_combo.set_active (0);
|
||||
instrument_combo.set_button_sensitivity (Gtk::SENSITIVITY_AUTO);
|
||||
|
||||
VBox* vbox = manage (new VBox);
|
||||
Gtk::Label* l;
|
||||
|
||||
@@ -119,8 +129,8 @@ AddRouteDialog::AddRouteDialog (Session* s)
|
||||
|
||||
/* Route configuration */
|
||||
|
||||
l = manage (new Label (_("Configuration:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
|
||||
table2->attach (*l, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
||||
configuration_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
|
||||
table2->attach (configuration_label, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
||||
table2->attach (channel_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
|
||||
++n;
|
||||
|
||||
@@ -135,6 +145,11 @@ AddRouteDialog::AddRouteDialog (Session* s)
|
||||
|
||||
}
|
||||
|
||||
instrument_label.set_alignment (Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
|
||||
table2->attach (instrument_label, 1, 2, n, n + 1, Gtk::FILL, Gtk::EXPAND, 0, 0);
|
||||
table2->attach (instrument_combo, 2, 3, n, n + 1, Gtk::FILL, Gtk::EXPAND | Gtk::FILL, 0, 0);
|
||||
++n;
|
||||
|
||||
/* Group choice */
|
||||
|
||||
l = manage (new Label (_("Group:"), Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER, false));
|
||||
@@ -202,12 +217,24 @@ AddRouteDialog::track_type_chosen ()
|
||||
if (midi_tracks_wanted()) {
|
||||
channel_combo.set_sensitive (false);
|
||||
mode_combo.set_sensitive (false);
|
||||
instrument_combo.set_sensitive (true);
|
||||
configuration_label.set_sensitive (false);
|
||||
mode_label.set_sensitive (false);
|
||||
instrument_label.set_sensitive (true);
|
||||
} else if (audio_tracks_wanted()) {
|
||||
mode_combo.set_sensitive (true);
|
||||
channel_combo.set_sensitive (true);
|
||||
instrument_combo.set_sensitive (false);
|
||||
configuration_label.set_sensitive (true);
|
||||
mode_label.set_sensitive (true);
|
||||
instrument_label.set_sensitive (false);
|
||||
} else {
|
||||
mode_combo.set_sensitive (false);
|
||||
channel_combo.set_sensitive (true);
|
||||
instrument_combo.set_sensitive (false);
|
||||
configuration_label.set_sensitive (true);
|
||||
mode_label.set_sensitive (true);
|
||||
instrument_label.set_sensitive (false);
|
||||
}
|
||||
|
||||
maybe_update_name_template_entry ();
|
||||
@@ -457,3 +484,62 @@ AddRouteDialog::route_separator (const Glib::RefPtr<Gtk::TreeModel> &, const Gtk
|
||||
return route_group_combo.get_active_text () == "separator";
|
||||
}
|
||||
|
||||
void
|
||||
AddRouteDialog::build_instrument_list ()
|
||||
{
|
||||
PluginInfoList all_plugs;
|
||||
PluginManager& manager (PluginManager::instance());
|
||||
TreeModel::Row row;
|
||||
|
||||
all_plugs.insert (all_plugs.end(), manager.ladspa_plugin_info().begin(), manager.ladspa_plugin_info().end());
|
||||
#ifdef WINDOWS_VST_SUPPORT
|
||||
all_plugs.insert (all_plugs.end(), manager.windows_vst_plugin_info().begin(), manager.windows_vst_plugin_info().end());
|
||||
#endif
|
||||
#ifdef LXVST_SUPPORT
|
||||
all_plugs.insert (all_plugs.end(), manager.lxvst_plugin_info().begin(), manager.lxvst_plugin_info().end());
|
||||
#endif
|
||||
#ifdef AUDIOUNIT_SUPPORT
|
||||
all_plugs.insert (all_plugs.end(), manager.au_plugin_info().begin(), manager.au_plugin_info().end());
|
||||
#endif
|
||||
#ifdef LV2_SUPPORT
|
||||
all_plugs.insert (all_plugs.end(), manager.lv2_plugin_info().begin(), manager.lv2_plugin_info().end());
|
||||
#endif
|
||||
|
||||
|
||||
instrument_list = ListStore::create (instrument_list_columns);
|
||||
|
||||
row = *(instrument_list->append());
|
||||
row[instrument_list_columns.info_ptr] = PluginInfoPtr ();
|
||||
row[instrument_list_columns.name] = _("-none-");
|
||||
|
||||
for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
|
||||
|
||||
if (manager.get_status (*i) == PluginManager::Hidden) continue;
|
||||
|
||||
string category = (*i)->category;
|
||||
|
||||
/* XXX more finesse is possible here. VST plugins have a
|
||||
a specific "instrument" flag, for example.
|
||||
*/
|
||||
|
||||
if ((*i)->n_inputs.n_midi() != 0 && (*i)->n_outputs.n_audio() > 0) {
|
||||
row = *(instrument_list->append());
|
||||
row[instrument_list_columns.name] = (*i)->name;
|
||||
row[instrument_list_columns.info_ptr] = *i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PluginInfoPtr
|
||||
AddRouteDialog::requested_instrument ()
|
||||
{
|
||||
TreeModel::iterator iter = instrument_combo.get_active ();
|
||||
TreeModel::Row row;
|
||||
|
||||
if (iter) {
|
||||
row = (*iter);
|
||||
return row[instrument_list_columns.info_ptr];
|
||||
}
|
||||
|
||||
return PluginInfoPtr();
|
||||
}
|
||||
|
||||
@@ -29,9 +29,12 @@
|
||||
#include <gtkmm/adjustment.h>
|
||||
#include <gtkmm/spinbutton.h>
|
||||
#include <gtkmm/button.h>
|
||||
#include <gtkmm/combobox.h>
|
||||
#include <gtkmm/comboboxtext.h>
|
||||
#include <gtkmm/treemodel.h>
|
||||
#include <gtkmm/liststore.h>
|
||||
|
||||
#include "ardour/plugin.h"
|
||||
#include "ardour/types.h"
|
||||
#include "ardour/template_utils.h"
|
||||
|
||||
@@ -52,7 +55,8 @@ class AddRouteDialog : public ArdourDialog
|
||||
|
||||
std::string name_template ();
|
||||
std::string track_template ();
|
||||
|
||||
ARDOUR::PluginInfoPtr requested_instrument ();
|
||||
|
||||
ARDOUR::TrackMode mode();
|
||||
ARDOUR::RouteGroup* route_group ();
|
||||
|
||||
@@ -62,9 +66,12 @@ class AddRouteDialog : public ArdourDialog
|
||||
Gtk::Adjustment routes_adjustment;
|
||||
Gtk::SpinButton routes_spinner;
|
||||
Gtk::ComboBoxText channel_combo;
|
||||
Gtk::Label configuration_label;
|
||||
Gtk::Label mode_label;
|
||||
Gtk::Label instrument_label;
|
||||
Gtk::ComboBoxText mode_combo;
|
||||
Gtk::ComboBoxText route_group_combo;
|
||||
Gtk::ComboBox instrument_combo;
|
||||
|
||||
std::vector<ARDOUR::TemplateInfo> route_templates;
|
||||
|
||||
@@ -94,6 +101,20 @@ class AddRouteDialog : public ArdourDialog
|
||||
|
||||
static std::vector<std::string> channel_combo_strings;
|
||||
static std::vector<std::string> bus_mode_strings;
|
||||
|
||||
struct InstrumentListColumns : public Gtk::TreeModel::ColumnRecord {
|
||||
InstrumentListColumns () {
|
||||
add (name);
|
||||
add (info_ptr);
|
||||
}
|
||||
Gtk::TreeModelColumn<std::string> name;
|
||||
Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> info_ptr;
|
||||
};
|
||||
|
||||
Glib::RefPtr<Gtk::ListStore> instrument_list;
|
||||
InstrumentListColumns instrument_list_columns;
|
||||
|
||||
void build_instrument_list ();
|
||||
};
|
||||
|
||||
#endif /* __gtk_ardour_add_route_dialog_h__ */
|
||||
|
||||
@@ -1441,7 +1441,7 @@ ARDOUR_UI::open_session ()
|
||||
|
||||
|
||||
void
|
||||
ARDOUR_UI::session_add_midi_route (bool disk, RouteGroup* route_group, uint32_t how_many, string const & name_template)
|
||||
ARDOUR_UI::session_add_midi_route (bool disk, RouteGroup* route_group, uint32_t how_many, const string& name_template, PluginInfoPtr instrument)
|
||||
{
|
||||
list<boost::shared_ptr<MidiTrack> > tracks;
|
||||
|
||||
@@ -1453,7 +1453,7 @@ ARDOUR_UI::session_add_midi_route (bool disk, RouteGroup* route_group, uint32_t
|
||||
try {
|
||||
if (disk) {
|
||||
|
||||
tracks = _session->new_midi_track (ARDOUR::Normal, route_group, how_many, name_template);
|
||||
tracks = _session->new_midi_track (instrument, ARDOUR::Normal, route_group, how_many, name_template);
|
||||
|
||||
if (tracks.size() != how_many) {
|
||||
if (how_many == 1) {
|
||||
@@ -1462,6 +1462,7 @@ ARDOUR_UI::session_add_midi_route (bool disk, RouteGroup* route_group, uint32_t
|
||||
error << string_compose (_("could not create %1 new midi tracks"), how_many) << endmsg;
|
||||
}
|
||||
}
|
||||
|
||||
} /*else {
|
||||
if ((route = _session->new_midi_route ()) == 0) {
|
||||
error << _("could not create new midi bus") << endmsg;
|
||||
@@ -3297,6 +3298,7 @@ ARDOUR_UI::add_route (Gtk::Window* float_window)
|
||||
uint32_t input_chan = add_route_dialog->channels ();
|
||||
uint32_t output_chan;
|
||||
string name_template = add_route_dialog->name_template ();
|
||||
PluginInfoPtr instrument = add_route_dialog->requested_instrument ();
|
||||
RouteGroup* route_group = add_route_dialog->route_group ();
|
||||
|
||||
AutoConnectOption oac = Config->get_output_auto_connect();
|
||||
@@ -3310,7 +3312,7 @@ ARDOUR_UI::add_route (Gtk::Window* float_window)
|
||||
/* XXX do something with name template */
|
||||
|
||||
if (add_route_dialog->midi_tracks_wanted()) {
|
||||
session_add_midi_track (route_group, count, name_template);
|
||||
session_add_midi_track (route_group, count, name_template, instrument);
|
||||
} else if (add_route_dialog->audio_tracks_wanted()) {
|
||||
session_add_audio_track (input_chan, output_chan, add_route_dialog->mode(), route_group, count, name_template);
|
||||
} else {
|
||||
|
||||
@@ -58,9 +58,11 @@
|
||||
#include <gtkmm2ext/click_box.h>
|
||||
#include <gtkmm2ext/stateful_button.h>
|
||||
#include <gtkmm2ext/bindable_button.h>
|
||||
|
||||
#include "ardour/ardour.h"
|
||||
#include "ardour/types.h"
|
||||
#include "ardour/utils.h"
|
||||
#include "ardour/plugin.h"
|
||||
#include "ardour/session_handle.h"
|
||||
|
||||
#include "ardour_dialog.h"
|
||||
@@ -226,24 +228,14 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
||||
session_add_audio_route (true, input_channels, output_channels, mode, route_group, how_many, name_template);
|
||||
}
|
||||
|
||||
void session_add_audio_bus (
|
||||
int input_channels,
|
||||
int32_t output_channels,
|
||||
ARDOUR::RouteGroup* route_group,
|
||||
uint32_t how_many,
|
||||
std::string const & name_template
|
||||
) {
|
||||
|
||||
void session_add_audio_bus (int input_channels, int32_t output_channels, ARDOUR::RouteGroup* route_group,
|
||||
uint32_t how_many, std::string const & name_template) {
|
||||
session_add_audio_route (false, input_channels, output_channels, ARDOUR::Normal, route_group, how_many, name_template);
|
||||
}
|
||||
|
||||
void session_add_midi_track (
|
||||
ARDOUR::RouteGroup* route_group,
|
||||
uint32_t how_many,
|
||||
std::string const & name_template
|
||||
) {
|
||||
|
||||
session_add_midi_route (true, route_group, how_many, name_template);
|
||||
void session_add_midi_track (ARDOUR::RouteGroup* route_group, uint32_t how_many, std::string const & name_template,
|
||||
ARDOUR::PluginInfoPtr instrument) {
|
||||
session_add_midi_route (true, route_group, how_many, name_template, instrument);
|
||||
}
|
||||
|
||||
/*void session_add_midi_bus () {
|
||||
@@ -547,7 +539,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
||||
void import_metadata ();
|
||||
|
||||
void session_add_audio_route (bool, int32_t, int32_t, ARDOUR::TrackMode, ARDOUR::RouteGroup *, uint32_t, std::string const &);
|
||||
void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &);
|
||||
void session_add_midi_route (bool, ARDOUR::RouteGroup *, uint32_t, std::string const &, ARDOUR::PluginInfoPtr);
|
||||
|
||||
void set_transport_sensitivity (bool);
|
||||
|
||||
|
||||
@@ -938,7 +938,7 @@ Editor::finish_bringing_in_material (boost::shared_ptr<Region> region, uint32_t
|
||||
|
||||
existing_track = at.front();
|
||||
} else if (mr) {
|
||||
list<boost::shared_ptr<MidiTrack> > mt (_session->new_midi_track (Normal, 0, 1));
|
||||
list<boost::shared_ptr<MidiTrack> > mt (_session->new_midi_track (boost::shared_ptr<PluginInfo>(), Normal, 0, 1));
|
||||
|
||||
if (mt.empty()) {
|
||||
return -1;
|
||||
|
||||
@@ -113,6 +113,7 @@ class MidiTrack;
|
||||
class NamedSelection;
|
||||
class Playlist;
|
||||
class PluginInsert;
|
||||
class PluginInfo;
|
||||
class Port;
|
||||
class PortInsert;
|
||||
class ProcessThread;
|
||||
@@ -455,7 +456,9 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
|
||||
);
|
||||
|
||||
std::list<boost::shared_ptr<MidiTrack> > new_midi_track (
|
||||
TrackMode mode = Normal, RouteGroup* route_group = 0, uint32_t how_many = 1, std::string name_template = ""
|
||||
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 = ""
|
||||
);
|
||||
|
||||
void remove_route (boost::shared_ptr<Route>);
|
||||
|
||||
@@ -81,6 +81,7 @@
|
||||
#include "ardour/named_selection.h"
|
||||
#include "ardour/process_thread.h"
|
||||
#include "ardour/playlist.h"
|
||||
#include "ardour/plugin.h"
|
||||
#include "ardour/plugin_insert.h"
|
||||
#include "ardour/port_insert.h"
|
||||
#include "ardour/processor.h"
|
||||
@@ -1567,9 +1568,10 @@ Session::count_existing_track_channels (ChanCount& in, ChanCount& out)
|
||||
|
||||
/** Caller must not hold process lock
|
||||
* @param name_template string to use for the start of the name, or "" to use "MIDI".
|
||||
* @param instrument plugin info for the instrument to insert pre-fader, if any
|
||||
*/
|
||||
list<boost::shared_ptr<MidiTrack> >
|
||||
Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_many, string name_template)
|
||||
Session::new_midi_track (boost::shared_ptr<PluginInfo> instrument, TrackMode mode, RouteGroup* route_group, uint32_t how_many, string name_template)
|
||||
{
|
||||
char track_name[32];
|
||||
uint32_t track_id = 0;
|
||||
@@ -1645,6 +1647,15 @@ Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m
|
||||
failed:
|
||||
if (!new_routes.empty()) {
|
||||
add_routes (new_routes, true, true);
|
||||
|
||||
if (instrument) {
|
||||
for (RouteList::iterator r = new_routes.begin(); r != new_routes.end(); ++r) {
|
||||
PluginPtr plugin = instrument->load (*this);
|
||||
boost::shared_ptr<Processor> p (new PluginInsert (*this, plugin));
|
||||
(*r)->add_processor (p, PreFader);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user