From 895b9c20518141510ec0192f603913475fae6493 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 15 Apr 2020 15:31:59 +0200 Subject: [PATCH] Fix PolyKeyPressure, consolidate AutomationType checks --- libs/ardour/ardour/parameter_types.h | 15 +++++++++++---- libs/ardour/automatable.cc | 2 +- libs/ardour/parameter_descriptor.cc | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/libs/ardour/ardour/parameter_types.h b/libs/ardour/ardour/parameter_types.h index ac82dca0ad..5893956818 100644 --- a/libs/ardour/ardour/parameter_types.h +++ b/libs/ardour/ardour/parameter_types.h @@ -34,7 +34,7 @@ parameter_midi_type(AutomationType type) case MidiCCAutomation: return MIDI_CMD_CONTROL; break; case MidiPgmChangeAutomation: return MIDI_CMD_PGM_CHANGE; break; case MidiChannelPressureAutomation: return MIDI_CMD_CHANNEL_PRESSURE; break; - case MidiNotePressureAutomation: return MIDI_CMD_NOTE_PRESSURE; break; + case MidiNotePressureAutomation: return MIDI_CMD_NOTE_PRESSURE; break; case MidiPitchBenderAutomation: return MIDI_CMD_BENDER; break; case MidiSystemExclusiveAutomation: return MIDI_CMD_COMMON_SYSEX; break; default: return 0; @@ -48,7 +48,7 @@ midi_parameter_type(uint8_t status) case MIDI_CMD_CONTROL: return MidiCCAutomation; break; case MIDI_CMD_PGM_CHANGE: return MidiPgmChangeAutomation; break; case MIDI_CMD_CHANNEL_PRESSURE: return MidiChannelPressureAutomation; break; - case MIDI_CMD_NOTE_PRESSURE: return MidiNotePressureAutomation; break; + case MIDI_CMD_NOTE_PRESSURE: return MidiNotePressureAutomation; break; case MIDI_CMD_BENDER: return MidiPitchBenderAutomation; break; case MIDI_CMD_COMMON_SYSEX: return MidiSystemExclusiveAutomation; break; default: return NullAutomation; @@ -67,7 +67,7 @@ midi_parameter(const uint8_t* buf, const uint32_t len) case MidiChannelPressureAutomation: return Evoral::Parameter(MidiChannelPressureAutomation, channel); case MidiNotePressureAutomation: - return Evoral::Parameter(MidiChannelPressureAutomation, channel); + return Evoral::Parameter(MidiNotePressureAutomation, channel); case MidiPitchBenderAutomation: return Evoral::Parameter(MidiPitchBenderAutomation, channel); case MidiSystemExclusiveAutomation: @@ -80,7 +80,14 @@ midi_parameter(const uint8_t* buf, const uint32_t len) inline bool parameter_is_midi(AutomationType type) { - return (type >= MidiCCAutomation) && (type <= MidiChannelPressureAutomation); + return (type >= MidiCCAutomation) && (type <= MidiNotePressureAutomation); +} + +inline bool +parameter_is_midi(Evoral::ParameterType t) +{ + AutomationType type = (AutomationType) t; + return (type >= MidiCCAutomation) && (type <= MidiNotePressureAutomation); } } // namespace ARDOUR diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc index 1ff86e2ef4..16832b8af1 100644 --- a/libs/ardour/automatable.cc +++ b/libs/ardour/automatable.cc @@ -521,7 +521,7 @@ Automatable::control_factory(const Evoral::Parameter& param) ParameterDescriptor desc(param); boost::shared_ptr list; - if (param.type() >= MidiCCAutomation && param.type() <= MidiChannelPressureAutomation) { + if (parameter_is_midi (param.type())) { MidiTrack* mt = dynamic_cast(this); if (mt) { control = new MidiTrack::MidiControl(mt, param); diff --git a/libs/ardour/parameter_descriptor.cc b/libs/ardour/parameter_descriptor.cc index 0559927d21..05e5bfbca9 100644 --- a/libs/ardour/parameter_descriptor.cc +++ b/libs/ardour/parameter_descriptor.cc @@ -26,6 +26,7 @@ #include "ardour/amp.h" #include "ardour/dB.h" #include "ardour/parameter_descriptor.h" +#include "ardour/parameter_types.h" #include "ardour/rc_configuration.h" #include "ardour/types.h" #include "ardour/utils.h" @@ -43,8 +44,7 @@ ParameterDescriptor::ParameterDescriptor(const Evoral::Parameter& parameter) , step(0) , smallstep(0) , largestep(0) - , integer_step(parameter.type() >= MidiCCAutomation && - parameter.type() <= MidiChannelPressureAutomation) + , integer_step(parameter_is_midi (parameter.type ())) , sr_dependent(false) , enumeration(false) {