mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 08:36:32 +01:00
Optimize MTAV creation, speed up new MIDI track
This removes various duplicate code-paths leading to midi-model updates, and expensive context-menu rebuilds. This significantly speeds up MIDI track creation.
This commit is contained in:
parent
21c9505652
commit
714e2f1736
2 changed files with 68 additions and 74 deletions
|
|
@ -264,10 +264,9 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
|
||||||
_midi_controls_box.set_homogeneous(false);
|
_midi_controls_box.set_homogeneous(false);
|
||||||
_midi_controls_box.set_border_width (2);
|
_midi_controls_box.set_border_width (2);
|
||||||
|
|
||||||
MIDI::Name::MidiPatchManager::instance().maybe_use (*this, invalidator (*this), boost::bind (&MidiTimeAxisView::use_midnam_info, this), gui_context());
|
|
||||||
|
|
||||||
maybe_trigger_model_change ();
|
/* this directly calls use_midnam_info() if there are midnam's already */
|
||||||
custom_device_mode_changed (gui_property(X_("midnam-custom-device-mode")));
|
MIDI::Name::MidiPatchManager::instance().maybe_use (*this, invalidator (*this), boost::bind (&MidiTimeAxisView::use_midnam_info, this), gui_context());
|
||||||
|
|
||||||
controls_vbox.pack_start(_midi_controls_box, false, false);
|
controls_vbox.pack_start(_midi_controls_box, false, false);
|
||||||
|
|
||||||
|
|
@ -312,7 +311,7 @@ void
|
||||||
MidiTimeAxisView::processors_changed (RouteProcessorChange c)
|
MidiTimeAxisView::processors_changed (RouteProcessorChange c)
|
||||||
{
|
{
|
||||||
RouteTimeAxisView::processors_changed (c);
|
RouteTimeAxisView::processors_changed (c);
|
||||||
update_patch_selector ();
|
maybe_trigger_model_change ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -347,9 +346,7 @@ MidiTimeAxisView::check_step_edit ()
|
||||||
void
|
void
|
||||||
MidiTimeAxisView::use_midnam_info ()
|
MidiTimeAxisView::use_midnam_info ()
|
||||||
{
|
{
|
||||||
//cerr << "MidiTimeAxisView::use_midnam_info\n";
|
|
||||||
setup_midnam_patches ();
|
setup_midnam_patches ();
|
||||||
update_patch_selector ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -392,57 +389,6 @@ MidiTimeAxisView::setup_midnam_patches ()
|
||||||
_midnam_model_selector.AddMenuElem(Menu_Helpers::MenuElem(m->first, *menu));
|
_midnam_model_selector.AddMenuElem(Menu_Helpers::MenuElem(m->first, *menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string model = gui_property (X_("midnam-model-name"));
|
|
||||||
if (model.empty() && _route->instrument_info().have_custom_plugin_info ()) {
|
|
||||||
/* use plugin's MIDNAM */
|
|
||||||
model_changed ("");
|
|
||||||
} else if (!_route->instrument_info().master_device_names()) {
|
|
||||||
/* switch to use default */
|
|
||||||
model_changed ("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MidiTimeAxisView::maybe_trigger_model_change ()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (_route->instrument_info().have_custom_plugin_info ()) {
|
|
||||||
const std::string saved_model_name = gui_property (X_("midnam-model-name"));
|
|
||||||
|
|
||||||
if (!saved_model_name.empty()) {
|
|
||||||
/* user changed the MIDNAM model to something
|
|
||||||
* other than the plugin provided one. We
|
|
||||||
* should use that, and not the "plugin
|
|
||||||
* provided" label.
|
|
||||||
*/
|
|
||||||
model_changed (saved_model_name);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
/* user has not explicitly set MIDNAM model, and
|
|
||||||
* there's a plugin provided MIDNAM. Ensure that
|
|
||||||
* "Plugin Provided" is prefixed at the top of the list
|
|
||||||
*/
|
|
||||||
model_changed ("");
|
|
||||||
if (_midnam_model_selector.items().empty () || _midnam_model_selector.items().begin()->get_label() != _("Plugin Provided")) {
|
|
||||||
setup_midnam_patches ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* no plugin provided MIDNAM for this plugin */
|
|
||||||
setup_midnam_patches ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
MidiTimeAxisView::update_patch_selector ()
|
|
||||||
{
|
|
||||||
typedef MIDI::Name::MidiPatchManager PatchManager;
|
|
||||||
PatchManager& patch_manager = PatchManager::instance();
|
|
||||||
|
|
||||||
if (_route) {
|
|
||||||
maybe_trigger_model_change ();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (patch_manager.all_models().empty()) {
|
if (patch_manager.all_models().empty()) {
|
||||||
_midnam_model_selector.hide ();
|
_midnam_model_selector.hide ();
|
||||||
_midnam_custom_device_mode_selector.hide ();
|
_midnam_custom_device_mode_selector.hide ();
|
||||||
|
|
@ -452,6 +398,36 @@ MidiTimeAxisView::update_patch_selector ()
|
||||||
_midnam_custom_device_mode_selector.show ();
|
_midnam_custom_device_mode_selector.show ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* call _midnam_model_selector.set_text ()
|
||||||
|
* and show/hide _midnam_custom_device_mode_selector
|
||||||
|
*/
|
||||||
|
std::string model = gui_property (X_("midnam-model-name"));
|
||||||
|
if (model.empty() && _route->instrument_info().have_custom_plugin_info ()) {
|
||||||
|
/* use plugin's MIDNAM */
|
||||||
|
model_changed ("");
|
||||||
|
} else if (!_route->instrument_info().master_device_names()) {
|
||||||
|
/* switch to use default */
|
||||||
|
model_changed ("");
|
||||||
|
} else {
|
||||||
|
model_changed (model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MidiTimeAxisView::maybe_trigger_model_change ()
|
||||||
|
{
|
||||||
|
bool changed = false;
|
||||||
|
if (_route->instrument_info().have_custom_plugin_info ()) {
|
||||||
|
if (_midnam_model_selector.items().empty () || _midnam_model_selector.items().begin()->get_label() != _("Plugin Provided")) {
|
||||||
|
setup_midnam_patches ();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* no plugin provided MIDNAM for this plugin */
|
||||||
|
if (!_midnam_model_selector.items().empty () && _midnam_model_selector.items().begin()->get_label() == _("Plugin Provided")) {
|
||||||
|
setup_midnam_patches ();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -479,8 +455,6 @@ MidiTimeAxisView::model_changed (const std::string& m)
|
||||||
device_modes = patch_manager.custom_device_mode_names_by_model (model);
|
device_modes = patch_manager.custom_device_mode_names_by_model (model);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string current_mode = gui_property (X_("midname-custom-device-mode"));
|
|
||||||
|
|
||||||
if (model == "") {
|
if (model == "") {
|
||||||
_midnam_model_selector.set_text (_("Plugin Provided"));
|
_midnam_model_selector.set_text (_("Plugin Provided"));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -491,36 +465,56 @@ MidiTimeAxisView::model_changed (const std::string& m)
|
||||||
set_gui_property (X_("midnam-model-name"), model);
|
set_gui_property (X_("midnam-model-name"), model);
|
||||||
} else {
|
} else {
|
||||||
remove_gui_property (X_("midnam-model-name"));
|
remove_gui_property (X_("midnam-model-name"));
|
||||||
|
model = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set new mode */
|
||||||
|
const std::string current_mode = gui_property (X_("midname-custom-device-mode"));
|
||||||
|
std::string mode;
|
||||||
|
if (find (device_modes.begin(), device_modes.end(), current_mode) == device_modes.end()) {
|
||||||
|
if (device_modes.size() > 0) {
|
||||||
|
mode = device_modes.front();
|
||||||
|
custom_device_mode_changed (device_modes.front());
|
||||||
|
} else {
|
||||||
|
mode = "";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
mode = current_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set backend state */
|
||||||
|
_route->instrument_info().set_external_instrument (model, mode);
|
||||||
|
|
||||||
|
if (_effective_model == _route->instrument_info().model () && _effective_mode == _route->instrument_info().mode ()) {
|
||||||
|
/* no change */
|
||||||
|
printf (" ---- SKIP ----\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_effective_model = _route->instrument_info().model ();
|
||||||
|
_effective_mode = _route->instrument_info().mode ();
|
||||||
|
|
||||||
|
/* update GUI */
|
||||||
|
|
||||||
_midnam_custom_device_mode_selector.clear_items();
|
_midnam_custom_device_mode_selector.clear_items();
|
||||||
for (std::list<std::string>::const_iterator i = device_modes.begin(); i != device_modes.end(); ++i) {
|
for (std::list<std::string>::const_iterator i = device_modes.begin(); i != device_modes.end(); ++i) {
|
||||||
_midnam_custom_device_mode_selector.AddMenuElem (Gtk::Menu_Helpers::MenuElem(*i, sigc::bind(sigc::mem_fun(*this, &MidiTimeAxisView::custom_device_mode_changed), *i)));
|
_midnam_custom_device_mode_selector.AddMenuElem (Gtk::Menu_Helpers::MenuElem(*i, sigc::bind(sigc::mem_fun(*this, &MidiTimeAxisView::custom_device_mode_changed), *i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (find (device_modes.begin(), device_modes.end(), current_mode) == device_modes.end()) {
|
|
||||||
if (device_modes.size() > 0) {
|
|
||||||
custom_device_mode_changed (device_modes.front());
|
|
||||||
} else {
|
|
||||||
custom_device_mode_changed ("");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
custom_device_mode_changed (current_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (device_modes.size() > 1) {
|
if (device_modes.size() > 1) {
|
||||||
_midnam_custom_device_mode_selector.show();
|
_midnam_custom_device_mode_selector.show();
|
||||||
} else {
|
} else {
|
||||||
_midnam_custom_device_mode_selector.hide();
|
_midnam_custom_device_mode_selector.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
//cerr << "MidiTimeAxisView::model_changed model '" << model << "' mode '" << current_mode << "'\n";
|
/* set _midnam_custom_device_mode_selector */
|
||||||
|
custom_device_mode_changed (mode);
|
||||||
|
|
||||||
// Rebuild controller menu
|
/* Rebuild controller menu */
|
||||||
_controller_menu_map.clear ();
|
_controller_menu_map.clear ();
|
||||||
delete controller_menu;
|
delete controller_menu;
|
||||||
controller_menu = 0;
|
controller_menu = 0;
|
||||||
build_automation_action_menu(false);
|
build_automation_action_menu (false);
|
||||||
|
|
||||||
if (patch_change_dialog ()) {
|
if (patch_change_dialog ()) {
|
||||||
patch_change_dialog ()->refresh ();
|
patch_change_dialog ()->refresh ();
|
||||||
|
|
@ -531,7 +525,6 @@ void
|
||||||
MidiTimeAxisView::custom_device_mode_changed(const std::string& mode)
|
MidiTimeAxisView::custom_device_mode_changed(const std::string& mode)
|
||||||
{
|
{
|
||||||
const std::string model = gui_property (X_("midnam-model-name"));
|
const std::string model = gui_property (X_("midnam-model-name"));
|
||||||
|
|
||||||
set_gui_property (X_("midnam-custom-device-mode"), mode);
|
set_gui_property (X_("midnam-custom-device-mode"), mode);
|
||||||
_midnam_custom_device_mode_selector.set_text (mode);
|
_midnam_custom_device_mode_selector.set_text (mode);
|
||||||
/* inform the backend, route owned instrument info */
|
/* inform the backend, route owned instrument info */
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,6 @@ private:
|
||||||
sigc::signal<void, std::string, std::string> _midi_patch_settings_changed;
|
sigc::signal<void, std::string, std::string> _midi_patch_settings_changed;
|
||||||
|
|
||||||
void setup_midnam_patches ();
|
void setup_midnam_patches ();
|
||||||
void update_patch_selector ();
|
|
||||||
|
|
||||||
sigc::connection _note_range_changed_connection;
|
sigc::connection _note_range_changed_connection;
|
||||||
|
|
||||||
|
|
@ -143,6 +142,8 @@ private:
|
||||||
void update_control_names ();
|
void update_control_names ();
|
||||||
|
|
||||||
bool _ignore_signals;
|
bool _ignore_signals;
|
||||||
|
std::string _effective_model;
|
||||||
|
std::string _effective_mode;
|
||||||
MidiScroomer* _range_scroomer;
|
MidiScroomer* _range_scroomer;
|
||||||
PianoRollHeader* _piano_roll_header;
|
PianoRollHeader* _piano_roll_header;
|
||||||
ARDOUR::NoteMode _note_mode;
|
ARDOUR::NoteMode _note_mode;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue