#include #include #include #include "generic_midi_control_protocol.h" using namespace ARDOUR; #include "i18n.h" GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s) : ControlProtocol (s, _("GenericMIDI")) { _port = s.midi_port(); s.MIDI_PortChanged.connect (mem_fun (*this, &GenericMidiControlProtocol::port_change)); } GenericMidiControlProtocol::~GenericMidiControlProtocol () { } int GenericMidiControlProtocol::init () { /* start delivery/outbound thread */ return init_thread (); } void GenericMidiControlProtocol::port_change () { _port = session.midi_port (); } void GenericMidiControlProtocol::set_port (MIDI::Port* p) { _port = p; } void GenericMidiControlProtocol::send_route_feedback (list& routes) { if (_port != 0) { const int32_t bufsize = 16 * 1024; MIDI::byte buf[bufsize]; int32_t bsize = bufsize; MIDI::byte* end = buf; for (list::iterator r = routes.begin(); r != routes.end(); ++r) { end = (*r)->write_midi_feedback (end, bsize); } if (end == buf) { return; } _port->write (buf, (int32_t) (end - buf)); //cerr << "MIDI feedback: wrote " << (int32_t) (end - buf) << " to midi port\n"; } } bool GenericMidiControlProtocol::active() const { return _port && send(); }