13
0

implement backlight, fader touch sensitivity and recalibrate fader functions for MCP GUI

This commit is contained in:
Paul Davis 2015-10-02 21:54:40 -04:00
parent 04b9df1fd9
commit ccf505c3a2
6 changed files with 144 additions and 1 deletions

View File

@ -111,6 +111,12 @@ MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
RadioButtonGroup rb_group = absolute_touch_mode_button.get_group();
touch_move_mode_button.set_group (rb_group);
recalibrate_fader_button.signal_clicked().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::recalibrate_faders));
backlight_button.signal_clicked().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::toggle_backlight));
touch_sensitivity_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::touch_sensitive_change));
touch_sensitivity_scale.set_update_policy (Gtk::UPDATE_DISCONTINUOUS);
l = manage (new Gtk::Label (_("Button click")));
l->set_alignment (1.0, 0.5);
table->attach (*l, 0, 1, 1, 2, AttachOptions(FILL|EXPAND), AttachOptions (0));
@ -154,7 +160,6 @@ MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
ipmidi_base_port_spinner.set_sensitive (_cp.device_info().uses_ipmidi());
ipmidi_base_port_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::ipmidi_spinner_changed));
table->attach (discover_button, 1, 2, 8, 9, AttachOptions(FILL|EXPAND), AttachOptions (0));
discover_button.signal_clicked().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::discover_clicked));
@ -562,3 +567,22 @@ MackieControlProtocolGUI::discover_clicked ()
/* this should help to get things started */
_cp.midi_connectivity_established ();
}
void
MackieControlProtocolGUI::recalibrate_faders ()
{
_cp.recalibrate_faders ();
}
void
MackieControlProtocolGUI::toggle_backlight ()
{
_cp.toggle_backlight ();
}
void
MackieControlProtocolGUI::touch_sensitive_change ()
{
int sensitivity = (int) touch_sensitivity_adjustment.get_value ();
_cp.set_touch_sensitivity (sensitivity);
}

View File

@ -109,6 +109,9 @@ class MackieControlProtocolGUI : public Gtk::Notebook
Gtk::Button discover_button;
void discover_clicked ();
void recalibrate_faders ();
void toggle_backlight ();
void touch_sensitive_change ();
};
}

View File

@ -1695,3 +1695,36 @@ MackieControlProtocol::clear_surfaces ()
Glib::Threads::Mutex::Lock lm (surfaces_lock);
surfaces.clear ();
}
void
MackieControlProtocol::set_touch_sensitivity (int sensitivity)
{
sensitivity = min (9, sensitivity);
sensitivity = max (0, sensitivity);
Glib::Threads::Mutex::Lock lm (surfaces_lock);
for (Surfaces::const_iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
(*s)->set_touch_sensitivity (sensitivity);
}
}
void
MackieControlProtocol::recalibrate_faders ()
{
Glib::Threads::Mutex::Lock lm (surfaces_lock);
for (Surfaces::const_iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
(*s)->recalibrate_faders ();
}
}
void
MackieControlProtocol::toggle_backlight ()
{
Glib::Threads::Mutex::Lock lm (surfaces_lock);
for (Surfaces::const_iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
(*s)->toggle_backlight ();
}
}

View File

@ -171,6 +171,10 @@ class MackieControlProtocol
void notify_route_added (ARDOUR::RouteList &);
void notify_remote_id_changed();
void recalibrate_faders ();
void toggle_backlight ();
void set_touch_sensitivity (int);
/// rebuild the current bank. Called on route added/removed and
/// remote id changed.
void refresh_current_bank();

View File

@ -995,3 +995,75 @@ Surface::notify_metering_state_changed()
(*s)->notify_metering_state_changed ();
}
}
void
Surface::reset ()
{
if (_port) {
/* reset msg for Mackie Control */
MidiByteArray msg (8, MIDI::sysex, 0x00, 0x00, 0x66, 0x14, 0x08, 0x00, MIDI::eox);
_port->write (msg);
msg[4] = 0x15; /* reset Mackie XT */
_port->write (msg);
msg[4] = 0x10; /* reset Logic Control */
_port->write (msg);
msg[4] = 0x11; /* reset Logic Control XT */
_port->write (msg);
}
}
void
Surface::toggle_backlight ()
{
if (_port) {
int onoff = random() %2;
MidiByteArray msg (8, MIDI::sysex, 0x00, 0x00, 0x66, 0x14, 0x0a, onoff, MIDI::eox);
_port->write (msg);
msg[4] = 0x15; /* reset Mackie XT */
_port->write (msg);
msg[4] = 0x10; /* reset Logic Control */
_port->write (msg);
msg[4] = 0x11; /* reset Logic Control XT */
_port->write (msg);
}
}
void
Surface::recalibrate_faders ()
{
if (_port) {
MidiByteArray msg (8, MIDI::sysex, 0x00, 0x00, 0x66, 0x14, 0x09, 0x00, MIDI::eox);
_port->write (msg);
msg[4] = 0x15; /* reset Mackie XT */
_port->write (msg);
msg[4] = 0x10; /* reset Logic Control */
_port->write (msg);
msg[4] = 0x11; /* reset Logic Control XT */
_port->write (msg);
}
}
void
Surface::set_touch_sensitivity (int sensitivity)
{
/* NOTE: assumed called from GUI code, hence sleep() */
/* sensitivity already clamped by caller */
if (_port) {
MidiByteArray msg (9, MIDI::sysex, 0x00, 0x00, 0x66, 0x14, 0x0e, 0xff, sensitivity, MIDI::eox);
for (int fader = 0; fader < 9; ++fader) {
msg[6] = fader;
_port->write (msg);
msg[4] = 0x15; /* reset Mackie XT */
_port->write (msg);
msg[4] = 0x10; /* reset Logic Control */
_port->write (msg);
msg[4] = 0x11; /* reset Logic Control XT */
g_usleep (1000); /* milliseconds */
}
}
}

View File

@ -115,6 +115,13 @@ public:
void display_timecode (const std::string & /*timecode*/, const std::string & /*timecode_last*/);
/// sends MCP "reset" message to surface
void reset ();
void recalibrate_faders ();
void toggle_backlight ();
void set_touch_sensitivity (int);
/**
This is used to calculate the clicks per second that define
a transport speed of 1.0 for the jog wheel. 100.0 is 10 clicks