2013-01-16 13:22:15 -05:00
|
|
|
/*
|
2019-08-03 08:34:29 -04:00
|
|
|
* Copyright (C) 2006-2007 John Anderson
|
|
|
|
* Copyright (C) 2008-2016 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2008 Doug McLain <doug@nostar.net>
|
|
|
|
* Copyright (C) 2010-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2015-2016 Len Ovens <len@ovenwerks.net>
|
|
|
|
* Copyright (C) 2015-2016 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2016-2018 Ben Loftis <ben@harrisonconsoles.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2013-01-16 13:22:15 -05:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
#include <sstream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <iostream>
|
2012-04-08 17:17:11 -04:00
|
|
|
#include <cstdio>
|
2012-04-10 10:27:44 -04:00
|
|
|
#include <cmath>
|
|
|
|
|
2015-10-08 12:49:58 -04:00
|
|
|
#include <glibmm/convert.h>
|
|
|
|
|
2015-12-14 22:22:34 -05:00
|
|
|
#include "pbd/stacktrace.h"
|
|
|
|
|
2012-04-10 10:27:44 -04:00
|
|
|
#include "midi++/port.h"
|
2012-04-08 17:17:11 -04:00
|
|
|
|
2015-10-07 13:17:42 -04:00
|
|
|
#include "ardour/audioengine.h"
|
2012-04-14 16:38:42 -04:00
|
|
|
#include "ardour/automation_control.h"
|
2012-04-08 17:17:11 -04:00
|
|
|
#include "ardour/debug.h"
|
2012-04-10 10:27:44 -04:00
|
|
|
#include "ardour/route.h"
|
|
|
|
#include "ardour/panner.h"
|
|
|
|
#include "ardour/panner_shell.h"
|
2015-12-10 09:17:05 -05:00
|
|
|
#include "ardour/profile.h"
|
2012-04-10 10:27:44 -04:00
|
|
|
#include "ardour/rc_configuration.h"
|
2012-04-14 16:38:42 -04:00
|
|
|
#include "ardour/session.h"
|
2012-04-18 09:13:42 -04:00
|
|
|
#include "ardour/utils.h"
|
2012-04-08 17:17:11 -04:00
|
|
|
|
2015-10-10 17:13:04 -04:00
|
|
|
#include <gtkmm2ext/gui_thread.h>
|
|
|
|
|
2012-04-09 09:59:35 -04:00
|
|
|
#include "control_group.h"
|
2012-04-08 17:17:11 -04:00
|
|
|
#include "surface_port.h"
|
|
|
|
#include "surface.h"
|
2012-04-09 09:59:35 -04:00
|
|
|
#include "strip.h"
|
2012-04-10 10:27:44 -04:00
|
|
|
#include "mackie_control_protocol.h"
|
2012-04-22 13:37:52 -04:00
|
|
|
#include "jog_wheel.h"
|
2012-04-09 09:59:35 -04:00
|
|
|
|
|
|
|
#include "strip.h"
|
|
|
|
#include "button.h"
|
|
|
|
#include "led.h"
|
|
|
|
#include "pot.h"
|
|
|
|
#include "fader.h"
|
|
|
|
#include "jog.h"
|
|
|
|
#include "meter.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2012-04-10 10:27:44 -04:00
|
|
|
|
2015-10-03 05:20:15 -04:00
|
|
|
#ifdef PLATFORM_WINDOWS
|
|
|
|
#define random() rand()
|
|
|
|
#endif
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
using namespace std;
|
2012-04-07 12:04:13 -04:00
|
|
|
using namespace PBD;
|
2016-05-16 16:45:37 -04:00
|
|
|
using ARDOUR::Stripable;
|
2012-04-10 10:27:44 -04:00
|
|
|
using ARDOUR::Panner;
|
2015-12-10 09:17:05 -05:00
|
|
|
using ARDOUR::Profile;
|
2012-04-14 16:38:42 -04:00
|
|
|
using ARDOUR::AutomationControl;
|
2015-04-15 20:37:20 -04:00
|
|
|
using namespace ArdourSurface;
|
|
|
|
using namespace Mackie;
|
2012-04-14 16:38:42 -04:00
|
|
|
|
|
|
|
#define ui_context() MackieControlProtocol::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
// The MCU sysex header.4th byte Will be overwritten
|
|
|
|
// when we get an incoming sysex that identifies
|
|
|
|
// the device type
|
|
|
|
static MidiByteArray mackie_sysex_hdr (5, MIDI::sysex, 0x0, 0x0, 0x66, 0x14);
|
2012-04-10 10:27:44 -04:00
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
// The MCU extender sysex header.4th byte Will be overwritten
|
|
|
|
// when we get an incoming sysex that identifies
|
|
|
|
// the device type
|
|
|
|
static MidiByteArray mackie_sysex_hdr_xt (5, MIDI::sysex, 0x0, 0x0, 0x66, 0x15);
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2018-02-01 15:39:17 -05:00
|
|
|
//QCON
|
|
|
|
// The MCU sysex header for QCon Control surface
|
|
|
|
static MidiByteArray mackie_sysex_hdr_qcon (5, MIDI::sysex, 0x0, 0x0, 0x66, 0x14);
|
|
|
|
|
|
|
|
// The MCU sysex header for QCon Control - extender
|
|
|
|
// The extender differs from Mackie by 4th bit - it's same like for main control surface (for display)
|
|
|
|
static MidiByteArray mackie_sysex_hdr_xt_qcon (5, MIDI::sysex, 0x0, 0x0, 0x66, 0x14);
|
|
|
|
|
|
|
|
|
2012-04-10 10:27:44 -04:00
|
|
|
static MidiByteArray empty_midi_byte_array;
|
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
Surface::Surface (MackieControlProtocol& mcp, const std::string& device_name, uint32_t number, surface_type_t stype)
|
2012-04-10 10:27:44 -04:00
|
|
|
: _mcp (mcp)
|
|
|
|
, _stype (stype)
|
|
|
|
, _number (number)
|
2012-04-12 12:41:07 -04:00
|
|
|
, _name (device_name)
|
2012-04-21 22:15:24 -04:00
|
|
|
, _active (false)
|
2012-04-10 10:27:44 -04:00
|
|
|
, _connected (false)
|
|
|
|
, _jog_wheel (0)
|
2012-06-14 07:32:12 -04:00
|
|
|
, _master_fader (0)
|
2012-06-09 15:06:52 -04:00
|
|
|
, _last_master_gain_written (-0.0f)
|
2015-10-07 13:17:42 -04:00
|
|
|
, connection_state (0)
|
2018-02-03 09:58:45 -05:00
|
|
|
, is_qcon (false)
|
2018-02-10 18:59:37 -05:00
|
|
|
, input_source (0)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2012-06-12 23:07:50 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Surface::Surface init\n");
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2013-09-06 10:39:14 -04:00
|
|
|
try {
|
|
|
|
_port = new SurfacePort (*this);
|
|
|
|
} catch (...) {
|
|
|
|
throw failed_constructor ();
|
|
|
|
}
|
2012-04-07 15:30:00 -04:00
|
|
|
|
2018-02-02 10:26:17 -05:00
|
|
|
//Store Qcon flag
|
|
|
|
if( mcp.device_info().is_qcon() ) {
|
|
|
|
is_qcon = true;
|
|
|
|
} else {
|
|
|
|
is_qcon = false;
|
|
|
|
}
|
|
|
|
|
2012-04-14 15:02:54 -04:00
|
|
|
/* only the first Surface object has global controls */
|
2015-06-04 18:07:43 -04:00
|
|
|
/* lets use master_position instead */
|
|
|
|
uint32_t mp = _mcp.device_info().master_position();
|
|
|
|
if (_number == mp) {
|
2015-08-06 01:02:27 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Surface matches MasterPosition. Might have global controls.\n");
|
2012-04-14 15:02:54 -04:00
|
|
|
if (_mcp.device_info().has_global_controls()) {
|
|
|
|
init_controls ();
|
2012-06-06 08:20:57 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "init_controls done\n");
|
2012-04-14 15:02:54 -04:00
|
|
|
}
|
2012-04-14 16:38:42 -04:00
|
|
|
|
|
|
|
if (_mcp.device_info().has_master_fader()) {
|
|
|
|
setup_master ();
|
2012-06-06 08:20:57 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "setup_master done\n");
|
2012-04-14 16:38:42 -04:00
|
|
|
}
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
|
2012-04-12 13:52:57 -04:00
|
|
|
uint32_t n = _mcp.device_info().strip_cnt();
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-12 13:52:57 -04:00
|
|
|
if (n) {
|
|
|
|
init_strips (n);
|
2012-06-06 08:20:57 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "init_strips done\n");
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-10-09 14:01:22 -04:00
|
|
|
if (_mcp.device_info().uses_ipmidi()) {
|
2015-10-08 15:28:37 -04:00
|
|
|
/* ipMIDI port already exists, we can just assume that we're
|
|
|
|
* connected.
|
|
|
|
*
|
|
|
|
* If the user still hasn't connected the ipMIDI surface and/or
|
|
|
|
* turned it on, then they have to press "Discover Mackie
|
|
|
|
* Devices" in the GUI at the right time.
|
|
|
|
*/
|
|
|
|
|
|
|
|
connection_state |= (InputConnected|OutputConnected);
|
|
|
|
connected ();
|
|
|
|
}
|
2015-10-07 13:17:42 -04:00
|
|
|
|
2012-04-10 10:46:51 -04:00
|
|
|
connect_to_signals ();
|
|
|
|
|
2012-06-12 23:07:50 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Surface::Surface done\n");
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2012-04-08 10:11:00 -04:00
|
|
|
Surface::~Surface ()
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2012-06-12 23:07:50 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Surface::~Surface init\n");
|
2012-04-10 10:27:44 -04:00
|
|
|
|
2015-10-09 11:12:28 -04:00
|
|
|
if (input_source) {
|
|
|
|
g_source_destroy (input_source);
|
|
|
|
input_source = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// delete groups (strips)
|
2012-04-08 10:11:00 -04:00
|
|
|
for (Groups::iterator it = groups.begin(); it != groups.end(); ++it) {
|
2008-06-02 17:41:35 -04:00
|
|
|
delete it->second;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-10-09 11:12:28 -04:00
|
|
|
// delete controls (global buttons, master fader etc)
|
2012-04-08 10:11:00 -04:00
|
|
|
for (Controls::iterator it = controls.begin(); it != controls.end(); ++it) {
|
2008-06-02 17:41:35 -04:00
|
|
|
delete *it;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-10 10:27:44 -04:00
|
|
|
delete _jog_wheel;
|
2012-04-23 22:28:51 -04:00
|
|
|
delete _port;
|
2015-10-14 01:19:36 -04:00
|
|
|
// the ports take time to release and we may be rebuilding right away
|
|
|
|
// in the case of changing devices.
|
2015-10-14 08:55:10 -04:00
|
|
|
g_usleep (10000);
|
2012-06-12 23:07:50 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Surface::~Surface done\n");
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
|
2015-10-09 14:01:22 -04:00
|
|
|
bool
|
2015-10-07 13:17:42 -04:00
|
|
|
Surface::connection_handler (boost::weak_ptr<ARDOUR::Port>, std::string name1, boost::weak_ptr<ARDOUR::Port>, std::string name2, bool yn)
|
|
|
|
{
|
2015-10-08 15:28:21 -04:00
|
|
|
if (!_port) {
|
2015-10-09 14:01:22 -04:00
|
|
|
return false;
|
2015-10-08 15:28:21 -04:00
|
|
|
}
|
|
|
|
|
2015-10-07 13:17:42 -04:00
|
|
|
string ni = ARDOUR::AudioEngine::instance()->make_port_name_non_relative (_port->input_name());
|
|
|
|
string no = ARDOUR::AudioEngine::instance()->make_port_name_non_relative (_port->output_name());
|
|
|
|
|
|
|
|
if (ni == name1 || ni == name2) {
|
|
|
|
if (yn) {
|
|
|
|
connection_state |= InputConnected;
|
|
|
|
} else {
|
|
|
|
connection_state &= ~InputConnected;
|
|
|
|
}
|
|
|
|
} else if (no == name1 || no == name2) {
|
|
|
|
if (yn) {
|
|
|
|
connection_state |= OutputConnected;
|
|
|
|
} else {
|
|
|
|
connection_state &= ~OutputConnected;
|
|
|
|
}
|
2015-10-09 14:01:22 -04:00
|
|
|
} else {
|
|
|
|
/* not our ports */
|
|
|
|
return false;
|
2015-10-07 13:17:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((connection_state & (InputConnected|OutputConnected)) == (InputConnected|OutputConnected)) {
|
|
|
|
|
|
|
|
/* this will send a device query message, which should
|
|
|
|
result in a response that will kick off device type
|
|
|
|
discovery and activation of the surface(s).
|
|
|
|
|
|
|
|
The intended order of events is:
|
|
|
|
|
|
|
|
- each surface sends a device query message
|
|
|
|
- devices respond with either MCP or LCP response (sysex in both
|
|
|
|
cases)
|
|
|
|
- sysex message causes Surface::turn_it_on() which tells the
|
|
|
|
MCP object that the surface is ready, and sets up strip
|
|
|
|
displays and binds faders and buttons for that surface
|
|
|
|
|
|
|
|
In the case of LCP, where this is a handshake process that could
|
|
|
|
fail, the response process to the initial sysex after a device query
|
|
|
|
will mark the surface inactive, which won't shut anything down
|
|
|
|
but will stop any writes to the device.
|
|
|
|
|
|
|
|
Note: there are no known cases of the handshake process failing.
|
|
|
|
|
|
|
|
We actually can't initiate this in this callback, so we have
|
|
|
|
to queue it with the MCP event loop.
|
|
|
|
*/
|
|
|
|
|
2015-10-10 17:13:04 -04:00
|
|
|
/* XXX this is a horrible hack. Without a short sleep here,
|
|
|
|
something prevents the device wakeup messages from being
|
|
|
|
sent and/or the responses from being received.
|
|
|
|
*/
|
|
|
|
|
|
|
|
g_usleep (100000);
|
2015-10-07 13:17:42 -04:00
|
|
|
connected ();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface %1 disconnected (input or output or both)\n", _name));
|
|
|
|
_active = false;
|
|
|
|
}
|
2015-10-09 14:01:22 -04:00
|
|
|
|
|
|
|
return true; /* connection status changed */
|
2015-10-07 13:17:42 -04:00
|
|
|
}
|
|
|
|
|
2013-12-13 16:00:08 -05:00
|
|
|
XMLNode&
|
|
|
|
Surface::get_state()
|
|
|
|
{
|
2015-10-11 11:58:00 -04:00
|
|
|
XMLNode* node = new XMLNode (X_("Surface"));
|
2016-08-29 21:51:18 -04:00
|
|
|
node->set_property (X_("name"), _name);
|
2013-12-13 16:00:08 -05:00
|
|
|
node->add_child_nocopy (_port->get_state());
|
|
|
|
return *node;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
Surface::set_state (const XMLNode& node, int version)
|
|
|
|
{
|
2015-10-12 13:36:22 -04:00
|
|
|
/* Look for a node named after the device we're part of */
|
2015-10-11 11:58:00 -04:00
|
|
|
|
|
|
|
XMLNodeList const& children = node.children();
|
|
|
|
XMLNode* mynode = 0;
|
|
|
|
|
|
|
|
for (XMLNodeList::const_iterator c = children.begin(); c != children.end(); ++c) {
|
2016-08-29 21:51:18 -04:00
|
|
|
std::string name;
|
|
|
|
if ((*c)->get_property (X_("name"), name) && name == _name) {
|
|
|
|
mynode = *c;
|
|
|
|
break;
|
2015-10-11 11:58:00 -04:00
|
|
|
}
|
|
|
|
}
|
2013-12-13 16:00:08 -05:00
|
|
|
|
|
|
|
if (!mynode) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-13 07:33:20 -04:00
|
|
|
XMLNode* portnode = mynode->child (X_("Port"));
|
|
|
|
if (portnode) {
|
|
|
|
if (_port->set_state (*portnode, version)) {
|
|
|
|
return -1;
|
2013-12-13 16:00:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
const MidiByteArray&
|
2012-04-10 10:27:44 -04:00
|
|
|
Surface::sysex_hdr() const
|
|
|
|
{
|
|
|
|
switch (_stype) {
|
2018-02-01 15:39:17 -05:00
|
|
|
case mcu:
|
|
|
|
if (_mcp.device_info().is_qcon()) {
|
|
|
|
return mackie_sysex_hdr_qcon;
|
|
|
|
} else {
|
|
|
|
return mackie_sysex_hdr;
|
|
|
|
}
|
|
|
|
case ext:
|
|
|
|
if(_mcp.device_info().is_qcon()) {
|
|
|
|
return mackie_sysex_hdr_xt_qcon;
|
|
|
|
} else {
|
|
|
|
return mackie_sysex_hdr_xt;
|
|
|
|
}
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
cout << "SurfacePort::sysex_hdr _port_type not known" << endl;
|
|
|
|
return mackie_sysex_hdr;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2012-04-14 15:02:54 -04:00
|
|
|
static GlobalControlDefinition mackie_global_controls[] = {
|
|
|
|
{ "external", Pot::External, Pot::factory, "none" },
|
|
|
|
{ "fader_touch", Led::FaderTouch, Led::factory, "master" },
|
|
|
|
{ "timecode", Led::Timecode, Led::factory, "none" },
|
|
|
|
{ "beats", Led::Beats, Led::factory, "none" },
|
|
|
|
{ "solo", Led::RudeSolo, Led::factory, "none" },
|
|
|
|
{ "relay_click", Led::RelayClick, Led::factory, "none" },
|
|
|
|
{ "", 0, Led::factory, "" }
|
|
|
|
};
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void
|
2012-04-08 17:17:11 -04:00
|
|
|
Surface::init_controls()
|
|
|
|
{
|
|
|
|
Group* group;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-06-06 08:20:57 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Surface::init_controls: creating groups\n");
|
2012-04-08 17:17:11 -04:00
|
|
|
groups["assignment"] = new Group ("assignment");
|
|
|
|
groups["automation"] = new Group ("automation");
|
|
|
|
groups["bank"] = new Group ("bank");
|
|
|
|
groups["cursor"] = new Group ("cursor");
|
|
|
|
groups["display"] = new Group ("display");
|
2012-06-06 08:20:57 -04:00
|
|
|
groups["function select"] = new Group ("function select");
|
|
|
|
groups["global view"] = new Group ("global view");
|
|
|
|
groups["master"] = new Group ("master");
|
2012-04-08 17:17:11 -04:00
|
|
|
groups["modifiers"] = new Group ("modifiers");
|
|
|
|
groups["none"] = new Group ("none");
|
|
|
|
groups["transport"] = new Group ("transport");
|
|
|
|
groups["user"] = new Group ("user");
|
2012-06-06 08:20:57 -04:00
|
|
|
groups["utilities"] = new Group ("utilities");
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-06-06 08:20:57 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Surface::init_controls: creating jog wheel\n");
|
2012-04-14 15:02:54 -04:00
|
|
|
if (_mcp.device_info().has_jog_wheel()) {
|
|
|
|
_jog_wheel = new Mackie::JogWheel (_mcp);
|
|
|
|
}
|
2012-04-08 17:17:11 -04:00
|
|
|
|
2012-06-06 08:20:57 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Surface::init_controls: creating global controls\n");
|
2012-04-08 17:17:11 -04:00
|
|
|
for (uint32_t n = 0; mackie_global_controls[n].name[0]; ++n) {
|
|
|
|
group = groups[mackie_global_controls[n].group_name];
|
2012-04-10 10:27:44 -04:00
|
|
|
Control* control = mackie_global_controls[n].factory (*this, mackie_global_controls[n].id, mackie_global_controls[n].name, *group);
|
2012-04-14 15:02:54 -04:00
|
|
|
controls_by_device_independent_id[mackie_global_controls[n].id] = control;
|
2012-04-08 17:17:11 -04:00
|
|
|
}
|
|
|
|
|
2012-04-14 15:02:54 -04:00
|
|
|
/* add global buttons */
|
2012-06-06 08:20:57 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Surface::init_controls: adding global buttons\n");
|
2012-04-14 15:02:54 -04:00
|
|
|
const map<Button::ID,GlobalButtonInfo>& global_buttons (_mcp.device_info().global_buttons());
|
|
|
|
|
|
|
|
for (map<Button::ID,GlobalButtonInfo>::const_iterator b = global_buttons.begin(); b != global_buttons.end(); ++b){
|
|
|
|
group = groups[b->second.group];
|
|
|
|
controls_by_device_independent_id[b->first] = Button::factory (*this, b->first, b->second.id, b->second.label, *group);
|
|
|
|
}
|
|
|
|
}
|
2012-04-08 17:17:11 -04:00
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void
|
2012-04-12 13:52:57 -04:00
|
|
|
Surface::init_strips (uint32_t n)
|
2012-04-08 17:17:11 -04:00
|
|
|
{
|
2012-04-14 15:02:54 -04:00
|
|
|
const map<Button::ID,StripButtonInfo>& strip_buttons (_mcp.device_info().strip_buttons());
|
|
|
|
|
2012-04-12 13:52:57 -04:00
|
|
|
for (uint32_t i = 0; i < n; ++i) {
|
2012-04-08 17:17:11 -04:00
|
|
|
|
|
|
|
char name[32];
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-10 10:27:44 -04:00
|
|
|
snprintf (name, sizeof (name), "strip_%d", (8* _number) + i);
|
2012-04-09 13:48:16 -04:00
|
|
|
|
2012-04-14 15:02:54 -04:00
|
|
|
Strip* strip = new Strip (*this, name, i, strip_buttons);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-08 17:17:11 -04:00
|
|
|
groups[name] = strip;
|
2012-04-12 13:52:57 -04:00
|
|
|
strips.push_back (strip);
|
2012-04-08 17:17:11 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-13 08:33:02 -05:00
|
|
|
void
|
|
|
|
Surface::master_monitor_may_have_changed ()
|
|
|
|
{
|
2016-01-18 11:58:07 -05:00
|
|
|
if (_number == _mcp.device_info().master_position()) {
|
|
|
|
setup_master ();
|
|
|
|
}
|
2015-12-13 08:33:02 -05:00
|
|
|
}
|
|
|
|
|
2012-04-14 16:38:42 -04:00
|
|
|
void
|
|
|
|
Surface::setup_master ()
|
|
|
|
{
|
2016-05-16 16:45:37 -04:00
|
|
|
boost::shared_ptr<Stripable> m;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-14 16:38:42 -04:00
|
|
|
if ((m = _mcp.get_session().monitor_out()) == 0) {
|
|
|
|
m = _mcp.get_session().master_out();
|
2015-10-04 14:51:05 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-14 16:38:42 -04:00
|
|
|
if (!m) {
|
2016-02-20 14:24:03 -05:00
|
|
|
if (_master_fader) {
|
|
|
|
_master_fader->set_control (boost::shared_ptr<AutomationControl>());
|
|
|
|
}
|
2015-12-13 08:33:02 -05:00
|
|
|
master_connection.disconnect ();
|
2012-04-14 16:38:42 -04:00
|
|
|
return;
|
|
|
|
}
|
2012-06-12 23:07:50 -04:00
|
|
|
|
2015-12-13 08:33:02 -05:00
|
|
|
if (!_master_fader) {
|
|
|
|
Groups::iterator group_it;
|
2016-02-06 14:24:06 -05:00
|
|
|
Group* master_group;
|
2015-12-13 08:33:02 -05:00
|
|
|
group_it = groups.find("master");
|
|
|
|
|
2016-02-05 17:59:29 -05:00
|
|
|
if (group_it == groups.end()) {
|
2016-02-06 14:24:06 -05:00
|
|
|
groups["master"] = master_group = new Group ("master");
|
|
|
|
} else {
|
|
|
|
master_group = group_it->second;
|
2016-02-05 17:59:29 -05:00
|
|
|
}
|
|
|
|
|
2016-02-06 14:24:06 -05:00
|
|
|
_master_fader = dynamic_cast<Fader*> (Fader::factory (*this, _mcp.device_info().strip_cnt(), "master", *master_group));
|
2016-02-05 17:59:29 -05:00
|
|
|
|
2015-12-13 08:33:02 -05:00
|
|
|
DeviceInfo device_info = _mcp.device_info();
|
|
|
|
GlobalButtonInfo master_button = device_info.get_global_button(Button::MasterFaderTouch);
|
|
|
|
Button* bb = dynamic_cast<Button*> (Button::factory (
|
|
|
|
*this,
|
|
|
|
Button::MasterFaderTouch,
|
|
|
|
master_button.id,
|
|
|
|
master_button.label,
|
|
|
|
*(group_it->second)
|
|
|
|
));
|
|
|
|
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("surface %1 Master Fader new button BID %2 id %3\n",
|
|
|
|
number(), Button::MasterFaderTouch, bb->id()));
|
|
|
|
} else {
|
|
|
|
master_connection.disconnect ();
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-16 15:05:27 -04:00
|
|
|
_master_fader->set_control (m->gain_control());
|
2015-12-13 08:33:02 -05:00
|
|
|
m->gain_control()->Changed.connect (master_connection, MISSING_INVALIDATOR, boost::bind (&Surface::master_gain_changed, this), ui_context());
|
|
|
|
_last_master_gain_written = FLT_MAX; /* some essentially impossible value */
|
|
|
|
master_gain_changed ();
|
2012-04-14 16:38:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Surface::master_gain_changed ()
|
|
|
|
{
|
2012-06-09 15:06:52 -04:00
|
|
|
if (!_master_fader) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-16 15:05:27 -04:00
|
|
|
boost::shared_ptr<AutomationControl> ac = _master_fader->control();
|
2012-06-09 18:36:59 -04:00
|
|
|
if (!ac) {
|
|
|
|
return;
|
|
|
|
}
|
2012-06-09 15:06:52 -04:00
|
|
|
|
|
|
|
float normalized_position = ac->internal_to_interface (ac->get_value());
|
|
|
|
if (normalized_position == _last_master_gain_written) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Surface::master_gain_changed: updating surface master fader\n");
|
|
|
|
|
|
|
|
_port->write (_master_fader->set_position (normalized_position));
|
|
|
|
_last_master_gain_written = normalized_position;
|
2012-04-14 16:38:42 -04:00
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
float
|
2012-04-11 14:51:01 -04:00
|
|
|
Surface::scaled_delta (float delta, float current_speed)
|
2012-04-10 10:27:44 -04:00
|
|
|
{
|
2012-04-11 14:51:01 -04:00
|
|
|
/* XXX needs work before use */
|
2012-04-22 13:37:52 -04:00
|
|
|
const float sign = delta < 0.0 ? -1.0 : 1.0;
|
|
|
|
|
|
|
|
return ((sign * std::pow (delta + 1.0, 2.0)) + current_speed) / 100.0;
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void
|
2012-04-10 10:27:44 -04:00
|
|
|
Surface::display_bank_start (uint32_t current_bank)
|
|
|
|
{
|
|
|
|
if (current_bank == 0) {
|
|
|
|
// send Ar. to 2-char display on the master
|
2012-04-22 13:37:52 -04:00
|
|
|
show_two_char_display ("Ar", "..");
|
2012-04-10 10:27:44 -04:00
|
|
|
} else {
|
|
|
|
// write the current first remote_id to the 2-char display
|
2012-04-22 13:37:52 -04:00
|
|
|
show_two_char_display (current_bank);
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void
|
2012-04-10 10:27:44 -04:00
|
|
|
Surface::blank_jog_ring ()
|
|
|
|
{
|
2012-04-14 15:02:54 -04:00
|
|
|
Control* control = controls_by_device_independent_id[Jog::ID];
|
2012-04-10 10:27:44 -04:00
|
|
|
|
|
|
|
if (control) {
|
2012-04-11 09:03:41 -04:00
|
|
|
Pot* pot = dynamic_cast<Pot*> (control);
|
|
|
|
if (pot) {
|
2012-04-21 22:15:24 -04:00
|
|
|
_port->write (pot->set (0.0, false, Pot::spread));
|
2012-04-11 09:03:41 -04:00
|
|
|
}
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
float
|
|
|
|
Surface::scrub_scaling_factor () const
|
|
|
|
{
|
|
|
|
return 100.0;
|
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void
|
2012-04-10 10:27:44 -04:00
|
|
|
Surface::connect_to_signals ()
|
|
|
|
{
|
|
|
|
if (!_connected) {
|
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface %1 connecting to signals on port %2\n",
|
2012-04-10 10:45:21 -04:00
|
|
|
number(), _port->input_port().name()));
|
|
|
|
|
2012-04-10 10:27:44 -04:00
|
|
|
MIDI::Parser* p = _port->input_port().parser();
|
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
/* Incoming sysex */
|
|
|
|
p->sysex.connect_same_thread (*this, boost::bind (&Surface::handle_midi_sysex, this, _1, _2, _3));
|
2012-04-10 10:27:44 -04:00
|
|
|
/* V-Pot messages are Controller */
|
|
|
|
p->controller.connect_same_thread (*this, boost::bind (&Surface::handle_midi_controller_message, this, _1, _2));
|
|
|
|
/* Button messages are NoteOn */
|
|
|
|
p->note_on.connect_same_thread (*this, boost::bind (&Surface::handle_midi_note_on_message, this, _1, _2));
|
2014-02-19 12:50:28 -05:00
|
|
|
/* Button messages are NoteOn but libmidi++ sends note-on w/velocity = 0 as note-off so catch them too */
|
2012-04-13 17:46:26 -04:00
|
|
|
p->note_off.connect_same_thread (*this, boost::bind (&Surface::handle_midi_note_on_message, this, _1, _2));
|
2012-04-10 10:27:44 -04:00
|
|
|
/* Fader messages are Pitchbend */
|
2012-06-09 15:06:52 -04:00
|
|
|
uint32_t i;
|
|
|
|
for (i = 0; i < _mcp.device_info().strip_cnt(); i++) {
|
|
|
|
p->channel_pitchbend[i].connect_same_thread (*this, boost::bind (&Surface::handle_midi_pitchbend_message, this, _1, _2, i));
|
|
|
|
}
|
|
|
|
// Master fader
|
|
|
|
p->channel_pitchbend[_mcp.device_info().strip_cnt()].connect_same_thread (*this, boost::bind (&Surface::handle_midi_pitchbend_message, this, _1, _2, _mcp.device_info().strip_cnt()));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-10 10:27:44 -04:00
|
|
|
_connected = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Surface::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb, uint32_t fader_id)
|
|
|
|
{
|
2014-02-19 12:50:28 -05:00
|
|
|
/* Pitchbend messages are fader position messages. Nothing in the data we get
|
2012-04-11 11:37:06 -04:00
|
|
|
* from the MIDI::Parser conveys the fader ID, which was given by the
|
|
|
|
* channel ID in the status byte.
|
|
|
|
*
|
2015-10-04 14:51:05 -04:00
|
|
|
* Instead, we have used bind() to supply the fader-within-strip ID
|
2012-04-11 11:37:06 -04:00
|
|
|
* when we connected to the per-channel pitchbend events.
|
|
|
|
*/
|
|
|
|
|
2015-10-02 10:22:00 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface::handle_midi_pitchbend_message on port %3, fader = %1 value = %2 (%4)\n",
|
2015-10-07 13:17:42 -04:00
|
|
|
fader_id, pb, _number, pb/16384.0));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-05-11 12:04:09 -04:00
|
|
|
if (_mcp.device_info().no_handshake()) {
|
|
|
|
turn_it_on ();
|
|
|
|
}
|
|
|
|
|
2012-04-11 11:37:06 -04:00
|
|
|
Fader* fader = faders[fader_id];
|
2012-04-10 10:27:44 -04:00
|
|
|
|
2012-04-11 09:39:25 -04:00
|
|
|
if (fader) {
|
|
|
|
Strip* strip = dynamic_cast<Strip*> (&fader->group());
|
2015-10-02 10:22:00 -04:00
|
|
|
float pos = pb / 16384.0;
|
2012-04-11 09:39:25 -04:00
|
|
|
if (strip) {
|
2012-04-14 16:38:42 -04:00
|
|
|
strip->handle_fader (*fader, pos);
|
2012-04-11 09:39:25 -04:00
|
|
|
} else {
|
2012-06-09 15:06:52 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Handling master fader\n");
|
2012-04-11 09:39:25 -04:00
|
|
|
/* master fader */
|
2012-04-16 15:05:27 -04:00
|
|
|
fader->set_value (pos); // alter master gain
|
2012-04-14 16:38:42 -04:00
|
|
|
_port->write (fader->set_position (pos)); // write back value (required for servo)
|
2012-04-11 09:39:25 -04:00
|
|
|
}
|
2012-04-10 10:27:44 -04:00
|
|
|
} else {
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "fader not found\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void
|
2012-04-10 10:27:44 -04:00
|
|
|
Surface::handle_midi_note_on_message (MIDI::Parser &, MIDI::EventTwoBytes* ev)
|
|
|
|
{
|
2012-06-09 15:06:52 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface::handle_midi_note_on_message %1 = %2\n", (int) ev->note_number, (int) ev->velocity));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-05-11 12:04:09 -04:00
|
|
|
if (_mcp.device_info().no_handshake()) {
|
|
|
|
turn_it_on ();
|
2015-10-04 14:51:05 -04:00
|
|
|
}
|
2012-05-11 12:04:09 -04:00
|
|
|
|
2015-10-03 12:03:07 -04:00
|
|
|
if (_mcp.device_info().device_type() == DeviceInfo::HUI && ev->note_number == 0 && ev->velocity == 127) {
|
|
|
|
turn_it_on ();
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2014-02-19 12:50:28 -05:00
|
|
|
/* fader touch sense is given by "buttons" 0xe..0xe7 and 0xe8 for the
|
2015-10-04 14:51:05 -04:00
|
|
|
* master.
|
2014-02-19 12:50:28 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (ev->note_number >= 0xE0 && ev->note_number <= 0xE8) {
|
|
|
|
Fader* fader = faders[ev->note_number];
|
|
|
|
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface: fader touch message, fader = %1\n", fader));
|
|
|
|
|
|
|
|
if (fader) {
|
|
|
|
|
|
|
|
Strip* strip = dynamic_cast<Strip*> (&fader->group());
|
|
|
|
|
|
|
|
if (ev->velocity > 64) {
|
|
|
|
strip->handle_fader_touch (*fader, true);
|
|
|
|
} else {
|
|
|
|
strip->handle_fader_touch (*fader, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-11 09:39:25 -04:00
|
|
|
Button* button = buttons[ev->note_number];
|
2012-04-10 10:27:44 -04:00
|
|
|
|
2012-04-11 09:39:25 -04:00
|
|
|
if (button) {
|
2015-10-07 15:12:09 -04:00
|
|
|
|
|
|
|
if (ev->velocity > 64) {
|
|
|
|
button->pressed ();
|
|
|
|
}
|
|
|
|
|
2012-04-11 09:39:25 -04:00
|
|
|
Strip* strip = dynamic_cast<Strip*> (&button->group());
|
|
|
|
|
|
|
|
if (strip) {
|
2012-04-11 12:24:52 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip %1 button %2 pressed ? %3\n",
|
2012-04-13 21:02:40 -04:00
|
|
|
strip->index(), button->name(), (ev->velocity > 64)));
|
|
|
|
strip->handle_button (*button, ev->velocity > 64 ? press : release);
|
2012-04-11 09:39:25 -04:00
|
|
|
} else {
|
|
|
|
/* global button */
|
2012-04-11 12:31:23 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("global button %1\n", button->id()));
|
2012-04-13 21:02:40 -04:00
|
|
|
_mcp.handle_button_event (*this, *button, ev->velocity > 64 ? press : release);
|
2012-04-11 09:39:25 -04:00
|
|
|
}
|
2015-10-07 15:12:09 -04:00
|
|
|
|
|
|
|
if (ev->velocity <= 64) {
|
|
|
|
button->released ();
|
|
|
|
}
|
|
|
|
|
2012-04-11 11:50:02 -04:00
|
|
|
} else {
|
2012-06-09 15:06:52 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("no button found for %1\n", (int) ev->note_number));
|
2012-04-11 11:22:05 -04:00
|
|
|
}
|
2015-10-07 15:12:09 -04:00
|
|
|
|
|
|
|
/* button release should reset timer AFTER handler(s) have run */
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void
|
2012-04-10 10:27:44 -04:00
|
|
|
Surface::handle_midi_controller_message (MIDI::Parser &, MIDI::EventTwoBytes* ev)
|
|
|
|
{
|
2012-04-11 18:32:02 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("SurfacePort::handle_midi_controller %1 = %2\n", (int) ev->controller_number, (int) ev->value));
|
2012-04-10 10:27:44 -04:00
|
|
|
|
2012-05-11 12:04:09 -04:00
|
|
|
if (_mcp.device_info().no_handshake()) {
|
|
|
|
turn_it_on ();
|
|
|
|
}
|
|
|
|
|
2012-04-11 20:28:16 -04:00
|
|
|
Pot* pot = pots[ev->controller_number];
|
2012-04-10 10:27:44 -04:00
|
|
|
|
2012-04-25 23:46:18 -04:00
|
|
|
// bit 6 gives the sign
|
2015-10-04 14:51:05 -04:00
|
|
|
float sign = (ev->value & 0x40) == 0 ? 1.0 : -1.0;
|
2012-04-25 23:46:18 -04:00
|
|
|
// bits 0..5 give the velocity. we interpret this as "ticks
|
|
|
|
// moved before this message was sent"
|
|
|
|
float ticks = (ev->value & 0x3f);
|
|
|
|
if (ticks == 0) {
|
|
|
|
/* euphonix and perhaps other devices send zero
|
|
|
|
when they mean 1, we think.
|
|
|
|
*/
|
|
|
|
ticks = 1;
|
|
|
|
}
|
2015-06-04 17:04:46 -04:00
|
|
|
|
|
|
|
float delta = 0;
|
2016-02-02 11:49:16 -05:00
|
|
|
if (mcp().main_modifier_state() == MackieControlProtocol::MODIFIER_SHIFT) {
|
2015-06-04 17:04:46 -04:00
|
|
|
delta = sign * (ticks / (float) 0xff);
|
|
|
|
} else {
|
|
|
|
delta = sign * (ticks / (float) 0x3f);
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-22 13:37:52 -04:00
|
|
|
if (!pot) {
|
|
|
|
if (ev->controller_number == Jog::ID && _jog_wheel) {
|
|
|
|
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Jog wheel moved %1\n", ticks));
|
|
|
|
_jog_wheel->jog_event (delta);
|
|
|
|
return;
|
|
|
|
}
|
2015-08-06 01:02:27 -04:00
|
|
|
// add external (pedal?) control here
|
2012-04-11 09:03:41 -04:00
|
|
|
|
2012-04-25 23:46:18 -04:00
|
|
|
return;
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
2012-04-25 23:46:18 -04:00
|
|
|
|
|
|
|
Strip* strip = dynamic_cast<Strip*> (&pot->group());
|
|
|
|
if (strip) {
|
|
|
|
strip->handle_pot (*pot, delta);
|
2015-10-04 14:51:05 -04:00
|
|
|
}
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void
|
2012-04-12 12:41:07 -04:00
|
|
|
Surface::handle_midi_sysex (MIDI::Parser &, MIDI::byte * raw_bytes, size_t count)
|
|
|
|
{
|
|
|
|
MidiByteArray bytes (count, raw_bytes);
|
|
|
|
|
2012-05-11 12:04:09 -04:00
|
|
|
if (_mcp.device_info().no_handshake()) {
|
|
|
|
turn_it_on ();
|
|
|
|
}
|
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
/* always save the device type ID so that our outgoing sysex messages
|
2015-10-04 14:51:05 -04:00
|
|
|
* are correct
|
2012-04-12 12:41:07 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
if (_stype == mcu) {
|
2018-02-01 15:39:17 -05:00
|
|
|
if (_mcp.device_info().is_qcon()) {
|
|
|
|
mackie_sysex_hdr_qcon[4] = bytes[4];
|
|
|
|
} else {
|
|
|
|
mackie_sysex_hdr[4] = bytes[4];
|
|
|
|
}
|
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
} else {
|
2018-02-01 15:39:17 -05:00
|
|
|
if (_mcp.device_info().is_qcon()) {
|
|
|
|
mackie_sysex_hdr_xt_qcon[4] = bytes[4];
|
|
|
|
} else {
|
|
|
|
mackie_sysex_hdr_xt[4] = bytes[4];
|
|
|
|
}
|
2012-04-12 12:41:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (bytes[5]) {
|
|
|
|
case 0x01:
|
2016-06-12 08:18:01 -04:00
|
|
|
if (!_active) {
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("handle_midi_sysex: %1\n", bytes));
|
|
|
|
}
|
2015-10-04 14:51:05 -04:00
|
|
|
/* MCP: Device Ready
|
|
|
|
LCP: Connection Challenge
|
2012-04-12 12:41:07 -04:00
|
|
|
*/
|
|
|
|
if (bytes[4] == 0x10 || bytes[4] == 0x11) {
|
2014-02-19 12:50:28 -05:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Logic Control Device connection challenge\n");
|
2012-04-12 12:41:07 -04:00
|
|
|
write_sysex (host_connection_query (bytes));
|
|
|
|
} else {
|
2016-06-12 08:18:01 -04:00
|
|
|
if (!_active) {
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Mackie Control Device ready, current status = %1\n", _active));
|
|
|
|
}
|
2015-10-10 17:13:04 -04:00
|
|
|
turn_it_on ();
|
2012-04-12 12:41:07 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-02-07 10:25:25 -05:00
|
|
|
case 0x06:
|
2016-06-12 08:18:01 -04:00
|
|
|
if (!_active) {
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("handle_midi_sysex: %1\n", bytes));
|
|
|
|
}
|
2016-02-07 10:25:25 -05:00
|
|
|
/* Behringer X-Touch Compact: Device Ready
|
|
|
|
*/
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Behringer X-Touch Compact ready, current status = %1\n", _active));
|
|
|
|
turn_it_on ();
|
|
|
|
break;
|
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
case 0x03: /* LCP Connection Confirmation */
|
2016-06-12 08:18:01 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("handle_midi_sysex: %1\n", bytes));
|
2014-02-19 12:50:28 -05:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Logic Control Device confirms connection, ardour replies\n");
|
2012-04-12 12:41:07 -04:00
|
|
|
if (bytes[4] == 0x10 || bytes[4] == 0x11) {
|
|
|
|
write_sysex (host_connection_confirmation (bytes));
|
2015-10-10 17:13:04 -04:00
|
|
|
turn_it_on ();
|
2012-04-12 12:41:07 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x04: /* LCP: Confirmation Denied */
|
2016-06-12 08:18:01 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("handle_midi_sysex: %1\n", bytes));
|
2014-02-19 12:50:28 -05:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "Logic Control Device denies connection\n");
|
2012-04-12 12:41:07 -04:00
|
|
|
_active = false;
|
|
|
|
break;
|
2016-02-07 10:25:48 -05:00
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
default:
|
2016-06-12 08:18:01 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("handle_midi_sysex: %1\n", bytes));
|
2016-02-07 10:25:48 -05:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("unknown device ID byte %1", (int) bytes[5]));
|
2012-04-12 12:41:07 -04:00
|
|
|
error << "MCP: unknown sysex: " << bytes << endmsg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
static MidiByteArray
|
2012-04-12 12:41:07 -04:00
|
|
|
calculate_challenge_response (MidiByteArray::iterator begin, MidiByteArray::iterator end)
|
|
|
|
{
|
|
|
|
MidiByteArray l;
|
|
|
|
back_insert_iterator<MidiByteArray> back (l);
|
|
|
|
copy (begin, end, back);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
MidiByteArray retval;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
// this is how to calculate the response to the challenge.
|
|
|
|
// from the Logic docs.
|
|
|
|
retval << (0x7f & (l[0] + (l[1] ^ 0xa) - l[3]));
|
|
|
|
retval << (0x7f & ( (l[2] >> l[3]) ^ (l[0] + l[3])));
|
|
|
|
retval << (0x7f & ((l[3] - (l[2] << 2)) ^ (l[0] | l[1])));
|
|
|
|
retval << (0x7f & (l[1] - l[2] + (0xf0 ^ (l[3] << 4))));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
MidiByteArray
|
2012-04-12 12:41:07 -04:00
|
|
|
Surface::host_connection_query (MidiByteArray & bytes)
|
|
|
|
{
|
|
|
|
MidiByteArray response;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
if (bytes[4] != 0x10 && bytes[4] != 0x11) {
|
|
|
|
/* not a Logic Control device - no response required */
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
// handle host connection query
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("host connection query: %1\n", bytes));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
if (bytes.size() != 18) {
|
|
|
|
cerr << "expecting 18 bytes, read " << bytes << " from " << _port->input_port().name() << endl;
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
// build and send host connection reply
|
|
|
|
response << 0x02;
|
|
|
|
copy (bytes.begin() + 6, bytes.begin() + 6 + 7, back_inserter (response));
|
|
|
|
response << calculate_challenge_response (bytes.begin() + 6 + 7, bytes.begin() + 6 + 7 + 4);
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
MidiByteArray
|
2012-04-12 12:41:07 -04:00
|
|
|
Surface::host_connection_confirmation (const MidiByteArray & bytes)
|
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("host_connection_confirmation: %1\n", bytes));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
// decode host connection confirmation
|
|
|
|
if (bytes.size() != 14) {
|
|
|
|
ostringstream os;
|
|
|
|
os << "expecting 14 bytes, read " << bytes << " from " << _port->input_port().name();
|
|
|
|
throw MackieControlException (os.str());
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-12 12:41:07 -04:00
|
|
|
// send version request
|
|
|
|
return MidiByteArray (2, 0x13, 0x00);
|
|
|
|
}
|
|
|
|
|
2012-05-11 12:04:09 -04:00
|
|
|
void
|
|
|
|
Surface::turn_it_on ()
|
|
|
|
{
|
2012-06-06 08:20:57 -04:00
|
|
|
if (_active) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_active = true;
|
2012-06-09 15:06:52 -04:00
|
|
|
|
2014-02-19 12:50:28 -05:00
|
|
|
_mcp.device_ready ();
|
|
|
|
|
2012-06-06 08:20:57 -04:00
|
|
|
for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) {
|
|
|
|
(*s)->notify_all ();
|
|
|
|
}
|
2012-06-09 15:06:52 -04:00
|
|
|
|
2016-01-28 15:08:19 -05:00
|
|
|
update_view_mode_display (false);
|
2012-06-06 08:20:57 -04:00
|
|
|
|
2016-01-30 22:38:18 -05:00
|
|
|
// if (_mcp.device_info ().has_global_controls ()) {
|
|
|
|
// _mcp.update_global_button (Button::Read, _mcp.metering_active ());
|
|
|
|
// }
|
2012-05-11 12:04:09 -04:00
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void
|
2012-04-10 10:27:44 -04:00
|
|
|
Surface::write_sysex (const MidiByteArray & mba)
|
|
|
|
{
|
|
|
|
if (mba.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MidiByteArray buf;
|
|
|
|
buf << sysex_hdr() << mba << MIDI::eox;
|
|
|
|
_port->write (buf);
|
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void
|
2012-04-10 10:27:44 -04:00
|
|
|
Surface::write_sysex (MIDI::byte msg)
|
|
|
|
{
|
|
|
|
MidiByteArray buf;
|
|
|
|
buf << sysex_hdr() << msg << MIDI::eox;
|
|
|
|
_port->write (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
2012-04-26 10:28:41 -04:00
|
|
|
Surface::n_strips (bool with_locked_strips) const
|
2012-04-10 10:27:44 -04:00
|
|
|
{
|
2012-04-26 10:28:41 -04:00
|
|
|
if (with_locked_strips) {
|
|
|
|
return strips.size();
|
2015-10-04 14:51:05 -04:00
|
|
|
}
|
2012-04-26 10:28:41 -04:00
|
|
|
|
|
|
|
uint32_t n = 0;
|
|
|
|
|
|
|
|
for (Strips::const_iterator it = strips.begin(); it != strips.end(); ++it) {
|
|
|
|
if (!(*it)->locked()) {
|
|
|
|
++n;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return n;
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Strip*
|
|
|
|
Surface::nth_strip (uint32_t n) const
|
|
|
|
{
|
|
|
|
if (n > n_strips()) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return strips[n];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Surface::zero_all ()
|
|
|
|
{
|
2012-06-01 08:56:20 -04:00
|
|
|
if (_mcp.device_info().has_timecode_display ()) {
|
|
|
|
display_timecode (string (10, '0'), string (10, ' '));
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-06-01 08:56:20 -04:00
|
|
|
if (_mcp.device_info().has_two_character_display()) {
|
2012-06-02 10:51:53 -04:00
|
|
|
show_two_char_display (string (2, '0'), string (2, ' '));
|
2012-06-01 08:56:20 -04:00
|
|
|
}
|
2012-04-10 10:27:44 -04:00
|
|
|
|
2012-06-12 23:07:50 -04:00
|
|
|
if (_mcp.device_info().has_master_fader () && _master_fader) {
|
2012-06-01 08:56:20 -04:00
|
|
|
_port->write (_master_fader->zero ());
|
|
|
|
}
|
2012-06-09 15:06:52 -04:00
|
|
|
|
2012-04-10 10:27:44 -04:00
|
|
|
// zero all strips
|
|
|
|
for (Strips::iterator it = strips.begin(); it != strips.end(); ++it) {
|
2012-04-21 22:15:24 -04:00
|
|
|
(*it)->zero();
|
|
|
|
}
|
|
|
|
|
|
|
|
zero_controls ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Surface::zero_controls ()
|
|
|
|
{
|
2012-06-09 15:06:52 -04:00
|
|
|
if (!_mcp.device_info().has_global_controls()) {
|
2012-04-21 22:15:24 -04:00
|
|
|
return;
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// turn off global buttons and leds
|
|
|
|
|
|
|
|
for (Controls::iterator it = controls.begin(); it != controls.end(); ++it) {
|
|
|
|
Control & control = **it;
|
2012-04-11 12:31:23 -04:00
|
|
|
if (!control.group().is_strip()) {
|
2012-04-11 09:03:41 -04:00
|
|
|
_port->write (control.zero());
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// and the led ring for the master strip
|
|
|
|
blank_jog_ring ();
|
2012-06-09 15:06:52 -04:00
|
|
|
|
|
|
|
_last_master_gain_written = 0.0f;
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-04-13 12:11:55 -04:00
|
|
|
Surface::periodic (uint64_t now_usecs)
|
2012-04-10 10:27:44 -04:00
|
|
|
{
|
2012-06-09 15:06:52 -04:00
|
|
|
master_gain_changed();
|
2012-04-10 10:27:44 -04:00
|
|
|
for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) {
|
2012-04-13 12:11:55 -04:00
|
|
|
(*s)->periodic (now_usecs);
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-02 22:03:17 -04:00
|
|
|
void
|
2016-01-29 12:26:41 -05:00
|
|
|
Surface::redisplay (ARDOUR::microseconds_t now, bool force)
|
2015-10-02 22:03:17 -04:00
|
|
|
{
|
|
|
|
for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) {
|
2016-01-29 12:26:41 -05:00
|
|
|
(*s)->redisplay (now, force);
|
2015-10-02 22:03:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-10 10:27:44 -04:00
|
|
|
void
|
2015-10-04 14:51:05 -04:00
|
|
|
Surface::write (const MidiByteArray& data)
|
2012-04-10 10:27:44 -04:00
|
|
|
{
|
2012-04-21 22:15:24 -04:00
|
|
|
if (_active) {
|
|
|
|
_port->write (data);
|
2013-03-06 15:15:28 -05:00
|
|
|
} else {
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, "surface not active, write ignored\n");
|
2012-04-21 22:15:24 -04:00
|
|
|
}
|
2012-04-10 10:27:44 -04:00
|
|
|
}
|
|
|
|
|
2017-05-17 16:55:43 -04:00
|
|
|
void
|
|
|
|
Surface::update_strip_selection ()
|
|
|
|
{
|
|
|
|
Strips::iterator s = strips.begin();
|
|
|
|
for ( ; s != strips.end(); ++s) {
|
|
|
|
(*s)->update_selection_state();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-10 11:13:37 -04:00
|
|
|
void
|
2016-05-16 16:45:37 -04:00
|
|
|
Surface::map_stripables (const vector<boost::shared_ptr<Stripable> >& stripables)
|
2012-04-10 11:13:37 -04:00
|
|
|
{
|
2016-05-16 16:45:37 -04:00
|
|
|
vector<boost::shared_ptr<Stripable> >::const_iterator r;
|
2012-04-26 12:18:03 -04:00
|
|
|
Strips::iterator s = strips.begin();
|
2012-04-10 11:13:37 -04:00
|
|
|
|
2016-05-16 16:45:37 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Mapping %1 stripables to %2 strips\n", stripables.size(), strips.size()));
|
2014-02-19 12:50:28 -05:00
|
|
|
|
2016-05-16 16:45:37 -04:00
|
|
|
for (r = stripables.begin(); r != stripables.end() && s != strips.end(); ++s) {
|
2012-04-26 10:28:41 -04:00
|
|
|
|
2016-05-16 16:45:37 -04:00
|
|
|
/* don't try to assign stripables to a locked strip. it won't
|
2012-04-26 10:28:41 -04:00
|
|
|
use it anyway, but if we do, then we get out of sync
|
|
|
|
with the proposed mapping.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!(*s)->locked()) {
|
2016-05-16 16:45:37 -04:00
|
|
|
(*s)->set_stripable (*r);
|
2012-04-26 10:28:41 -04:00
|
|
|
++r;
|
|
|
|
}
|
2012-04-10 11:13:37 -04:00
|
|
|
}
|
2012-04-21 22:15:24 -04:00
|
|
|
|
|
|
|
for (; s != strips.end(); ++s) {
|
2016-05-16 16:45:37 -04:00
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("strip %1 being set to null stripable\n", (*s)->index()));
|
|
|
|
(*s)->set_stripable (boost::shared_ptr<Stripable>());
|
2012-04-21 22:15:24 -04:00
|
|
|
}
|
2012-04-10 11:13:37 -04:00
|
|
|
}
|
2012-04-11 09:03:41 -04:00
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
static char
|
2012-04-22 13:37:52 -04:00
|
|
|
translate_seven_segment (char achar)
|
2012-04-11 09:03:41 -04:00
|
|
|
{
|
|
|
|
achar = toupper (achar);
|
2012-04-22 13:37:52 -04:00
|
|
|
|
|
|
|
if (achar >= 0x40 && achar <= 0x60) {
|
2012-04-11 09:03:41 -04:00
|
|
|
return achar - 0x40;
|
2012-04-22 13:37:52 -04:00
|
|
|
} else if (achar >= 0x21 && achar <= 0x3f) {
|
|
|
|
return achar;
|
|
|
|
} else {
|
|
|
|
return 0x00;
|
|
|
|
}
|
2012-04-11 09:03:41 -04:00
|
|
|
}
|
|
|
|
|
2012-04-22 13:37:52 -04:00
|
|
|
void
|
|
|
|
Surface::show_two_char_display (const std::string & msg, const std::string & dots)
|
2012-04-11 09:03:41 -04:00
|
|
|
{
|
2012-04-22 13:37:52 -04:00
|
|
|
if (_stype != mcu || !_mcp.device_info().has_two_character_display() || msg.length() != 2 || dots.length() != 2) {
|
|
|
|
return;
|
2012-04-11 15:27:13 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-22 13:37:52 -04:00
|
|
|
MidiByteArray right (3, 0xb0, 0x4b, 0x00);
|
|
|
|
MidiByteArray left (3, 0xb0, 0x4a, 0x00);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-22 13:37:52 -04:00
|
|
|
right[2] = translate_seven_segment (msg[0]) + (dots[0] == '.' ? 0x40 : 0x00);
|
|
|
|
left[2] = translate_seven_segment (msg[1]) + (dots[1] == '.' ? 0x40 : 0x00);
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-22 13:37:52 -04:00
|
|
|
_port->write (right);
|
|
|
|
_port->write (left);
|
2012-04-11 09:03:41 -04:00
|
|
|
}
|
|
|
|
|
2012-04-22 13:37:52 -04:00
|
|
|
void
|
|
|
|
Surface::show_two_char_display (unsigned int value, const std::string & /*dots*/)
|
2012-04-11 09:03:41 -04:00
|
|
|
{
|
|
|
|
ostringstream os;
|
|
|
|
os << setfill('0') << setw(2) << value % 100;
|
2012-04-22 13:37:52 -04:00
|
|
|
show_two_char_display (os.str());
|
2012-04-11 09:03:41 -04:00
|
|
|
}
|
|
|
|
|
2012-05-29 16:18:43 -04:00
|
|
|
void
|
|
|
|
Surface::display_timecode (const std::string & timecode, const std::string & last_timecode)
|
2012-04-11 09:03:41 -04:00
|
|
|
{
|
2018-02-02 10:26:17 -05:00
|
|
|
//TODO: Fix for Qcon to correct timecode value if is over 1000 bars
|
|
|
|
|
2012-05-29 16:34:19 -04:00
|
|
|
if (!_active || !_mcp.device_info().has_timecode_display()) {
|
2012-05-29 16:18:43 -04:00
|
|
|
return;
|
2012-04-11 09:03:41 -04:00
|
|
|
}
|
|
|
|
// if there's no change, send nothing, not even sysex header
|
2012-05-29 16:18:43 -04:00
|
|
|
if (timecode == last_timecode) return;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-04-11 09:03:41 -04:00
|
|
|
// length sanity checking
|
|
|
|
string local_timecode = timecode;
|
|
|
|
|
|
|
|
// truncate to 10 characters
|
|
|
|
if (local_timecode.length() > 10) {
|
|
|
|
local_timecode = local_timecode.substr (0, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
// pad to 10 characters
|
2015-10-04 14:51:05 -04:00
|
|
|
while (local_timecode.length() < 10) {
|
2012-04-11 09:03:41 -04:00
|
|
|
local_timecode += " ";
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-06-02 10:51:53 -04:00
|
|
|
// translate characters.
|
|
|
|
// Only the characters that actually changed are sent.
|
|
|
|
int position = 0x3f;
|
|
|
|
int i;
|
|
|
|
for (i = local_timecode.length () - 1; i >= 0; i--) {
|
|
|
|
position++;
|
|
|
|
if (local_timecode[i] == last_timecode[i]) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
MidiByteArray retval (2, 0xb0, position);
|
|
|
|
retval << translate_seven_segment (local_timecode[i]);
|
2012-05-29 16:18:43 -04:00
|
|
|
_port->write (retval);
|
2012-04-11 09:03:41 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-11 20:52:02 -04:00
|
|
|
void
|
|
|
|
Surface::update_flip_mode_display ()
|
|
|
|
{
|
|
|
|
for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) {
|
2016-02-01 22:52:16 -05:00
|
|
|
(*s)->flip_mode_changed ();
|
2015-10-08 00:36:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-11 11:46:39 -05:00
|
|
|
void
|
|
|
|
Surface::subview_mode_changed ()
|
2015-12-11 11:05:57 -05:00
|
|
|
{
|
2015-12-11 11:46:39 -05:00
|
|
|
for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) {
|
|
|
|
(*s)->subview_mode_changed ();
|
2015-12-11 11:05:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-11 15:27:13 -04:00
|
|
|
void
|
2016-01-28 15:08:19 -05:00
|
|
|
Surface::update_view_mode_display (bool with_helpful_text)
|
2012-04-11 15:27:13 -04:00
|
|
|
{
|
|
|
|
string text;
|
2012-04-25 23:46:18 -04:00
|
|
|
int id = -1;
|
2012-04-11 15:27:13 -04:00
|
|
|
|
2012-04-21 22:15:24 -04:00
|
|
|
if (!_active) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-11 15:27:13 -04:00
|
|
|
switch (_mcp.view_mode()) {
|
2012-04-12 17:02:43 -04:00
|
|
|
case MackieControlProtocol::Mixer:
|
2012-04-22 13:37:52 -04:00
|
|
|
show_two_char_display ("Mx");
|
2015-10-17 19:23:46 -04:00
|
|
|
id = Button::View;
|
2015-10-13 15:34:53 -04:00
|
|
|
text = _("Mixer View");
|
2012-04-11 15:27:13 -04:00
|
|
|
break;
|
|
|
|
case MackieControlProtocol::AudioTracks:
|
2012-04-22 13:37:52 -04:00
|
|
|
show_two_char_display ("AT");
|
2015-10-13 15:34:53 -04:00
|
|
|
id = Button::AudioTracks;
|
|
|
|
text = _("Audio Tracks");
|
2012-04-11 15:27:13 -04:00
|
|
|
break;
|
|
|
|
case MackieControlProtocol::MidiTracks:
|
2012-04-22 13:37:52 -04:00
|
|
|
show_two_char_display ("MT");
|
2015-10-13 15:34:53 -04:00
|
|
|
id = Button::MidiTracks;
|
|
|
|
text = _("MIDI Tracks");
|
|
|
|
break;
|
|
|
|
case MackieControlProtocol::Plugins:
|
|
|
|
show_two_char_display ("PL");
|
|
|
|
id = Button::Plugin;
|
|
|
|
text = _("Plugins");
|
|
|
|
break;
|
|
|
|
case MackieControlProtocol::Busses:
|
|
|
|
show_two_char_display ("BS");
|
|
|
|
id = Button::Busses;
|
2015-12-10 09:17:05 -05:00
|
|
|
if (Profile->get_mixbus()) {
|
|
|
|
text = _("Mixbusses");
|
|
|
|
} else {
|
|
|
|
text = _("Busses");
|
|
|
|
}
|
2015-10-13 15:34:53 -04:00
|
|
|
break;
|
|
|
|
case MackieControlProtocol::Auxes:
|
2015-12-10 09:17:05 -05:00
|
|
|
show_two_char_display ("Au");
|
2015-10-13 15:34:53 -04:00
|
|
|
id = Button::Aux;
|
|
|
|
text = _("Auxes");
|
2012-04-11 15:27:13 -04:00
|
|
|
break;
|
2016-01-16 10:32:30 -05:00
|
|
|
case MackieControlProtocol::Hidden:
|
|
|
|
show_two_char_display ("HI");
|
|
|
|
id = Button::Outputs;
|
|
|
|
text = _("Hidden Tracks");
|
|
|
|
break;
|
2015-10-20 21:54:56 -04:00
|
|
|
case MackieControlProtocol::Selected:
|
|
|
|
show_two_char_display ("SE");
|
|
|
|
id = Button::User;
|
2016-01-16 10:32:30 -05:00
|
|
|
text = _("Selected Tracks");
|
2015-10-20 21:54:56 -04:00
|
|
|
break;
|
2012-04-22 13:37:52 -04:00
|
|
|
default:
|
|
|
|
break;
|
2012-04-11 15:27:13 -04:00
|
|
|
}
|
|
|
|
|
2015-10-13 15:34:53 -04:00
|
|
|
vector<int> view_mode_buttons;
|
2015-10-17 19:23:46 -04:00
|
|
|
view_mode_buttons.push_back (Button::View);
|
2015-10-13 15:34:53 -04:00
|
|
|
view_mode_buttons.push_back (Button::Busses);
|
|
|
|
view_mode_buttons.push_back (Button::Plugin);
|
|
|
|
view_mode_buttons.push_back (Button::AudioTracks);
|
|
|
|
view_mode_buttons.push_back (Button::MidiTracks);
|
|
|
|
view_mode_buttons.push_back (Button::Aux);
|
2016-01-16 10:32:30 -05:00
|
|
|
view_mode_buttons.push_back (Button::Outputs);
|
2015-10-20 21:54:56 -04:00
|
|
|
view_mode_buttons.push_back (Button::User);
|
2015-10-13 15:34:53 -04:00
|
|
|
|
2012-04-25 23:46:18 -04:00
|
|
|
if (id >= 0) {
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-10-13 15:34:53 -04:00
|
|
|
for (vector<int>::iterator i = view_mode_buttons.begin(); i != view_mode_buttons.end(); ++i) {
|
2018-09-24 08:30:27 -04:00
|
|
|
map<int,Control*>::iterator x = controls_by_device_independent_id.find (*i);
|
2012-04-25 23:46:18 -04:00
|
|
|
|
2015-10-13 15:34:53 -04:00
|
|
|
if (x != controls_by_device_independent_id.end()) {
|
|
|
|
Button* button = dynamic_cast<Button*> (x->second);
|
|
|
|
if (button) {
|
|
|
|
bool onoff;
|
|
|
|
onoff = (*i) == id;
|
2012-04-25 23:46:18 -04:00
|
|
|
|
2015-10-13 15:34:53 -04:00
|
|
|
_port->write (button->set_state (onoff));
|
|
|
|
}
|
2012-04-25 23:46:18 -04:00
|
|
|
}
|
|
|
|
}
|
2012-04-11 15:47:41 -04:00
|
|
|
}
|
|
|
|
|
2016-01-28 15:08:19 -05:00
|
|
|
if (with_helpful_text && !text.empty()) {
|
2015-10-13 15:34:53 -04:00
|
|
|
display_message_for (text, 1000);
|
2012-04-11 15:27:13 -04:00
|
|
|
}
|
|
|
|
}
|
2012-04-12 10:34:03 -04:00
|
|
|
|
2012-04-21 22:15:24 -04:00
|
|
|
void
|
|
|
|
Surface::say_hello ()
|
|
|
|
{
|
2012-04-23 06:54:34 -04:00
|
|
|
/* wakeup for Mackie Control */
|
2012-04-21 22:15:24 -04:00
|
|
|
MidiByteArray wakeup (7, MIDI::sysex, 0x00, 0x00, 0x66, 0x14, 0x00, MIDI::eox);
|
|
|
|
_port->write (wakeup);
|
|
|
|
wakeup[4] = 0x15; /* wakup Mackie XT */
|
|
|
|
_port->write (wakeup);
|
2015-10-02 21:59:05 -04:00
|
|
|
wakeup[4] = 0x10; /* wakeup Logic Control */
|
2012-04-21 22:15:24 -04:00
|
|
|
_port->write (wakeup);
|
|
|
|
wakeup[4] = 0x11; /* wakeup Logic Control XT */
|
|
|
|
_port->write (wakeup);
|
|
|
|
}
|
2012-04-22 13:37:52 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Surface::next_jog_mode ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-05-02 16:29:46 -04:00
|
|
|
Surface::set_jog_mode (JogWheel::Mode)
|
2012-04-22 13:37:52 -04:00
|
|
|
{
|
2015-10-05 10:17:49 -04:00
|
|
|
}
|
2012-04-26 10:28:41 -04:00
|
|
|
|
|
|
|
bool
|
2016-05-16 16:45:37 -04:00
|
|
|
Surface::stripable_is_locked_to_strip (boost::shared_ptr<Stripable> stripable) const
|
2012-04-26 10:28:41 -04:00
|
|
|
{
|
|
|
|
for (Strips::const_iterator s = strips.begin(); s != strips.end(); ++s) {
|
2016-05-16 16:45:37 -04:00
|
|
|
if ((*s)->stripable() == stripable && (*s)->locked()) {
|
2012-04-26 10:28:41 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-30 10:32:27 -04:00
|
|
|
|
2016-01-28 15:08:19 -05:00
|
|
|
bool
|
2016-05-16 16:45:37 -04:00
|
|
|
Surface::stripable_is_mapped (boost::shared_ptr<Stripable> stripable) const
|
2016-01-28 15:08:19 -05:00
|
|
|
{
|
|
|
|
for (Strips::const_iterator s = strips.begin(); s != strips.end(); ++s) {
|
2016-05-16 16:45:37 -04:00
|
|
|
if ((*s)->stripable() == stripable) {
|
2016-01-28 15:08:19 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-10-04 14:51:05 -04:00
|
|
|
void
|
2012-06-01 08:56:20 -04:00
|
|
|
Surface::notify_metering_state_changed()
|
2012-05-30 10:32:27 -04:00
|
|
|
{
|
|
|
|
for (Strips::const_iterator s = strips.begin(); s != strips.end(); ++s) {
|
2012-06-01 08:56:20 -04:00
|
|
|
(*s)->notify_metering_state_changed ();
|
2012-05-30 10:32:27 -04:00
|
|
|
}
|
|
|
|
}
|
2015-10-02 21:54:40 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Surface::reset ()
|
|
|
|
{
|
|
|
|
if (_port) {
|
|
|
|
/* reset msg for Mackie Control */
|
2015-10-08 12:49:58 -04:00
|
|
|
MidiByteArray msg;
|
|
|
|
msg << sysex_hdr();
|
|
|
|
msg << 0x08;
|
|
|
|
msg << 0x00;
|
|
|
|
msg << MIDI::eox;
|
2015-10-02 21:54:40 -04:00
|
|
|
_port->write (msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Surface::toggle_backlight ()
|
|
|
|
{
|
|
|
|
if (_port) {
|
|
|
|
int onoff = random() %2;
|
2015-10-08 12:49:58 -04:00
|
|
|
MidiByteArray msg;
|
|
|
|
msg << sysex_hdr ();
|
|
|
|
msg << 0xa;
|
|
|
|
msg << (onoff ? 0x1 : 0x0);
|
|
|
|
msg << MIDI::eox;
|
2015-10-02 21:54:40 -04:00
|
|
|
_port->write (msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Surface::recalibrate_faders ()
|
|
|
|
{
|
|
|
|
if (_port) {
|
2015-10-08 12:49:58 -04:00
|
|
|
MidiByteArray msg;
|
|
|
|
msg << sysex_hdr ();
|
|
|
|
msg << 0x09;
|
|
|
|
msg << 0x00;
|
|
|
|
msg << MIDI::eox;
|
2015-10-02 21:54:40 -04:00
|
|
|
_port->write (msg);
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
}
|
2015-10-02 21:54:40 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Surface::set_touch_sensitivity (int sensitivity)
|
|
|
|
{
|
|
|
|
/* NOTE: assumed called from GUI code, hence sleep() */
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2015-10-02 21:54:40 -04:00
|
|
|
/* sensitivity already clamped by caller */
|
|
|
|
|
2018-02-02 10:26:17 -05:00
|
|
|
if( !is_qcon ) { // Qcon doesn't support fader sensitivity
|
|
|
|
if (_port) {
|
|
|
|
MidiByteArray msg;
|
2015-10-08 12:49:58 -04:00
|
|
|
|
2018-02-02 10:26:17 -05:00
|
|
|
msg << sysex_hdr ();
|
|
|
|
msg << 0x0e;
|
|
|
|
msg << 0xff; /* overwritten for each fader below */
|
|
|
|
msg << (sensitivity & 0x7f);
|
|
|
|
msg << MIDI::eox;
|
2015-10-02 21:54:40 -04:00
|
|
|
|
2018-02-02 10:26:17 -05:00
|
|
|
for (int fader = 0; fader < 9; ++fader) {
|
|
|
|
msg[6] = fader;
|
|
|
|
_port->write (msg);
|
|
|
|
}
|
2015-10-02 21:54:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-03 12:03:07 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Surface::hui_heartbeat ()
|
|
|
|
{
|
|
|
|
if (!_port) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MidiByteArray msg (3, MIDI::on, 0x0, 0x0);
|
|
|
|
_port->write (msg);
|
|
|
|
}
|
2015-10-07 13:17:42 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
Surface::connected ()
|
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface %1 now connected, trying to ping device...\n", _name));
|
|
|
|
|
|
|
|
say_hello ();
|
|
|
|
|
|
|
|
if (_mcp.device_info().no_handshake()) {
|
|
|
|
turn_it_on ();
|
|
|
|
}
|
|
|
|
}
|
2015-10-08 12:49:58 -04:00
|
|
|
|
|
|
|
MidiByteArray
|
|
|
|
Surface::display_line (string const& msg, int line_num)
|
|
|
|
{
|
|
|
|
MidiByteArray midi_msg;
|
|
|
|
midi_msg << sysex_hdr ();
|
|
|
|
midi_msg << 0x12;
|
|
|
|
midi_msg << (line_num ? 0x38 : 0x0); /* offsets into char array
|
|
|
|
* on device that
|
|
|
|
* correspond to line
|
|
|
|
* starts
|
|
|
|
*/
|
|
|
|
if (msg.empty()) {
|
|
|
|
|
|
|
|
midi_msg.insert (midi_msg.end(), 55, ' ');
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* ascii data to display. @param msg is UTF-8 which is not legal. */
|
|
|
|
string ascii = Glib::convert_with_fallback (msg, "UTF-8", "ISO-8859-1", "_");
|
|
|
|
string::size_type len = ascii.length();
|
|
|
|
|
|
|
|
if (len > 55) {
|
|
|
|
midi_msg << ascii.substr (0, 55);
|
|
|
|
} else {
|
|
|
|
midi_msg << ascii;
|
|
|
|
|
|
|
|
for (string::size_type i = len; i < 55; ++i) {
|
|
|
|
midi_msg << ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
midi_msg << MIDI::eox;
|
|
|
|
|
|
|
|
return midi_msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** display @param msg on the 55x2 screen for @param msecs milliseconds
|
|
|
|
*
|
|
|
|
* @param msg is assumed to be UTF-8 encoded, and will be converted
|
|
|
|
* to ASCII with an underscore as fallback character before being
|
|
|
|
* sent to the device.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Surface::display_message_for (string const& msg, uint64_t msecs)
|
|
|
|
{
|
|
|
|
string::size_type newline;
|
|
|
|
|
|
|
|
if ((newline = msg.find ('\n')) == string::npos) {
|
|
|
|
|
|
|
|
_port->write (display_line (msg, 0));
|
|
|
|
_port->write (display_line (string(), 1));
|
|
|
|
|
|
|
|
} else if (newline == 0) {
|
|
|
|
|
|
|
|
_port->write (display_line (string(), 0));
|
|
|
|
_port->write (display_line (msg.substr (1), 1));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
string first_line = msg.substr (0, newline-1);
|
|
|
|
string second_line = msg.substr (newline+1);
|
|
|
|
|
|
|
|
_port->write (display_line (first_line, 0));
|
|
|
|
_port->write (display_line (second_line.substr (0, second_line.find_first_of ('\n')), 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Strips::const_iterator s = strips.begin(); s != strips.end(); ++s) {
|
|
|
|
(*s)->block_screen_display_for (msecs);
|
|
|
|
}
|
|
|
|
}
|