summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Anderson <ardour@semiosix.com>2007-09-09 19:16:00 +0000
committerJohn Anderson <ardour@semiosix.com>2007-09-09 19:16:00 +0000
commitebadae4c96f84af4cb7c51eab006e0bb1778aa7c (patch)
tree09fe58f95e8be39a6c6b7329df7c7ad1cca2a471
parentf1c4219fa92119ab1b909f5a9d6c0bab4cce314a (diff)
more changes to reduce unnecessary midi messages. Also, don't throw an exception on port write overflow.
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2441 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/surfaces/mackie/mackie_control_protocol.cc15
-rw-r--r--libs/surfaces/mackie/mackie_control_protocol.h3
-rw-r--r--libs/surfaces/mackie/route_signal.h10
-rw-r--r--libs/surfaces/mackie/surface_port.cc8
4 files changed, 26 insertions, 10 deletions
diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc
index 46986bbc1e..6cd5a96761 100644
--- a/libs/surfaces/mackie/mackie_control_protocol.cc
+++ b/libs/surfaces/mackie/mackie_control_protocol.cc
@@ -1017,11 +1017,15 @@ void MackieControlProtocol::notify_panner_changed( RouteSignal * route_signal )
float pos;
route_signal->route().panner()[0]->get_effective_position( pos );
+ // cache the MidiByteArray here, because the mackie led control is much lower
+ // resolution than the panner control. So we save lots of byte
+ // sends in spite of more work on the comparison
+ MidiByteArray bytes = builder.build_led_ring( pot, ControlState( on, pos ), MackieMidiBuilder::midi_pot_mode_dot );
// check that something has actually changed
- if ( pos != route_signal->last_pan_written() )
+ if ( bytes != route_signal->last_pan_written() )
{
- route_signal->port().write( builder.build_led_ring( pot, ControlState( on, pos ), MackieMidiBuilder::midi_pot_mode_dot ) );
- route_signal->last_pan_written( pos );
+ route_signal->port().write( bytes );
+ route_signal->last_pan_written( bytes );
}
}
else
@@ -1049,11 +1053,12 @@ void MackieControlProtocol::update_automation( RouteSignal & rs )
{
notify_panner_changed( &rs );
}
+ _automation_last.start();
}
void MackieControlProtocol::poll_automation()
{
- if ( _active )
+ if ( _active && _automation_last.elapsed() >= 20 )
{
// do all currently mapped routes
for( RouteSignals::iterator it = route_signals.begin(); it != route_signals.end(); ++it )
@@ -1063,6 +1068,8 @@ void MackieControlProtocol::poll_automation()
// and the master strip
if ( master_route_signal != 0 ) update_automation( *master_route_signal );
+
+ _automation_last.start();
}
}
diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h
index 112b5c3f0f..d3ebc77676 100644
--- a/libs/surfaces/mackie/mackie_control_protocol.h
+++ b/libs/surfaces/mackie/mackie_control_protocol.h
@@ -330,6 +330,9 @@ class MackieControlProtocol
Mackie::Timer _frm_left_last;
Mackie::JogWheel _jog_wheel;
+
+ // Timer for controlling midi bandwidth used by automation polls
+ Mackie::Timer _automation_last;
};
#endif // ardour_mackie_control_protocol_h
diff --git a/libs/surfaces/mackie/route_signal.h b/libs/surfaces/mackie/route_signal.h
index 7f8a9f6875..6d79938ab0 100644
--- a/libs/surfaces/mackie/route_signal.h
+++ b/libs/surfaces/mackie/route_signal.h
@@ -22,6 +22,8 @@
#include <vector>
+#include "midi_byte_array.h"
+
class MackieControlProtocol;
namespace ARDOUR {
@@ -44,7 +46,7 @@ class RouteSignal
{
public:
RouteSignal( ARDOUR::Route & route, MackieControlProtocol & mcp, Strip & strip, MackiePort & port )
- : _route( route ), _mcp( mcp ), _strip( strip ), _port( port ), _last_gain_written(0.0), _last_pan_written(0.0)
+ : _route( route ), _mcp( mcp ), _strip( strip ), _port( port ), _last_gain_written(0.0)
{
connect();
}
@@ -67,8 +69,8 @@ public:
float last_gain_written() const { return _last_gain_written; }
void last_gain_written( float other ) { _last_gain_written = other; }
- float last_pan_written() const { return _last_pan_written; }
- void last_pan_written( float other ) { _last_pan_written = other; }
+ const MidiByteArray & last_pan_written() const { return _last_pan_written; }
+ void last_pan_written( const MidiByteArray & other ) { _last_pan_written = other; }
private:
ARDOUR::Route & _route;
@@ -82,7 +84,7 @@ private:
// Last written values for the gain and pan, to avoid overloading
// the midi connection to the surface
float _last_gain_written;
- float _last_pan_written;
+ MidiByteArray _last_pan_written;
};
}
diff --git a/libs/surfaces/mackie/surface_port.cc b/libs/surfaces/mackie/surface_port.cc
index bba9ab2402..448fbb40c8 100644
--- a/libs/surfaces/mackie/surface_port.cc
+++ b/libs/surfaces/mackie/surface_port.cc
@@ -132,11 +132,15 @@ void SurfacePort::write( const MidiByteArray & mba )
int count = port().write( mba.bytes().get(), mba.size() );
if ( count != (int)mba.size() )
{
- if ( errno != EAGAIN )
+ if ( errno == 0 )
+ {
+ cout << "port overflow on " << port().name() << ". Did not write all of " << mba << endl;
+ }
+ else if ( errno != EAGAIN )
{
ostringstream os;
os << "Surface: couldn't write to port " << port().name();
- os << ": " << errno << fetch_errmsg( errno );
+ os << ", error: " << fetch_errmsg( errno ) << "(" << errno << ")";
cout << os.str();
inactive_event();