summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/midi_channel_selector.cc20
-rw-r--r--gtk2_ardour/midi_channel_selector.h3
-rw-r--r--gtk2_ardour/midi_time_axis.cc5
-rw-r--r--libs/ardour/midi_diskstream.cc9
4 files changed, 34 insertions, 3 deletions
diff --git a/gtk2_ardour/midi_channel_selector.cc b/gtk2_ardour/midi_channel_selector.cc
index b810268633..1b0e9ecfbb 100644
--- a/gtk2_ardour/midi_channel_selector.cc
+++ b/gtk2_ardour/midi_channel_selector.cc
@@ -75,7 +75,7 @@ SingleMidiChannelSelector::button_toggled(ToggleButton *button, uint8_t channel)
--_recursion_counter;
}
-MidiMultipleChannelSelector::MidiMultipleChannelSelector(uint16_t initial_selection)
+MidiMultipleChannelSelector::MidiMultipleChannelSelector(uint16_t initial_selection, int8_t force_channel)
: MidiChannelSelector(4, 6, 0, 0), _mode(FILTERING_MULTIPLE_CHANNELS)
{
_select_all.add(*manage(new Label(_("All"))));
@@ -129,6 +129,24 @@ MidiMultipleChannelSelector::get_force_channel() const
return -1;
}
+void
+MidiMultipleChannelSelector::set_force_channel(int8_t channel)
+{
+ if(channel < 0) {
+ // if forcing is already activated, deactivate
+ if(_mode == FORCING_SINGLE_CHANNEL) {
+ _force_channel.toggled();
+ }
+ // if not, nothing to do
+ } else {
+ // otherwise simulate activating force channels by pressing the
+ // two buttons the user would press
+ _force_channel.toggled();
+ _buttons[channel / 4][channel % 4].toggled();
+ }
+}
+
+
const uint16_t
MidiMultipleChannelSelector::get_selected_channels() const
{
diff --git a/gtk2_ardour/midi_channel_selector.h b/gtk2_ardour/midi_channel_selector.h
index 901296903c..3562f5febe 100644
--- a/gtk2_ardour/midi_channel_selector.h
+++ b/gtk2_ardour/midi_channel_selector.h
@@ -41,7 +41,7 @@ protected:
class MidiMultipleChannelSelector : public MidiChannelSelector
{
public:
- MidiMultipleChannelSelector(uint16_t initial_selection = 1);
+ MidiMultipleChannelSelector(uint16_t initial_selection = 0xFFFF, int8_t force_channel = -1);
virtual ~MidiMultipleChannelSelector();
/**
@@ -56,6 +56,7 @@ public:
sigc::signal<void, int8_t> force_channel_changed;
const int8_t get_force_channel() const;
+ void set_force_channel(int8_t force_channel);
protected:
enum Mode {
FILTERING_MULTIPLE_CHANNELS,
diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc
index 16edd88f72..dec553f408 100644
--- a/gtk2_ardour/midi_time_axis.cc
+++ b/gtk2_ardour/midi_time_axis.cc
@@ -91,7 +91,6 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar
, _note_mode_item(NULL)
, _percussion_mode_item(NULL)
, _midi_expander("MIDI")
- , _channel_selector(0xFFFF)
{
subplugin_menu.set_name ("ArdourContextMenu");
@@ -144,6 +143,10 @@ MidiTimeAxisView::MidiTimeAxisView (PublicEditor& ed, Session& sess, boost::shar
_midi_expander.property_expanded().signal_changed().connect(
mem_fun(this, &MidiTimeAxisView::channel_selector_toggled));
controls_vbox.pack_end(_midi_expander, SHRINK, 0);
+ boost::shared_ptr<MidiDiskstream> diskstream = midi_track()->midi_diskstream();
+ // restore channel selector settings
+ _channel_selector.set_selected_channels(diskstream->get_channel_mask());
+ _channel_selector.set_force_channel(diskstream->get_force_channel());
_channel_selector.selection_changed.connect(
mem_fun(*midi_track()->midi_diskstream(), &MidiDiskstream::set_channel_mask));
_channel_selector.force_channel_changed.connect(
diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc
index 3d9aaca93f..885435e238 100644
--- a/libs/ardour/midi_diskstream.cc
+++ b/libs/ardour/midi_diskstream.cc
@@ -1229,6 +1229,9 @@ MidiDiskstream::get_state ()
snprintf (buf, sizeof(buf), "0x%x", get_channel_mask());
node->add_property("channel_mask", buf);
+ snprintf (buf, sizeof(buf), "%d", get_force_channel());
+ node->add_property("force_channel", buf);
+
node->add_property ("playlist", _playlist->name());
snprintf (buf, sizeof(buf), "%f", _visible_speed);
@@ -1312,6 +1315,12 @@ MidiDiskstream::set_state (const XMLNode& node)
sscanf (prop->value().c_str(), "0x%x", &channel_mask);
set_channel_mask(channel_mask);
}
+
+ if ((prop = node.property ("force_channel")) != 0) {
+ int force_channel;
+ sscanf (prop->value().c_str(), "%d", &force_channel);
+ set_force_channel(force_channel);
+ }
if ((prop = node.property ("channels")) != 0) {
nchans = atoi (prop->value().c_str());