13
0
livetrax/libs/surfaces/generic_midi/generic_midi_control_protocol.cc
Paul Davis a157537898 a) moved metering and meter falloff code into libardour
b) added initial "big meter" mode for tranzport
c) fixed some lock issues in ARDOUR::IO objects
d) generic_midi control surface module now compiles and loads


git-svn-id: svn://localhost/trunk/ardour2@450 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-04-10 03:54:00 +00:00

72 lines
1.3 KiB
C++

#include <midi++/port.h>
#include <ardour/route.h>
#include <ardour/session.h>
#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<Route*>& routes)
{
if (_port != 0) {
const int32_t bufsize = 16 * 1024;
MIDI::byte buf[bufsize];
int32_t bsize = bufsize;
MIDI::byte* end = buf;
for (list<Route*>::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();
}