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:
parent
7296ef87a1
commit
c6c98b6453
@ -272,8 +272,11 @@ void MackiePort::connect_to_signals ()
|
|||||||
|
|
||||||
MIDI::Parser* p = input_port().parser();
|
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));
|
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[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[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));
|
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
|
void
|
||||||
MackiePort::handle_midi_controller_message (MIDI::Parser &, MIDI::EventTwoBytes* ev)
|
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));
|
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) {
|
if (control) {
|
||||||
case Control::type_button:
|
ControlState state;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
// bytes[2] & 0b01000000 (0x40) give sign
|
||||||
|
state.sign = (ev->value & 0x40) == 0 ? 1 : -1;
|
||||||
case Control::type_pot:
|
// bytes[2] & 0b00111111 (0x3f) gives delta
|
||||||
control = _mcp.surface().pots[ev->controller_number];
|
state.ticks = (ev->value & 0x3f);
|
||||||
if (control) {
|
if (state.ticks == 0) {
|
||||||
ControlState state;
|
/* euphonix and perhaps other devices send zero
|
||||||
|
when they mean 1, we think.
|
||||||
// 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.
|
|
||||||
*/
|
*/
|
||||||
|
state.ticks = 1;
|
||||||
control->set_in_use (true);
|
|
||||||
_mcp.add_in_use_timeout (*this, *control, control);
|
|
||||||
control_event (*this, *control, state);
|
|
||||||
}
|
}
|
||||||
break;
|
state.delta = float (state.ticks) / float (0x3f);
|
||||||
|
|
||||||
default:
|
/* Pots only emit events when they move, not when they
|
||||||
break;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ public:
|
|||||||
void handle_midi_sysex( MIDI::Parser &, MIDI::byte *, size_t count );
|
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_pitchbend_message (MIDI::Parser &, MIDI::pitchbend_t, uint32_t channel_id);
|
||||||
void handle_midi_controller_message (MIDI::Parser &, MIDI::EventTwoBytes*);
|
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
|
/// return the number of strips associated with this port
|
||||||
virtual int strips() const;
|
virtual int strips() const;
|
||||||
|
@ -71,33 +71,34 @@ void RouteSignal::connect()
|
|||||||
// RemoteControlIDChanged. Better handled at Session level.
|
// RemoteControlIDChanged. Better handled at Session level.
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteSignal::disconnect()
|
void
|
||||||
|
RouteSignal::disconnect()
|
||||||
{
|
{
|
||||||
connections.drop_connections ();
|
connections.drop_connections ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteSignal::notify_all()
|
void
|
||||||
|
RouteSignal::notify_all()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
if (_strip.has_solo()) {
|
||||||
cout << "RouteSignal::notify_all for " << _strip << endl;
|
_mcp.notify_solo_changed (this);
|
||||||
#endif
|
}
|
||||||
if ( _strip.has_solo() )
|
|
||||||
_mcp.notify_solo_changed( this );
|
|
||||||
|
|
||||||
if ( _strip.has_mute() )
|
if (_strip.has_mute()) {
|
||||||
_mcp.notify_mute_changed( this );
|
_mcp.notify_mute_changed (this);
|
||||||
|
}
|
||||||
|
|
||||||
if ( _strip.has_gain() )
|
if (_strip.has_gain()) {
|
||||||
_mcp.notify_gain_changed( this );
|
_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() )
|
if (_strip.has_vpot()) {
|
||||||
_mcp.notify_panner_changed( this );
|
_mcp.notify_panner_changed (this);
|
||||||
|
}
|
||||||
|
|
||||||
if ( _strip.has_recenable() )
|
if (_strip.has_recenable()) {
|
||||||
_mcp.notify_record_enable_changed( this );
|
_mcp.notify_record_enable_changed (this);
|
||||||
#ifdef DEBUG
|
}
|
||||||
cout << "RouteSignal::notify_all finish" << endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user