diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-07-07 16:28:15 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-09-27 14:59:30 -0500 |
commit | 33a2995fd8c335673788aeb2ccb75b9f43bb4b40 (patch) | |
tree | 007cc7edb1cbe3ba0709a37f78d8c20e02dcef23 /libs/surfaces/push2 | |
parent | 70477e6fedee80a4e785d4da65c873329d06f76a (diff) |
push2: save and restore push2 pad state, etc.
Diffstat (limited to 'libs/surfaces/push2')
-rw-r--r-- | libs/surfaces/push2/gui.cc | 7 | ||||
-rw-r--r-- | libs/surfaces/push2/push2.cc | 47 | ||||
-rw-r--r-- | libs/surfaces/push2/push2.h | 15 |
3 files changed, 47 insertions, 22 deletions
diff --git a/libs/surfaces/push2/gui.cc b/libs/surfaces/push2/gui.cc index 0c417276c4..e0ddb53e19 100644 --- a/libs/surfaces/push2/gui.cc +++ b/libs/surfaces/push2/gui.cc @@ -84,7 +84,7 @@ P2GUI::P2GUI (Push2& p) , action_table (5, 4) , ignore_active_change (false) , pad_table (8, 8) - , root_note_octave_adjustment (3, 0, 10, 1, 1) + , root_note_octave_adjustment (p2.root_octave(), 0, 10, 1, 1) , root_note_octave (root_note_octave_adjustment) , root_note_octave_label (_("Octave")) , root_note_label (_("Root")) @@ -139,11 +139,11 @@ P2GUI::P2GUI (Push2& p) root_note_selector.set_model (build_note_columns()); root_note_selector.pack_start (note_columns.name); - root_note_selector.set_active (0); + root_note_selector.set_active (p2.scale_root()); mode_selector.set_model (build_mode_columns()); mode_selector.pack_start (mode_columns.name); - mode_selector.set_active (0); + mode_selector.set_active ((int) p2.mode()); mode_packer.set_border_width (12); mode_packer.set_spacings (12); @@ -157,6 +157,7 @@ P2GUI::P2GUI (Push2& p) mode_packer.attach (mode_label, 0, 1, 2, 3, AttachOptions (FILL|EXPAND), SHRINK); mode_packer.attach (mode_selector, 1, 2, 2, 3, AttachOptions (FILL|EXPAND), SHRINK); + inkey_button.set_active (p2.in_key()); mode_packer.attach (inkey_button, 1, 2, 3, 4, AttachOptions (FILL|EXPAND), SHRINK); pad_notebook.append_page (pad_table, _("Pad Layout")); diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index d5672fe886..ffbdef4e9d 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -126,10 +126,10 @@ Push2::Push2 (ARDOUR::Session& s) , bank_start (0) , connection_state (ConnectionState (0)) , gui (0) - , mode (MusicalMode::IonianMajor) - , scale_root (36) - , root_octave (3) - , in_key (true) + , _mode (MusicalMode::IonianMajor) + , _scale_root (0) + , _root_octave (3) + , _in_key (true) , octave_shift (0) { context = Cairo::Context::create (frame_buffer); @@ -651,7 +651,7 @@ Push2::set_active (bool yn) init_buttons (true); init_touch_strip (); - set_pad_scale (scale_root, root_octave, mode, in_key); + set_pad_scale (_scale_root, _root_octave, _mode, _in_key); switch_bank (0); splash (); @@ -1114,10 +1114,10 @@ Push2::get_state() child->add_child_nocopy (_async_out->get_state()); node.add_child_nocopy (*child); - node.add_property ("root", to_string (scale_root, std::dec)); - node.add_property ("root_octave", to_string (root_octave, std::dec)); - node.add_property ("in_key", in_key ? X_("yes") : X_("no")); - node.add_property ("mode", enum_2_string (mode)); + node.add_property (X_("root"), to_string (_scale_root, std::dec)); + node.add_property (X_("root_octave"), to_string (_root_octave, std::dec)); + node.add_property (X_("in_key"), _in_key ? X_("yes") : X_("no")); + node.add_property (X_("mode"), enum_2_string (_mode)); return node; } @@ -1149,6 +1149,24 @@ Push2::set_state (const XMLNode & node, int version) } } + XMLProperty const* prop; + + if ((prop = node.property (X_("root"))) != 0) { + _scale_root = atoi (prop->value()); + } + + if ((prop = node.property (X_("root_octave"))) != 0) { + _root_octave = atoi (prop->value()); + } + + if ((prop = node.property (X_("in_key"))) != 0) { + _in_key = string_is_affirmative (prop->value()); + } + + if ((prop = node.property (X_("mode"))) != 0) { + _mode = (MusicalMode::Type) string_2_enum (prop->value(), _mode); + } + return retval; } @@ -1737,7 +1755,7 @@ Push2::pad_note (int row, int col) const void Push2::set_pad_scale (int root, int octave, MusicalMode::Type mode, bool inkey) { - cerr << "reset pad to r = " << root << " o = " << octave << " m = " << mode << endl; + cerr << "reset pad to r = " << root << " o = " << octave << " m = " << mode << " ik " << inkey << endl; MusicalMode m (mode); vector<float>::iterator interval; @@ -1803,6 +1821,7 @@ Push2::set_pad_scale (int root, int octave, MusicalMode::Type mode, bool inkey) if ((notenum % 12) == original_root) { pad->set_color (LED::Green); + cerr << "Green!\n"; pad->perma_color = LED::Green; } else { pad->set_color (LED::White); @@ -1866,8 +1885,8 @@ Push2::set_pad_scale (int root, int octave, MusicalMode::Type mode, bool inkey) /* store state */ - scale_root = root; - root_octave = octave; - in_key = inkey; - mode = mode; + _scale_root = original_root; + _root_octave = octave; + _in_key = inkey; + _mode = mode; } diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h index e39c07e76c..d92bf89755 100644 --- a/libs/surfaces/push2/push2.h +++ b/libs/surfaces/push2/push2.h @@ -100,7 +100,12 @@ class Push2 : public ARDOUR::ControlProtocol void set_pad_scale (int root, int octave, MusicalMode::Type mode, bool inkey); - private: + MusicalMode::Type mode() const { return _mode; } + int scale_root() const { return _scale_root; } + int root_octave() const { return _root_octave; } + bool in_key() const { return _in_key; } + + private: libusb_device_handle *handle; uint8_t frame_header[16]; uint16_t* device_frame_buffer; @@ -514,10 +519,10 @@ class Push2 : public ARDOUR::ControlProtocol std::map<int,int> pad_map; void build_pad_table(); - MusicalMode::Type mode; - int scale_root; - int root_octave; - bool in_key; + MusicalMode::Type _mode; + int _scale_root; + int _root_octave; + bool _in_key; int octave_shift; }; |