X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fevent_type_map.cc;h=c8c48c5b8674550d8ab2eb9fb7f2a3f66dfb8405;hb=2b3adfb18f0c2befb39b8b56d3e3f07833cc7b33;hp=3f36aa6632eba6fc76a659d4451135fb27aa7323;hpb=3d594b460b1d0fdbc6799ded15201174d9a2c03c;p=ardour.git diff --git a/libs/ardour/event_type_map.cc b/libs/ardour/event_type_map.cc index 3f36aa6632..c8c48c5b86 100644 --- a/libs/ardour/event_type_map.cc +++ b/libs/ardour/event_type_map.cc @@ -18,13 +18,14 @@ */ -#include -#include -#include -#include -#include -#include -#include +#include +#include "ardour/types.h" +#include "ardour/event_type_map.h" +#include "evoral/Parameter.hpp" +#include "evoral/midi_events.h" +#include "evoral/MIDIParameters.hpp" +#include "pbd/error.h" +#include "pbd/compose.h" using namespace std; @@ -48,10 +49,10 @@ uint8_t EventTypeMap::parameter_midi_type(const Evoral::Parameter& param) const { switch (param.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 MidiPitchBenderAutomation: return MIDI_CMD_BENDER; break; + case MidiCCAutomation: return MIDI_CMD_CONTROL; break; + case MidiPgmChangeAutomation: return MIDI_CMD_PGM_CHANGE; break; + case MidiChannelPressureAutomation: return MIDI_CMD_CHANNEL_PRESSURE; break; + case MidiPitchBenderAutomation: return MIDI_CMD_BENDER; break; case MidiSystemExclusiveAutomation: return MIDI_CMD_COMMON_SYSEX; break; default: return 0; } @@ -77,11 +78,11 @@ EventTypeMap::is_integer(const Evoral::Parameter& param) const && param.type() <= MidiChannelPressureAutomation); } -Evoral::ControlList::InterpolationStyle +Evoral::ControlList::InterpolationStyle EventTypeMap::interpolation_of(const Evoral::Parameter& param) { switch (param.type()) { - case MidiCCAutomation: + case MidiCCAutomation: switch (param.id()) { case MIDI_CTL_LSB_BANK: case MIDI_CTL_MSB_BANK: @@ -117,20 +118,17 @@ EventTypeMap::interpolation_of(const Evoral::Parameter& param) case MIDI_CTL_OMNI_ON: case MIDI_CTL_MONO: case MIDI_CTL_POLY: - - return Evoral::ControlList::Discrete; - break; - - default: return Evoral::ControlList::Linear; break; + return Evoral::ControlList::Discrete; break; + default: + return Evoral::ControlList::Linear; break; } - - break; - - case MidiPgmChangeAutomation: return Evoral::ControlList::Discrete; break; - case MidiChannelPressureAutomation: return Evoral::ControlList::Linear; break; - case MidiPitchBenderAutomation: return Evoral::ControlList::Linear; break; + break; + case MidiPgmChangeAutomation: return Evoral::ControlList::Discrete; break; + case MidiChannelPressureAutomation: return Evoral::ControlList::Linear; break; + case MidiPitchBenderAutomation: return Evoral::ControlList::Linear; break; default: assert(false); } + return Evoral::ControlList::Linear; // Not reached, suppress warnings } @@ -142,15 +140,25 @@ EventTypeMap::new_parameter(uint32_t type, uint8_t channel, uint32_t id) const double min = 0.0f; double max = 1.0f; double normal = 0.0f; + switch((AutomationType)type) { case NullAutomation: case GainAutomation: max = 2.0f; normal = 1.0f; break; - case PanAutomation: - normal = 0.5f; - break; + case PanAzimuthAutomation: + normal = 0.5f; // there really is no normal but this works for stereo, sort of + break; + case PanWidthAutomation: + min = -1.0; + max = 1.0; + normal = 0.0f; + break; + case PanElevationAutomation: + case PanFrontBackAutomation: + case PanLFEAutomation: + break; case PluginAutomation: case SoloAutomation: case MuteAutomation: @@ -166,9 +174,11 @@ EventTypeMap::new_parameter(uint32_t type, uint8_t channel, uint32_t id) const Evoral::MIDI::controller_range(min, max, normal); break; case MidiPitchBenderAutomation: Evoral::MIDI::bender_range(min, max, normal); break; + case MidiSystemExclusiveAutomation: + return p; } - - p.set_range(type, min, max, normal); + + p.set_range(type, min, max, normal, false); return p; } @@ -191,11 +201,16 @@ EventTypeMap::new_parameter(const string& str) const p_type = FadeOutAutomation; } else if (str == "envelope") { p_type = EnvelopeAutomation; - } else if (str == "pan") { - p_type = PanAutomation; - } else if (str.length() > 4 && str.substr(0, 4) == "pan-") { - p_type = PanAutomation; - p_id = atoi(str.c_str()+4); + } else if (str == "pan-azimuth") { + p_type = PanAzimuthAutomation; + } else if (str == "pan-width") { + p_type = PanWidthAutomation; + } else if (str == "pan-elevation") { + p_type = PanElevationAutomation; + } else if (str == "pan-frontback") { + p_type = PanFrontBackAutomation; + } else if (str == "pan-lfe") { + p_type = PanLFEAutomation; } else if (str.length() > 10 && str.substr(0, 10) == "parameter-") { p_type = PluginAutomation; p_id = atoi(str.c_str()+10); @@ -219,7 +234,7 @@ EventTypeMap::new_parameter(const string& str) const assert(channel < 16); p_id = 0; p_channel = channel; - } else if (str.length() > 24 && str.substr(0, 24) == "midi-channel-pressure-") { + } else if (str.length() > 22 && str.substr(0, 22) == "midi-channel-pressure-") { p_type = MidiChannelPressureAutomation; uint32_t channel = 0; sscanf(str.c_str(), "midi-channel-pressure-%d", &channel); @@ -243,8 +258,16 @@ EventTypeMap::to_symbol(const Evoral::Parameter& param) const if (t == GainAutomation) { return "gain"; - } else if (t == PanAutomation) { - return string_compose("pan-%1", param.id()); + } else if (t == PanAzimuthAutomation) { + return "pan-azimuth"; + } else if (t == PanElevationAutomation) { + return "pan-elevation"; + } else if (t == PanWidthAutomation) { + return "pan-width"; + } else if (t == PanFrontBackAutomation) { + return "pan-frontback"; + } else if (t == PanLFEAutomation) { + return "pan-lfe"; } else if (t == SoloAutomation) { return "solo"; } else if (t == MuteAutomation) {