2006-04-09 23:54:00 -04:00
|
|
|
#include <midi++/port.h>
|
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
#include <ardour/route.h>
|
|
|
|
#include <ardour/session.h>
|
|
|
|
|
2006-04-04 20:21:43 -04:00
|
|
|
#include "generic_midi_control_protocol.h"
|
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
GenericMidiControlProtocol::GenericMidiControlProtocol (Session& s)
|
|
|
|
: ControlProtocol (s, _("GenericMIDI"))
|
|
|
|
{
|
2006-04-09 23:54:00 -04:00
|
|
|
_port = s.midi_port();
|
|
|
|
s.MIDI_PortChanged.connect (mem_fun (*this, &GenericMidiControlProtocol::port_change));
|
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
GenericMidiControlProtocol::~GenericMidiControlProtocol ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-04-09 23:54:00 -04:00
|
|
|
int
|
2006-04-24 18:45:19 -04:00
|
|
|
GenericMidiControlProtocol::set_active (bool yn)
|
2006-04-09 23:54:00 -04:00
|
|
|
{
|
|
|
|
/* start delivery/outbound thread */
|
2006-04-24 18:45:19 -04:00
|
|
|
return 0;
|
2006-04-09 23:54:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::port_change ()
|
|
|
|
{
|
|
|
|
_port = session.midi_port ();
|
|
|
|
}
|
|
|
|
|
2006-04-03 23:26:08 -04:00
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::set_port (MIDI::Port* p)
|
|
|
|
{
|
|
|
|
_port = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
GenericMidiControlProtocol::send_route_feedback (list<Route*>& routes)
|
|
|
|
{
|
|
|
|
if (_port != 0) {
|
|
|
|
|
|
|
|
const int32_t bufsize = 16 * 1024;
|
2006-04-09 23:54:00 -04:00
|
|
|
MIDI::byte buf[bufsize];
|
2006-04-03 23:26:08 -04:00
|
|
|
int32_t bsize = bufsize;
|
|
|
|
MIDI::byte* end = buf;
|
|
|
|
|
|
|
|
for (list<Route*>::iterator r = routes.begin(); r != routes.end(); ++r) {
|
2006-04-09 23:54:00 -04:00
|
|
|
end = (*r)->write_midi_feedback (end, bsize);
|
2006-04-03 23:26:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (end == buf) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-04-09 23:54:00 -04:00
|
|
|
_port->write (buf, (int32_t) (end - buf));
|
2006-04-03 23:26:08 -04:00
|
|
|
//cerr << "MIDI feedback: wrote " << (int32_t) (end - buf) << " to midi port\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|