MIDI polyphonic pressure, part 2
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 18 Aug 2016 16:35:15 +0000 (12:35 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 19 Aug 2016 12:32:44 +0000 (08:32 -0400)
libs/ardour/ardour/parameter_types.h
libs/ardour/ardour/types.h
libs/ardour/automatable.cc
libs/ardour/enums.cc
libs/ardour/event_type_map.cc
libs/ardour/midi_track.cc
libs/ardour/parameter_descriptor.cc

index 240ad2d9565dadbd5a02abdc360aac9a3f82d787..151aacab6fe81b4ce543add784f8f1b4f52fcc8f 100644 (file)
@@ -36,6 +36,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 MidiPitchBenderAutomation:     return MIDI_CMD_BENDER;           break;
        case MidiSystemExclusiveAutomation: return MIDI_CMD_COMMON_SYSEX;     break;
        default: return 0;
@@ -49,6 +50,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_BENDER:           return MidiPitchBenderAutomation;     break;
        case MIDI_CMD_COMMON_SYSEX:     return MidiSystemExclusiveAutomation; break;
        default: return NullAutomation;
@@ -66,6 +68,8 @@ midi_parameter(const uint8_t* buf, const uint32_t len)
                return Evoral::Parameter(MidiPgmChangeAutomation, channel);
        case MidiChannelPressureAutomation:
                return Evoral::Parameter(MidiChannelPressureAutomation, channel);
+       case MidiNotePressureAutomation:
+               return Evoral::Parameter(MidiChannelPressureAutomation, channel);
        case MidiPitchBenderAutomation:
                return Evoral::Parameter(MidiPitchBenderAutomation, channel);
        case MidiSystemExclusiveAutomation:
index e818ea707ec9663240b8a808b3d8d6a6b2073b89..976c4924a794034dd1c143ba5aca9a12044db543 100644 (file)
@@ -146,6 +146,7 @@ namespace ARDOUR {
                MidiPgmChangeAutomation,
                MidiPitchBenderAutomation,
                MidiChannelPressureAutomation,
+               MidiNotePressureAutomation,
                MidiSystemExclusiveAutomation,
                FadeInAutomation,
                FadeOutAutomation,
index 10d2565c90c4be3ce7f96e965e42856cf59ac8f7..040dbefedcf2a4e36e78df8943d04583749b4da4 100644 (file)
@@ -186,6 +186,8 @@ Automatable::describe_parameter (Evoral::Parameter param)
                return string_compose("Bender [%1]", int(param.channel()) + 1);
        } else if (param.type() == MidiChannelPressureAutomation) {
                return string_compose("Pressure [%1]", int(param.channel()) + 1);
+       } else if (param.type() == MidiNotePressureAutomation) {
+               return string_compose("PolyPressure [%1]", int(param.channel()) + 1);
 #ifdef LV2_SUPPORT
        } else if (param.type() == PluginPropertyAutomation) {
                return string_compose("Property %1", URIMap::instance().id_to_uri(param.id()));
index 6e90bd01f0cb016b31dbd3df08a0e7c58b7fec80..be468c2534990f897b25e2b6f73bbf0abaf70801 100644 (file)
@@ -157,6 +157,7 @@ setup_enum_writer ()
        REGISTER_ENUM (MidiPgmChangeAutomation);
        REGISTER_ENUM (MidiPitchBenderAutomation);
        REGISTER_ENUM (MidiChannelPressureAutomation);
+       REGISTER_ENUM (MidiNotePressureAutomation);
        REGISTER_ENUM (MidiSystemExclusiveAutomation);
        REGISTER_ENUM (FadeInAutomation);
        REGISTER_ENUM (FadeOutAutomation);
index 28f688df8124a0f656decbfb853c1a403987e60b..0b62d4a54bb9c27e768fe6ca4c0c0aca571ee97b 100644 (file)
@@ -115,6 +115,7 @@ EventTypeMap::interpolation_of(const Evoral::Parameter& param)
                break;
        case MidiPgmChangeAutomation:       return Evoral::ControlList::Discrete; break;
        case MidiChannelPressureAutomation: return Evoral::ControlList::Linear; break;
+       case MidiNotePressureAutomation: return Evoral::ControlList::Linear; break;
        case MidiPitchBenderAutomation:     return Evoral::ControlList::Linear; break;
        default: assert(false);
        }
@@ -192,6 +193,13 @@ EventTypeMap::from_symbol(const string& str) const
                assert(channel < 16);
                p_id = 0;
                p_channel = channel;
+       } else if (str.length() > 19 && str.substr(0, 19) == "midi-note-pressure-") {
+               p_type = MidiNotePressureAutomation;
+               uint32_t channel = 0;
+               sscanf(str.c_str(), "midi-note-pressure-%d-%d", &channel, &p_id);
+               assert(channel < 16);
+               assert(p_id < 127);
+               p_channel = channel;
        } else {
                PBD::warning << "Unknown Parameter '" << str << "'" << endmsg;
        }
@@ -250,6 +258,8 @@ EventTypeMap::to_symbol(const Evoral::Parameter& param) const
                return string_compose("midi-pitch-bender-%1", int(param.channel()));
        } else if (t == MidiChannelPressureAutomation) {
                return string_compose("midi-channel-pressure-%1", int(param.channel()));
+       } else if (t == MidiChannelPressureAutomation) {
+               return string_compose("midi-note-pressure-%1-%2", int(param.channel()), param.id());
        } else {
                PBD::warning << "Uninitialized Parameter symbol() called." << endmsg;
                return "";
index b79a1cf52cd6b56f85e7d20650ae45b596dff29a..f1344e7697640eac1d85cf604d8ada3f00a7f584 100644 (file)
@@ -701,6 +701,7 @@ MidiTrack::set_parameter_automation_state (Evoral::Parameter param, AutoState st
        case MidiPgmChangeAutomation:
        case MidiPitchBenderAutomation:
        case MidiChannelPressureAutomation:
+       case MidiNotePressureAutomation:
        case MidiSystemExclusiveAutomation:
                /* The track control for MIDI parameters is for immediate events to act
                   as a control surface, write/touch for them is not currently
@@ -757,6 +758,12 @@ MidiTrack::MidiControl::actually_set_value (double val, PBD::Controllable::Group
                        ev[1] = int(val);
                        break;
 
+               case MidiNotePressureAutomation:
+                       ev[0] += MIDI_CMD_NOTE_PRESSURE;
+                       ev[1] = parameter.id();
+                       ev[2] = int(val);
+                       break;
+
                case MidiPitchBenderAutomation:
                        ev[0] += MIDI_CMD_BENDER;
                        ev[1] = 0x7F & int(val);
index bf0c9b7af153fc18c79c90371a1135100e7c7a3f..db567d46538dd117a37fc08d927882b116ac39a2 100644 (file)
@@ -96,6 +96,7 @@ ParameterDescriptor::ParameterDescriptor(const Evoral::Parameter& parameter)
        case MidiCCAutomation:
        case MidiPgmChangeAutomation:
        case MidiChannelPressureAutomation:
+       case MidiNotePressureAutomation:
                lower  = 0.0;
                normal = 0.0;
                upper  = 127.0;