diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-07-08 17:10:26 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-09-27 14:59:30 -0500 |
commit | b31df0db2c07c9f17bf1fd64773155caaa0b249d (patch) | |
tree | f5f5f333c3067f307eb6ed8e834d8bfaef6240c0 | |
parent | d2e59c308e9c123e32b1d9920631c392b7277977 (diff) |
add bundle support to push2
-rw-r--r-- | libs/surfaces/push2/push2.cc | 55 | ||||
-rw-r--r-- | libs/surfaces/push2/push2.h | 7 |
2 files changed, 57 insertions, 5 deletions
diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index 60570e5d89..c471049fe6 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -193,8 +193,8 @@ Push2::port_registration_handler () vector<string> in; vector<string> out; - AudioEngine::instance()->get_ports (string_compose (".*%1", input_port_name), DataType::MIDI, PortFlags (IsPhysical|IsOutput), in); - AudioEngine::instance()->get_ports (string_compose (".*%1", output_port_name), DataType::MIDI, PortFlags (IsPhysical|IsInput), out); + AudioEngine::instance()->get_ports (string_compose (".*%1", input_port_name), DataType::MIDI, PortFlags (IsPhysical|IsOutput|ControlOnly), in); + AudioEngine::instance()->get_ports (string_compose (".*%1", output_port_name), DataType::MIDI, PortFlags (IsPhysical|IsInput|ControlOnly), out); if (!in.empty() && !out.empty()) { cerr << "Push2: both ports found\n"; @@ -238,23 +238,68 @@ Push2::open () /* setup ports */ - _async_in = AudioEngine::instance()->register_input_port (DataType::MIDI, X_("push2 in"), true); - _async_out = AudioEngine::instance()->register_output_port (DataType::MIDI, X_("push2 out"), true); + _async_in = AudioEngine::instance()->register_input_port (DataType::MIDI, X_("push 2 in"), true); + _async_out = AudioEngine::instance()->register_output_port (DataType::MIDI, X_("push 2 out"), true); if (_async_in == 0 || _async_out == 0) { return -1; } + _input_bundle.reset (new ARDOUR::Bundle (_("Push 2 In"), true)); + _output_bundle.reset (new ARDOUR::Bundle (_("Push 2 Out"), false)); + + _input_bundle->add_channel ( + _async_in->name(), + ARDOUR::DataType::MIDI, + session->engine().make_port_name_non_relative (_async_in->name()) + ); + + _output_bundle->add_channel ( + _async_out->name(), + ARDOUR::DataType::MIDI, + session->engine().make_port_name_non_relative (_async_out->name()) + ); + + _input_port = boost::dynamic_pointer_cast<AsyncMIDIPort>(_async_in).get(); _output_port = boost::dynamic_pointer_cast<AsyncMIDIPort>(_async_out).get(); - boost::dynamic_pointer_cast<AsyncMIDIPort> (_async_in)->add_shadow_port (string_compose (_("%1 Pads"), X_("Push 2")), boost::bind (&Push2::pad_filter, this, _1, _2)); + /* Create a shadow port where, depending on the state of the surface, + * we will make pad note on/off events appear. The surface code will + * automatically this port to the first selected MIDI track. + */ + + boost::dynamic_pointer_cast<AsyncMIDIPort>(_async_in)->add_shadow_port (string_compose (_("%1 Pads"), X_("Push 2")), boost::bind (&Push2::pad_filter, this, _1, _2)); + boost::shared_ptr<MidiPort> shadow_port = boost::dynamic_pointer_cast<AsyncMIDIPort>(_async_in)->shadow_port(); + + if (shadow_port) { + _output_bundle->add_channel ( + shadow_port->name(), + ARDOUR::DataType::MIDI, + session->engine().make_port_name_non_relative (shadow_port->name()) + ); + } + + session->BundleAddedOrRemoved (); connect_to_parser (); return 0; } +list<boost::shared_ptr<ARDOUR::Bundle> > +Push2::bundles () +{ + list<boost::shared_ptr<ARDOUR::Bundle> > b; + + if (_input_bundle) { + b.push_back (_input_bundle); + b.push_back (_output_bundle); + } + + return b; +} + int Push2::close () { diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h index d92bf89755..6180d66813 100644 --- a/libs/surfaces/push2/push2.h +++ b/libs/surfaces/push2/push2.h @@ -82,6 +82,8 @@ class Push2 : public ARDOUR::ControlProtocol static bool probe (); static void* request_factory (uint32_t); + std::list<boost::shared_ptr<ARDOUR::Bundle> > bundles (); + bool has_editor () const { return true; } void* get_gui () const; void tear_down_gui (); @@ -373,6 +375,11 @@ class Push2 : public ARDOUR::ControlProtocol void build_maps (); + // Bundle to represent our input ports + boost::shared_ptr<ARDOUR::Bundle> _input_bundle; + // Bundle to represent our output ports + boost::shared_ptr<ARDOUR::Bundle> _output_bundle; + MIDI::Port* _input_port; MIDI::Port* _output_port; boost::shared_ptr<ARDOUR::Port> _async_in; |