X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fevent_type_map.cc;h=28f688df8124a0f656decbfb853c1a403987e60b;hb=4bdbe77414b956e27f2c1631e67189c70409a3d1;hp=cc15d72356689b344cd74e8688e0b87f90c0ddcc;hpb=358ebde106dce1bc67ef86fabbd096e4e01b40cb;p=ardour.git diff --git a/libs/ardour/event_type_map.cc b/libs/ardour/event_type_map.cc index cc15d72356..28f688df81 100644 --- a/libs/ardour/event_type_map.cc +++ b/libs/ardour/event_type_map.cc @@ -22,11 +22,12 @@ #include #include "ardour/types.h" #include "ardour/event_type_map.h" +#include "ardour/parameter_descriptor.h" #include "ardour/parameter_types.h" #include "ardour/uri_map.h" #include "evoral/Parameter.hpp" +#include "evoral/ParameterDescriptor.hpp" #include "evoral/midi_events.h" -#include "evoral/MIDIParameters.hpp" #include "pbd/error.h" #include "pbd/compose.h" @@ -40,26 +41,11 @@ EventTypeMap& EventTypeMap::instance() { if (!EventTypeMap::event_type_map) { - EventTypeMap::event_type_map = new EventTypeMap(URIMap::instance()); - - // Initialize parameter metadata - EventTypeMap::event_type_map->new_parameter(NullAutomation); - EventTypeMap::event_type_map->new_parameter(GainAutomation); - EventTypeMap::event_type_map->new_parameter(PanAzimuthAutomation); - EventTypeMap::event_type_map->new_parameter(PanElevationAutomation); - EventTypeMap::event_type_map->new_parameter(PanWidthAutomation); - EventTypeMap::event_type_map->new_parameter(PluginAutomation); - EventTypeMap::event_type_map->new_parameter(PluginPropertyAutomation); - EventTypeMap::event_type_map->new_parameter(SoloAutomation); - EventTypeMap::event_type_map->new_parameter(MuteAutomation); - EventTypeMap::event_type_map->new_parameter(MidiCCAutomation); - EventTypeMap::event_type_map->new_parameter(MidiPgmChangeAutomation); - EventTypeMap::event_type_map->new_parameter(MidiPitchBenderAutomation); - EventTypeMap::event_type_map->new_parameter(MidiChannelPressureAutomation); - EventTypeMap::event_type_map->new_parameter(FadeInAutomation); - EventTypeMap::event_type_map->new_parameter(FadeOutAutomation); - EventTypeMap::event_type_map->new_parameter(EnvelopeAutomation); - EventTypeMap::event_type_map->new_parameter(MidiCCAutomation); +#ifdef LV2_SUPPORT + EventTypeMap::event_type_map = new EventTypeMap(&URIMap::instance()); +#else + EventTypeMap::event_type_map = new EventTypeMap(NULL); +#endif } return *EventTypeMap::event_type_map; } @@ -70,12 +56,6 @@ EventTypeMap::type_is_midi(uint32_t type) const return ARDOUR::parameter_is_midi((AutomationType)type); } -bool -EventTypeMap::is_midi_parameter(const Evoral::Parameter& param) -{ - return type_is_midi(param.type()); -} - uint8_t EventTypeMap::parameter_midi_type(const Evoral::Parameter& param) const { @@ -88,13 +68,6 @@ EventTypeMap::midi_event_type(uint8_t status) const return (uint32_t)ARDOUR::midi_parameter_type(status); } -bool -EventTypeMap::is_integer(const Evoral::Parameter& param) const -{ - return ( param.type() >= MidiCCAutomation - && param.type() <= MidiChannelPressureAutomation); -} - Evoral::ControlList::InterpolationStyle EventTypeMap::interpolation_of(const Evoral::Parameter& param) { @@ -148,70 +121,8 @@ EventTypeMap::interpolation_of(const Evoral::Parameter& param) return Evoral::ControlList::Linear; // Not reached, suppress warnings } - -Evoral::Parameter -EventTypeMap::new_parameter(uint32_t type, uint8_t channel, uint32_t id) const -{ - Evoral::Parameter p(type, channel, id); - - double min = 0.0f; - double max = 1.0f; - double normal = 0.0f; - bool toggled = false; - - switch((AutomationType)type) { - case NullAutomation: - case GainAutomation: - max = 2.0f; - normal = 1.0f; - 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 RecEnableAutomation: - /* default 0.0 - 1.0 is fine */ - toggled = true; - break; - case PluginAutomation: - case FadeInAutomation: - case FadeOutAutomation: - case EnvelopeAutomation: - max = 2.0f; - normal = 1.0f; - break; - case SoloAutomation: - case MuteAutomation: - max = 1.0f; - normal = 0.0f; - toggled = true; - break; - case MidiCCAutomation: - case MidiPgmChangeAutomation: - case MidiChannelPressureAutomation: - Evoral::MIDI::controller_range(min, max, normal); break; - case MidiPitchBenderAutomation: - Evoral::MIDI::bender_range(min, max, normal); break; - case MidiSystemExclusiveAutomation: - return p; - case PluginPropertyAutomation: - return p; - } - - p.set_range(type, min, max, normal, toggled); - return p; -} - Evoral::Parameter -EventTypeMap::new_parameter(const string& str) const +EventTypeMap::from_symbol(const string& str) const { AutomationType p_type = NullAutomation; uint8_t p_channel = 0; @@ -219,6 +130,8 @@ EventTypeMap::new_parameter(const string& str) const if (str == "gain") { p_type = GainAutomation; + } else if (str == "trim") { + p_type = TrimAutomation; } else if (str == "solo") { p_type = SoloAutomation; } else if (str == "mute") { @@ -242,14 +155,16 @@ EventTypeMap::new_parameter(const string& str) const } else if (str.length() > 10 && str.substr(0, 10) == "parameter-") { p_type = PluginAutomation; p_id = atoi(str.c_str()+10); +#ifdef LV2_SUPPORT } else if (str.length() > 9 && str.substr(0, 9) == "property-") { p_type = PluginPropertyAutomation; const char* name = str.c_str() + 9; if (isdigit(str.c_str()[0])) { p_id = atoi(name); } else { - p_id = _uri_map.uri_to_id(name); + p_id = _uri_map->uri_to_id(name); } +#endif } else if (str.length() > 7 && str.substr(0, 7) == "midicc-") { p_type = MidiCCAutomation; uint32_t channel = 0; @@ -280,8 +195,8 @@ EventTypeMap::new_parameter(const string& str) const } else { PBD::warning << "Unknown Parameter '" << str << "'" << endmsg; } - - return new_parameter(p_type, p_channel, p_id); + + return Evoral::Parameter(p_type, p_channel, p_id); } /** Unique string representation, suitable as an XML property value. @@ -294,6 +209,8 @@ EventTypeMap::to_symbol(const Evoral::Parameter& param) const if (t == GainAutomation) { return "gain"; + } else if (t == TrimAutomation) { + return "trim"; } else if (t == PanAzimuthAutomation) { return "pan-azimuth"; } else if (t == PanElevationAutomation) { @@ -316,13 +233,15 @@ EventTypeMap::to_symbol(const Evoral::Parameter& param) const return "envelope"; } else if (t == PluginAutomation) { return string_compose("parameter-%1", param.id()); +#ifdef LV2_SUPPORT } else if (t == PluginPropertyAutomation) { - const char* uri = _uri_map.id_to_uri(param.id()); + const char* uri = _uri_map->id_to_uri(param.id()); if (uri) { return string_compose("property-%1", uri); } else { return string_compose("property-%1", param.id()); } +#endif } else if (t == MidiCCAutomation) { return string_compose("midicc-%1-%2", int(param.channel()), param.id()); } else if (t == MidiPgmChangeAutomation) { @@ -337,5 +256,25 @@ EventTypeMap::to_symbol(const Evoral::Parameter& param) const } } +Evoral::ParameterDescriptor +EventTypeMap::descriptor(const Evoral::Parameter& param) const +{ + // Found an existing (perhaps custom) descriptor + Descriptors::const_iterator d = _descriptors.find(param); + if (d != _descriptors.end()) { + return d->second; + } + + // Add default descriptor and return that + return ARDOUR::ParameterDescriptor(param); +} + +void +EventTypeMap::set_descriptor(const Evoral::Parameter& param, + const Evoral::ParameterDescriptor& desc) +{ + _descriptors.insert(std::make_pair(param, desc)); +} + } // namespace ARDOUR