From 9cdeaa30b9bcbe77dc7730ce82b1c95faee45bc3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 7 Apr 2012 16:04:13 +0000 Subject: [PATCH] MCP: try to fix madness with extender strip indices git-svn-id: svn://localhost/ardour2/branches/3.0@11819 d708f5d6-7413-0410-9779-e7cbd77b26cf --- .../mackie/mackie_control_protocol.cc | 5 --- libs/surfaces/mackie/mackie_midi_builder.cc | 31 +++++++++++-------- libs/surfaces/mackie/surface.cc | 21 ++++++------- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index bf252411fb..c84327f5a7 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -185,15 +185,10 @@ MackiePort& MackieControlProtocol::port_for_id (uint32_t index) { uint32_t current_max = 0; - - cerr << "Looking for port for index " << index << endl; - for (MackiePorts::iterator it = _ports.begin(); it != _ports.end(); ++it) { - cerr << "\tport " << (*it)->input_port().name() << '/' << (*it)->output_port().name() << " has " << (*it)->strips() << endl; current_max += (*it)->strips(); if (index < current_max) { - cerr << "\t\tUSE IT\n"; return **it; } } diff --git a/libs/surfaces/mackie/mackie_midi_builder.cc b/libs/surfaces/mackie/mackie_midi_builder.cc index 293bbebc09..7cafbd2ebb 100644 --- a/libs/surfaces/mackie/mackie_midi_builder.cc +++ b/libs/surfaces/mackie/mackie_midi_builder.cc @@ -22,10 +22,14 @@ #include #include +#include "pbd/compose.h" + +#include "ardour/debug.h" #include "controls.h" #include "midi_byte_array.h" #include "mackie_port.h" +using namespace PBD; using namespace Mackie; using namespace std; @@ -191,39 +195,40 @@ MidiByteArray MackieMidiBuilder::strip_display_blank( SurfacePort & port, const return strip_display( port, strip, line_number, " " ); } -MidiByteArray MackieMidiBuilder::strip_display( SurfacePort & port, const Strip & strip, unsigned int line_number, const std::string & line ) +MidiByteArray MackieMidiBuilder::strip_display (SurfacePort & port, const Strip & strip, unsigned int line_number, const std::string & line ) { assert (line_number <= 1); - assert (strip.index() < 8); - -#ifdef NUCLEUS_DEBUG - cout << "MackieMidiBuilder::strip_display index: " << strip.index() << ", line " << line_number << ": " << line << endl; -#endif MidiByteArray retval; - + uint32_t index = strip.index() % port.strips(); + + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("MackieMidiBuilder::strip_display index: %1, line %2 = %3\n", strip.index(), line_number, line)); + // sysex header retval << port.sysex_hdr(); // code for display retval << 0x12; // offset (0 to 0x37 first line, 0x38 to 0x6f for second line ) - retval << ( strip.index() * 7 + ( line_number * 0x38 ) ); + retval << (index * 7 + (line_number * 0x38)); // ascii data to display retval << line; // pad with " " out to 6 chars - for ( int i = line.length(); i < 6; ++i ) retval << ' '; + for (int i = line.length(); i < 6; ++i) { + retval << ' '; + } // column spacer, unless it's the right-hand column - if ( strip.index() < 7 ) retval << ' '; + if (strip.index() < 7) { + retval << ' '; + } // sysex trailer retval << MIDI::eox; -#ifdef NUCLEUS_DEBUG - cout << "MackieMidiBuilder::strip_display midi: " << retval << endl; -#endif + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("MackieMidiBuilder::strip_display midi: %1\n", retval)); + return retval; } diff --git a/libs/surfaces/mackie/surface.cc b/libs/surfaces/mackie/surface.cc index 5b79cac4a6..e9e7723776 100644 --- a/libs/surfaces/mackie/surface.cc +++ b/libs/surfaces/mackie/surface.cc @@ -1,3 +1,4 @@ +#include "ardour/debug.h" #include "surface.h" #include @@ -5,6 +6,7 @@ #include using namespace std; +using namespace PBD; using namespace Mackie; Surface::Surface( uint32_t max_strips, uint32_t unit_strips ) @@ -14,14 +16,10 @@ Surface::Surface( uint32_t max_strips, uint32_t unit_strips ) void Surface::init() { -#ifdef DEBUG - cout << "Surface::init" << endl; -#endif + DEBUG_TRACE (DEBUG::MackieControl, "Surface::init\n"); init_controls(); init_strips( _max_strips, _unit_strips ); -#ifdef DEBUG - cout << "Surface::init finish" << endl; -#endif + DEBUG_TRACE (DEBUG::MackieControl, "Surface::init finish\n"); } Surface::~Surface() @@ -42,12 +40,13 @@ Surface::~Surface() // Mackie-specific, because of multiple devices on separate ports // add the strips from 9..max_strips // unit_strips is the number of strips for additional units. -void Surface::init_strips( uint32_t max_strips, uint32_t unit_strips ) +void Surface::init_strips (uint32_t max_strips, uint32_t unit_strips) { - if ( strips.size() < max_strips ) - { + if ( strips.size() < max_strips ) { + uint32_t const old_size = strips.size(); strips.resize (max_strips); + for (uint32_t i = old_size; i < max_strips; ++i) { // because I can't find itoa ostringstream os; @@ -62,8 +61,8 @@ void Surface::init_strips( uint32_t max_strips, uint32_t unit_strips ) Strip * strip = new Strip( *strips[i % unit_strips] ); // update the relevant values - strip->index( i ); - strip->name( name ); + strip->index (i); + strip->name (name); // add to data structures groups[name] = strip;