Persist track MIDNAM settings via a GUI property. Fix a

couple of crashes with the MIDNAM code.


git-svn-id: svn://localhost/ardour2/branches/3.0@12543 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2012-06-02 14:53:34 +00:00
parent fd89d52af5
commit dcd6dbf14b
4 changed files with 42 additions and 10 deletions

View File

@ -113,6 +113,10 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &
_note_group->raise_to_top();
PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys));
/* Look up MIDNAM details from our MidiTimeAxisView */
MidiTimeAxisView& mtv = dynamic_cast<MidiTimeAxisView&> (tv);
midi_patch_settings_changed (mtv.midi_patch_model (), mtv.midi_patch_custom_device_node ());
Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&MidiRegionView::parameter_changed, this, _1), gui_context());
connect_to_diskstream ();
@ -149,6 +153,10 @@ MidiRegionView::MidiRegionView (ArdourCanvas::Group *parent, RouteTimeAxisView &
_note_group->raise_to_top();
PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys));
/* Look up MIDNAM details from our MidiTimeAxisView */
MidiTimeAxisView& mtv = dynamic_cast<MidiTimeAxisView&> (tv);
midi_patch_settings_changed (mtv.midi_patch_model (), mtv.midi_patch_custom_device_node ());
connect_to_diskstream ();
SelectionCleared.connect (_selection_cleared_connection, invalidator (*this), boost::bind (&MidiRegionView::selection_cleared, this, _1), gui_context ());

View File

@ -199,14 +199,14 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt)
_model_selector.append_text(m->c_str());
}
_model_selector.signal_changed().connect(sigc::mem_fun(*this, &MidiTimeAxisView::model_changed));
_custom_device_mode_selector.signal_changed().connect(
sigc::mem_fun(*this, &MidiTimeAxisView::custom_device_mode_changed));
// TODO: persist the choice
// this initializes the comboboxes and sends out the signal
_model_selector.set_active(0);
_model_selector.set_active_text (gui_property (X_("midnam-model-name")));
_custom_device_mode_selector.set_active_text (gui_property (X_("midnam-custom-device-mode")));
midi_controls_hbox->pack_start(_channel_selector, true, false);
if (!patch_manager.all_models().empty()) {
@ -317,12 +317,15 @@ MidiTimeAxisView::model_changed()
}
_custom_device_mode_selector.set_active(0);
set_gui_property (X_("midnam-model-name"), midi_patch_model ());
}
void MidiTimeAxisView::custom_device_mode_changed()
void
MidiTimeAxisView::custom_device_mode_changed()
{
_midi_patch_settings_changed.emit(_model_selector.get_active_text(),
_custom_device_mode_selector.get_active_text());
_midi_patch_settings_changed.emit (midi_patch_model (), midi_patch_custom_device_node ());
set_gui_property (X_("midnam-custom-device-mode"), midi_patch_custom_device_node ());
}
MidiStreamView*
@ -1203,3 +1206,15 @@ MidiTimeAxisView::note_range_changed ()
set_gui_property ("note-range-min", (int) midi_view()->lowest_note ());
set_gui_property ("note-range-max", (int) midi_view()->highest_note ());
}
string
MidiTimeAxisView::midi_patch_model () const
{
return _model_selector.get_active_text ();
}
string
MidiTimeAxisView::midi_patch_custom_device_node () const
{
return _custom_device_mode_selector.get_active_text ();
}

View File

@ -102,6 +102,9 @@ class MidiTimeAxisView : public RouteTimeAxisView
uint8_t get_channel_for_add () const;
std::string midi_patch_model () const;
std::string midi_patch_custom_device_node () const;
protected:
void start_step_editing ();
void stop_step_editing ();

View File

@ -171,7 +171,7 @@ PatchChangeDialog::set_active_bank_combo ()
boost::replace_all (n, "_", " ");
MIDI::Name::PatchPrimaryKey const * key = (*i)->patch_primary_key ();
if (((key->msb << 7) | key->lsb) == _bank.get_value () - 1) {
if (key && ((key->msb << 7) | key->lsb) == _bank.get_value () - 1) {
_current_patch_bank = *i;
_ignore_signals = true;
_bank_combo.set_active_text (n);
@ -210,15 +210,21 @@ PatchChangeDialog::bank_combo_changed ()
}
}
if (_current_patch_bank == 0) {
return;
}
/* Reflect */
fill_patch_combo ();
set_active_patch_combo ();
MIDI::Name::PatchPrimaryKey const * key = _current_patch_bank->patch_primary_key ();
_ignore_signals = true;
_bank.set_value (((key->msb << 7) | key->lsb) + 1);
_ignore_signals = false;
if (key) {
_ignore_signals = true;
_bank.set_value (((key->msb << 7) | key->lsb) + 1);
_ignore_signals = false;
}
}
/** Fill the contents of the patch combo */