X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fmackie%2Ffader.cc;h=33e1e4c29faf34d8df107f56b57073c6c0d4da79;hb=b5dbfc9931bc586fb2b5a50a2493e8c158c99896;hp=9a44f8ef9bbe0607d6b81b68868dd5bd7b7a6e95;hpb=9b6c41c13435755ec092a1d2630bdaa156b85081;p=ardour.git diff --git a/libs/surfaces/mackie/fader.cc b/libs/surfaces/mackie/fader.cc index 9a44f8ef9b..33e1e4c29f 100644 --- a/libs/surfaces/mackie/fader.cc +++ b/libs/surfaces/mackie/fader.cc @@ -17,11 +17,20 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include + +#include "pbd/compose.h" + +#include "ardour/debug.h" + #include "fader.h" #include "surface.h" #include "control_group.h" +#include "mackie_control_protocol.h" +using namespace ArdourSurface; using namespace Mackie; +using namespace PBD; Control* Fader::factory (Surface& surface, int id, const char* name, Group& group) @@ -44,6 +53,20 @@ Fader::set_position (float normalized) MidiByteArray Fader::update_message () { - int posi = int (0x3fff * position); - return MidiByteArray (3, 0xe0 | raw_id(), posi & 0x7f, posi >> 7); + MackieControlProtocol* mcp = MackieControlProtocol::instance (); + if (mcp && mcp->flip_mode() == MackieControlProtocol::Zero) { + /* do not send messages to move the faders when in this mode */ + return MidiByteArray(); + } + + int posi = lrintf (16384.0 * position); + + if (posi == last_update_position) { + return MidiByteArray(); + } + + last_update_position = posi; + + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("generate fader message for position %1 (%2)\n", position, posi)); + return MidiByteArray (3, 0xe0 + id(), posi & 0x7f, posi >> 7); }