13
0

MCP: add handler for forgotten noteOn (button) messages, and more code tidying

git-svn-id: svn://localhost/ardour2/branches/3.0@11834 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-04-08 20:34:21 +00:00
parent 7296ef87a1
commit c6c98b6453
3 changed files with 60 additions and 59 deletions

View File

@ -272,8 +272,11 @@ void MackiePort::connect_to_signals ()
MIDI::Parser* p = input_port().parser();
/* V-Pot messages are Controller */
p->controller.connect_same_thread (*this, boost::bind (&MackiePort::handle_midi_controller_message, this, _1, _2));
/* Button messages are NoteOn */
p->controller.connect_same_thread (*this, boost::bind (&MackiePort::handle_midi_note_on_message, this, _1, _2));
/* Fader messages are Pitchbend */
p->channel_pitchbend[0].connect_same_thread (*this, boost::bind (&MackiePort::handle_midi_pitchbend_message, this, _1, _2, 0U));
p->channel_pitchbend[1].connect_same_thread (*this, boost::bind (&MackiePort::handle_midi_pitchbend_message, this, _1, _2, 1U));
p->channel_pitchbend[2].connect_same_thread (*this, boost::bind (&MackiePort::handle_midi_pitchbend_message, this, _1, _2, 2U));
@ -340,54 +343,50 @@ MackiePort::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb,
}
}
void
MackiePort::handle_midi_note_on_message (MIDI::Parser &, MIDI::EventTwoBytes* ev)
{
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("MackiePort::handle_note_on %1 = %2\n", ev->note_number, ev->velocity));
Control* control = _mcp.surface().buttons[(8*number()) + ev->note_number];
if (control) {
ControlState control_state (ev->velocity == 0x7f ? press : release);
control->set_in_use (control_state.button_state == press);
control_event (*this, *control, control_state);
}
}
void
MackiePort::handle_midi_controller_message (MIDI::Parser &, MIDI::EventTwoBytes* ev)
{
DEBUG_TRACE (DEBUG::MackieControl, string_compose ("MackiePort::handle_midi_controller %1 = %2\n", ev->controller_number, ev->value));
Control* control;
Control* control = _mcp.surface().pots[(8*number()) + ev->controller_number];
switch (ev->controller_number & 0xf0) {
case Control::type_button:
control = _mcp.surface().buttons[ev->controller_number];
if (control) {
control->set_in_use (true);
ControlState control_state (ev->value == 0x7f ? press : release);
control->set_in_use (control_state.button_state == press);
control_event (*this, *control, control_state);
}
if (control) {
ControlState state;
break;
case Control::type_pot:
control = _mcp.surface().pots[ev->controller_number];
if (control) {
ControlState state;
// bytes[2] & 0b01000000 (0x40) give sign
state.sign = (ev->value & 0x40) == 0 ? 1 : -1;
// bytes[2] & 0b00111111 (0x3f) gives delta
state.ticks = (ev->value & 0x3f);
if (state.ticks == 0) {
/* euphonix and perhaps other devices send zero
when they mean 1, we think.
*/
state.ticks = 1;
}
state.delta = float (state.ticks) / float (0x3f);
/* Pots only emit events when they move, not when they
stop moving. So to get a stop event, we need to use a timeout.
// bytes[2] & 0b01000000 (0x40) give sign
state.sign = (ev->value & 0x40) == 0 ? 1 : -1;
// bytes[2] & 0b00111111 (0x3f) gives delta
state.ticks = (ev->value & 0x3f);
if (state.ticks == 0) {
/* euphonix and perhaps other devices send zero
when they mean 1, we think.
*/
control->set_in_use (true);
_mcp.add_in_use_timeout (*this, *control, control);
control_event (*this, *control, state);
state.ticks = 1;
}
break;
default:
break;
state.delta = float (state.ticks) / float (0x3f);
/* Pots only emit events when they move, not when they
stop moving. So to get a stop event, we need to use a timeout.
*/
control->set_in_use (true);
_mcp.add_in_use_timeout (*this, *control, control);
control_event (*this, *control, state);
}
}

View File

@ -56,6 +56,7 @@ public:
void handle_midi_sysex( MIDI::Parser &, MIDI::byte *, size_t count );
void handle_midi_pitchbend_message (MIDI::Parser &, MIDI::pitchbend_t, uint32_t channel_id);
void handle_midi_controller_message (MIDI::Parser &, MIDI::EventTwoBytes*);
void handle_midi_note_on_message (MIDI::Parser &, MIDI::EventTwoBytes*);
/// return the number of strips associated with this port
virtual int strips() const;

View File

@ -71,33 +71,34 @@ void RouteSignal::connect()
// RemoteControlIDChanged. Better handled at Session level.
}
void RouteSignal::disconnect()
void
RouteSignal::disconnect()
{
connections.drop_connections ();
}
void RouteSignal::notify_all()
void
RouteSignal::notify_all()
{
#ifdef DEBUG
cout << "RouteSignal::notify_all for " << _strip << endl;
#endif
if ( _strip.has_solo() )
_mcp.notify_solo_changed( this );
if (_strip.has_solo()) {
_mcp.notify_solo_changed (this);
}
if ( _strip.has_mute() )
_mcp.notify_mute_changed( this );
if (_strip.has_mute()) {
_mcp.notify_mute_changed (this);
}
if ( _strip.has_gain() )
_mcp.notify_gain_changed( this );
if (_strip.has_gain()) {
_mcp.notify_gain_changed (this);
}
_mcp.notify_property_changed (PBD::PropertyChange (ARDOUR::Properties::name), this );
_mcp.notify_property_changed (PBD::PropertyChange (ARDOUR::Properties::name), this);
if ( _strip.has_vpot() )
_mcp.notify_panner_changed( this );
if (_strip.has_vpot()) {
_mcp.notify_panner_changed (this);
}
if ( _strip.has_recenable() )
_mcp.notify_record_enable_changed( this );
#ifdef DEBUG
cout << "RouteSignal::notify_all finish" << endl;
#endif
if (_strip.has_recenable()) {
_mcp.notify_record_enable_changed (this);
}
}