summaryrefslogtreecommitdiff
path: root/gtk2_ardour/midi_time_axis.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-05-25 15:19:47 +0000
committerCarl Hetherington <carl@carlh.net>2011-05-25 15:19:47 +0000
commit711db34a81eed3748684bc52b17a56292ffe4092 (patch)
tree19680b02723ff9519bded9d46a21398d9ec7c9d3 /gtk2_ardour/midi_time_axis.cc
parente984220eaaa318d9b51ebb20995d1bccae389389 (diff)
Remove MIDI track default channel and its menu, and choose the channel for new notes using MidiTimeAxisView::get_channel_for_add() (fixes #3998 and #3865).
git-svn-id: svn://localhost/ardour2/branches/3.0@9585 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/midi_time_axis.cc')
-rw-r--r--gtk2_ardour/midi_time_axis.cc62
1 files changed, 29 insertions, 33 deletions
diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc
index cf37ace16a..28401fc6d5 100644
--- a/gtk2_ardour/midi_time_axis.cc
+++ b/gtk2_ardour/midi_time_axis.cc
@@ -115,7 +115,6 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session* sess,
, _track_color_mode_item(0)
, _step_edit_item (0)
, _midi_thru_item (0)
- , default_channel_menu (0)
, controller_menu (0)
, _step_editor (0)
{
@@ -367,7 +366,6 @@ MidiTimeAxisView::append_extra_display_menu_items ()
items.push_back (MenuElem (_("Note Range"), *range_menu));
items.push_back (MenuElem (_("Note Mode"), *build_note_mode_menu()));
- items.push_back (MenuElem (_("Default Channel"), *build_def_channel_menu()));
items.push_back (CheckMenuElem (_("MIDI Thru"), sigc::mem_fun(*this, &MidiTimeAxisView::toggle_midi_thru)));
_midi_thru_item = dynamic_cast<CheckMenuItem*>(&items.back());
@@ -375,37 +373,6 @@ MidiTimeAxisView::append_extra_display_menu_items ()
items.push_back (SeparatorElem ());
}
-Gtk::Menu*
-MidiTimeAxisView::build_def_channel_menu ()
-{
- using namespace Menu_Helpers;
-
- default_channel_menu = manage (new Menu ());
-
- uint8_t defchn = midi_track()->default_channel();
- MenuList& def_channel_items = default_channel_menu->items();
- RadioMenuItem* item;
- RadioMenuItem::Group dc_group;
-
- for (int i = 0; i < 16; ++i) {
- char buf[4];
- snprintf (buf, sizeof (buf), "%d", i+1);
-
- def_channel_items.push_back (RadioMenuElem (dc_group, buf,
- sigc::bind (sigc::mem_fun (*this, &MidiTimeAxisView::set_default_channel), i)));
- item = dynamic_cast<RadioMenuItem*>(&def_channel_items.back());
- item->set_active ((i == defchn));
- }
-
- return default_channel_menu;
-}
-
-void
-MidiTimeAxisView::set_default_channel (int chn)
-{
- midi_track()->set_default_channel (chn);
-}
-
void
MidiTimeAxisView::toggle_midi_thru ()
{
@@ -1133,3 +1100,32 @@ MidiTimeAxisView::stop_step_editing ()
_step_editor->stop_step_editing ();
}
}
+
+
+/** @return channel (counted from 0) to add an event to, based on the current setting
+ * of the channel selector.
+ */
+uint8_t
+MidiTimeAxisView::get_channel_for_add () const
+{
+ uint16_t const chn_mask = _channel_selector.get_selected_channels ();
+ int chn_cnt = 0;
+ uint8_t channel = 0;
+
+ /* pick the highest selected channel, unless all channels are selected,
+ which is interpreted to mean channel 1 (zero)
+ */
+
+ for (uint16_t i = 0; i < 16; ++i) {
+ if (chn_mask & (1<<i)) {
+ channel = i;
+ chn_cnt++;
+ }
+ }
+
+ if (chn_cnt == 16) {
+ channel = 0;
+ }
+
+ return channel;
+}