MCP: latest patch from Rodrigo:

* fixes Master Fader Touch button in the Mackie;
    * implements a MasterFaderTouch global button;
    * removes unused MackieControlProtocol::_transport_previously_rolling property;
    * implements DeviceInfo::get_global_button() method;
    * creates GlobalButtonsInfo and StripButtonsInfo types in DeviceInfo;
    * implements Surface::_last_master_gain_written property to help master fader feedback;
    * makes Surface respect _mcp.device_info().strip_cnt() to create master fader and when connecting signals for strips and master fader instead of using hardcoded 8;
    * removed a few unnecessary updates in Surface::turn_it_on();
    * included master_gain_changed() in Surface::periodic();
    * implemented MackieControlProtocol::master_fader_touch_press and
    * MackieControlProtocol::master_fader_touch_release;



git-svn-id: svn://localhost/ardour2/branches/3.0@12631 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-06-09 19:06:52 +00:00
parent 94b6c7626c
commit 71427323ec
10 changed files with 138 additions and 45 deletions

View file

@ -136,6 +136,10 @@ Button::name_to_id (const std::string& name)
if (!g_ascii_strcasecmp (name.c_str(), "VSelect")) { return VSelect; }
if (!g_ascii_strcasecmp (name.c_str(), "FaderTouch")) { return FaderTouch; }
/* Master Fader button */
if (!g_ascii_strcasecmp (name.c_str(), "MasterFaderTouch")) { return MasterFaderTouch; }
return -1;
}
@ -237,5 +241,7 @@ Button::id_to_name (Button::ID id)
if (id == VSelect) { return "V-Pot"; }
if (id == FaderTouch) { return "Fader Touch"; }
if (id == MasterFaderTouch) { return "Master Fader Touch"; }
return "???";
}

View file

@ -136,6 +136,10 @@ public:
Select,
VSelect,
FaderTouch,
/* Master fader */
MasterFaderTouch,
};

View file

@ -61,10 +61,20 @@ DeviceInfo::~DeviceInfo()
{
}
GlobalButtonInfo&
DeviceInfo::get_global_button(Button::ID id)
{
GlobalButtonsInfo::iterator it;
it = _global_buttons.find (id);
return it->second;
}
std::string&
DeviceInfo::get_global_button_name(Button::ID id)
{
std::map<Button::ID,GlobalButtonInfo>::iterator it;
GlobalButtonsInfo::iterator it;
it = _global_buttons.find (id);
if (it == _global_buttons.end ()) {
@ -89,7 +99,6 @@ DeviceInfo::mackie_control_buttons ()
//TODO controller position value (0x00 to 0x7f)
_strip_buttons[Button::RecEnable] = StripButtonInfo (0x0, "Rec");
_strip_buttons[Button::FaderTouch] = StripButtonInfo (0xe0, "Fader Touch");
}
void
@ -102,7 +111,6 @@ DeviceInfo::logic_control_buttons ()
_global_buttons[Button::UserB] = GlobalButtonInfo ("User Switch B", "user", 0x67);
_strip_buttons[Button::RecEnable] = StripButtonInfo (0x0, "Rec/Rdy");
_strip_buttons[Button::FaderTouch] = StripButtonInfo (0x68, "Fader Touch");
}
void
@ -185,6 +193,10 @@ DeviceInfo::shared_buttons ()
_strip_buttons[Button::Mute] = StripButtonInfo (0x10, "Mute");
_strip_buttons[Button::Select] = StripButtonInfo (0x18, "Select");
_strip_buttons[Button::VSelect] = StripButtonInfo (0x20, "V-Select");
_strip_buttons[Button::FaderTouch] = StripButtonInfo (0x68, "Fader Touch");
_global_buttons[Button::MasterFaderTouch] = GlobalButtonInfo ("Master Fader Touch", "master", 0x70);
}
int

View file

@ -75,9 +75,13 @@ class DeviceInfo
static void reload_device_info();
std::string& get_global_button_name(Button::ID);
GlobalButtonInfo& get_global_button(Button::ID);
const std::map<Button::ID,GlobalButtonInfo>& global_buttons() const { return _global_buttons; }
const std::map<Button::ID,StripButtonInfo>& strip_buttons() const { return _strip_buttons; }
typedef std::map<Button::ID,GlobalButtonInfo> GlobalButtonsInfo;
typedef std::map<Button::ID,StripButtonInfo> StripButtonsInfo;
const GlobalButtonsInfo& global_buttons() const { return _global_buttons; }
const StripButtonsInfo& strip_buttons() const { return _strip_buttons; }
private:
uint32_t _strip_cnt;
@ -95,8 +99,8 @@ class DeviceInfo
std::string _name;
std::string _global_button_name;
std::map<Button::ID,GlobalButtonInfo> _global_buttons;
std::map<Button::ID,StripButtonInfo> _strip_buttons;
GlobalButtonsInfo _global_buttons;
StripButtonsInfo _strip_buttons;
void logic_control_buttons ();
void mackie_control_buttons ();

View file

@ -438,6 +438,10 @@ MackieControlProtocol::periodic ()
void
MackieControlProtocol::update_timecode_beats_led()
{
if (!_device_info.has_timecode_display()) {
return;
}
DEBUG_TRACE (DEBUG::MackieControl, string_compose("MackieControlProtocol::update_timecode_beats_led(): %1\n", _timecode_type));
switch (_timecode_type) {
case ARDOUR::AnyTime::BBT:
@ -458,12 +462,12 @@ MackieControlProtocol::update_timecode_beats_led()
void
MackieControlProtocol::update_global_button (int id, LedState ls)
{
boost::shared_ptr<Surface> surface = surfaces.front();
if (!surface->type() == mcu) {
if (!_device_info.has_global_controls()) {
return;
}
boost::shared_ptr<Surface> surface = surfaces.front();
map<int,Control*>::iterator x = surface->controls_by_device_independent_id.find (id);
if (x != surface->controls_by_device_independent_id.end()) {
Button * button = dynamic_cast<Button*> (x->second);
@ -476,15 +480,14 @@ MackieControlProtocol::update_global_button (int id, LedState ls)
void
MackieControlProtocol::update_global_led (int id, LedState ls)
{
boost::shared_ptr<Surface> surface = surfaces.front();
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("MackieControlProtocol::update_global_led (%1, %2)\n", id, ls));
if (surface->type() != mcu) {
if (!_device_info.has_global_controls()) {
return;
}
boost::shared_ptr<Surface> surface = surfaces.front();
map<int,Control*>::iterator x = surface->controls_by_device_independent_id.find (id);
if (x != surface->controls_by_device_independent_id.end()) {
Led * led = dynamic_cast<Led*> (x->second);
DEBUG_TRACE (DEBUG::MackieControl, "Writing LedState\n");
@ -516,8 +519,11 @@ MackieControlProtocol::initialize()
if (!surfaces.front()->active ()) {
return;
}
// sometimes the jog wheel is a pot
surfaces.front()->blank_jog_ring ();
if (_device_info.has_jog_wheel()) {
surfaces.front()->blank_jog_ring ();
}
// update global buttons and displays
@ -898,6 +904,10 @@ MackieControlProtocol::notify_loop_state_changed()
void
MackieControlProtocol::notify_transport_state_changed()
{
if (!_device_info.has_global_controls()) {
return;
}
// switch various play and stop buttons on / off
update_global_button (Button::Loop, session->get_play_loop());
update_global_button (Button::Play, session->transport_speed() == 1.0);
@ -906,8 +916,6 @@ MackieControlProtocol::notify_transport_state_changed()
update_global_button (Button::Ffwd, session->transport_speed() > 1.0);
notify_metering_state_changed ();
_transport_previously_rolling = session->transport_rolling();
}
void
@ -921,6 +929,9 @@ MackieControlProtocol::notify_metering_state_changed()
void
MackieControlProtocol::notify_record_state_changed ()
{
if (!_device_info.has_global_controls()) {
return;
}
boost::shared_ptr<Surface> surface = surfaces.front();
/* rec is a tristate */
@ -1061,6 +1072,7 @@ MackieControlProtocol::build_button_map ()
DEFINE_BUTTON_HANDLER (Button::Scrub, &MackieControlProtocol::scrub_press, &MackieControlProtocol::scrub_release);
DEFINE_BUTTON_HANDLER (Button::UserA, &MackieControlProtocol::user_a_press, &MackieControlProtocol::user_a_release);
DEFINE_BUTTON_HANDLER (Button::UserB, &MackieControlProtocol::user_b_press, &MackieControlProtocol::user_b_release);
DEFINE_BUTTON_HANDLER (Button::MasterFaderTouch, &MackieControlProtocol::master_fader_touch_press, &MackieControlProtocol::master_fader_touch_release);
DEFINE_BUTTON_HANDLER (Button::Snapshot, &MackieControlProtocol::snapshot_press, &MackieControlProtocol::snapshot_release);
DEFINE_BUTTON_HANDLER (Button::Read, &MackieControlProtocol::read_press, &MackieControlProtocol::read_release);

View file

@ -266,7 +266,6 @@ class MackieControlProtocol
PBD::ScopedConnectionList port_connections;
PBD::ScopedConnectionList route_connections;
PBD::ScopedConnectionList gui_connections;
bool _transport_previously_rolling;
// timer for two quick marker left presses
Mackie::Timer _frm_left_last;
// last written timecode string
@ -450,6 +449,8 @@ class MackieControlProtocol
Mackie::LedState user_b_release (Mackie::Button &);
Mackie::LedState fader_touch_press (Mackie::Button &);
Mackie::LedState fader_touch_release (Mackie::Button &);
Mackie::LedState master_fader_touch_press (Mackie::Button &);
Mackie::LedState master_fader_touch_release (Mackie::Button &);
Mackie::LedState snapshot_press (Mackie::Button&);
Mackie::LedState snapshot_release (Mackie::Button&);
@ -499,6 +500,4 @@ class MackieControlProtocol
Mackie::LedState view_release (Mackie::Button&);
};
#endif // ardour_mackie_control_protocol_h

View file

@ -29,6 +29,7 @@
#include "mackie_control_protocol.h"
#include "surface.h"
#include "fader.h"
#include "i18n.h"
@ -996,6 +997,33 @@ MackieControlProtocol::user_b_release (Button &)
return off;
}
LedState
MackieControlProtocol::master_fader_touch_press (Mackie::Button &)
{
DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::master_fader_touch_press\n");
Fader* master_fader = surfaces.front()->master_fader();
boost::shared_ptr<AutomationControl> ac = master_fader->control ();
master_fader->set_in_use (true);
master_fader->start_touch (transport_frame());
return none;
}
LedState
MackieControlProtocol::master_fader_touch_release (Mackie::Button &)
{
DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::master_fader_touch_release\n");
Fader* master_fader = surfaces.front()->master_fader();
master_fader->set_in_use (false);
master_fader->stop_touch (transport_frame(), true);
return none;
}
Mackie::LedState
MackieControlProtocol::snapshot_press (Mackie::Button&)
{

View file

@ -128,6 +128,7 @@ Strip::add (Control & control)
break;
case Button::FaderTouch:
_fader_touch = button;
break;
default:
break;
}

View file

@ -63,6 +63,7 @@ Surface::Surface (MackieControlProtocol& mcp, const std::string& device_name, ui
, _active (false)
, _connected (false)
, _jog_wheel (0)
, _last_master_gain_written (-0.0f)
{
DEBUG_TRACE (DEBUG::MackieControl, "Surface::init\n");
@ -71,7 +72,7 @@ Surface::Surface (MackieControlProtocol& mcp, const std::string& device_name, ui
/* only the first Surface object has global controls */
if (_number == 0) {
DEBUG_TRACE (DEBUG::MackieControl, "Surface has global controls\n");
DEBUG_TRACE (DEBUG::MackieControl, "Surface is first. Might have global controls.\n");
if (_mcp.device_info().has_global_controls()) {
init_controls ();
DEBUG_TRACE (DEBUG::MackieControl, "init_controls done\n");
@ -199,7 +200,7 @@ Surface::init_strips (uint32_t n)
void
Surface::setup_master ()
{
_master_fader = dynamic_cast<Fader*> (Fader::factory (*this, 8, "master", *groups["master"]));
_master_fader = dynamic_cast<Fader*> (Fader::factory (*this, _mcp.device_info().strip_cnt(), "master", *groups["master"]));
boost::shared_ptr<Route> m;
@ -213,14 +214,41 @@ Surface::setup_master ()
_master_fader->set_control (m->gain_control());
m->gain_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&Surface::master_gain_changed, this), ui_context());
Groups::iterator group_it;
group_it = groups.find("master");
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()));
}
void
Surface::master_gain_changed ()
{
if (!_master_fader) {
return;
}
boost::shared_ptr<AutomationControl> ac = _master_fader->control();
float pos = ac->internal_to_interface (ac->get_value());
_port->write (_master_fader->set_position (pos));
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;
}
float
@ -283,14 +311,12 @@ Surface::connect_to_signals ()
/* Button messages are NoteOn. libmidi++ sends note-on w/velocity = 0 as note-off so catch them too */
p->note_off.connect_same_thread (*this, boost::bind (&Surface::handle_midi_note_on_message, this, _1, _2));
/* Fader messages are Pitchbend */
p->channel_pitchbend[0].connect_same_thread (*this, boost::bind (&Surface::handle_midi_pitchbend_message, this, _1, _2, 0U));
p->channel_pitchbend[1].connect_same_thread (*this, boost::bind (&Surface::handle_midi_pitchbend_message, this, _1, _2, 1U));
p->channel_pitchbend[2].connect_same_thread (*this, boost::bind (&Surface::handle_midi_pitchbend_message, this, _1, _2, 2U));
p->channel_pitchbend[3].connect_same_thread (*this, boost::bind (&Surface::handle_midi_pitchbend_message, this, _1, _2, 3U));
p->channel_pitchbend[4].connect_same_thread (*this, boost::bind (&Surface::handle_midi_pitchbend_message, this, _1, _2, 4U));
p->channel_pitchbend[5].connect_same_thread (*this, boost::bind (&Surface::handle_midi_pitchbend_message, this, _1, _2, 5U));
p->channel_pitchbend[6].connect_same_thread (*this, boost::bind (&Surface::handle_midi_pitchbend_message, this, _1, _2, 6U));
p->channel_pitchbend[7].connect_same_thread (*this, boost::bind (&Surface::handle_midi_pitchbend_message, this, _1, _2, 7U));
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()));
_connected = true;
}
@ -308,7 +334,7 @@ Surface::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb, uin
*/
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("handle_midi pitchbend on port %3, fader = %1 value = %2\n",
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface::handle_midi_pitchbend_message on port %3, fader = %1 value = %2\n",
fader_id, pb, _number));
if (_mcp.device_info().no_handshake()) {
@ -323,6 +349,7 @@ Surface::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb, uin
if (strip) {
strip->handle_fader (*fader, pos);
} else {
DEBUG_TRACE (DEBUG::MackieControl, "Handling master fader\n");
/* master fader */
fader->set_value (pos); // alter master gain
_port->write (fader->set_position (pos)); // write back value (required for servo)
@ -335,7 +362,7 @@ Surface::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb, uin
void
Surface::handle_midi_note_on_message (MIDI::Parser &, MIDI::EventTwoBytes* ev)
{
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("SurfacePort::handle_note_on %1 = %2\n", (int) ev->note_number, (int) ev->velocity));
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface::handle_midi_note_on_message %1 = %2\n", (int) ev->note_number, (int) ev->velocity));
if (_mcp.device_info().no_handshake()) {
turn_it_on ();
@ -356,7 +383,7 @@ Surface::handle_midi_note_on_message (MIDI::Parser &, MIDI::EventTwoBytes* ev)
_mcp.handle_button_event (*this, *button, ev->velocity > 64 ? press : release);
}
} else {
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("no button found for %1\n", ev->note_number));
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("no button found for %1\n", (int) ev->note_number));
}
}
@ -521,14 +548,12 @@ Surface::turn_it_on ()
}
_active = true;
zero_controls ();
for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) {
(*s)->notify_all ();
}
update_view_mode_display ();
if (_mcp.device_info ().has_master_fader ()) {
master_gain_changed ();
}
if (_mcp.device_info ().has_global_controls ()) {
_mcp.update_global_button (Button::Read, _mcp.metering_active ());
@ -601,7 +626,7 @@ Surface::zero_all ()
if (_mcp.device_info().has_master_fader ()) {
_port->write (_master_fader->zero ());
}
// zero all strips
for (Strips::iterator it = strips.begin(); it != strips.end(); ++it) {
(*it)->zero();
@ -613,7 +638,7 @@ Surface::zero_all ()
void
Surface::zero_controls ()
{
if (_stype != mcu || !_mcp.device_info().has_global_controls()) {
if (!_mcp.device_info().has_global_controls()) {
return;
}
@ -630,11 +655,14 @@ Surface::zero_controls ()
// and the led ring for the master strip
blank_jog_ring ();
_last_master_gain_written = 0.0f;
}
void
Surface::periodic (uint64_t now_usecs)
{
master_gain_changed();
for (Strips::iterator s = strips.begin(); s != strips.end(); ++s) {
(*s)->periodic (now_usecs);
}
@ -643,9 +671,7 @@ Surface::periodic (uint64_t now_usecs)
void
Surface::write (const MidiByteArray& data)
{
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Surface::write for %1\n", data));
if (_active) {
DEBUG_TRACE (DEBUG::MackieControl, "Surface::write surface active\n");
_port->write (data);
}
}

View file

@ -160,12 +160,13 @@ public:
bool _connected;
Mackie::JogWheel* _jog_wheel;
Fader* _master_fader;
float _last_master_gain_written;
void handle_midi_sysex (MIDI::Parser&, MIDI::byte *, size_t count);
MidiByteArray host_connection_query (MidiByteArray& bytes);
MidiByteArray host_connection_confirmation (const MidiByteArray& bytes);
void init_controls();
void init_controls ();
void init_strips (uint32_t n);
void setup_master ();
void master_gain_changed ();