From 2939ed3164c4882dd9dcdd6482a59b374762cdb8 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 11 Oct 2022 02:38:47 +0200 Subject: [PATCH] Add dedicated InsertReturnLevel type This is preparation for PortInsert Send and Return level control. --- libs/ardour/ardour/types.h | 1 + libs/ardour/ardour/value_as_string.h | 2 +- libs/ardour/automatable.cc | 4 ++++ libs/ardour/automation_list.cc | 2 ++ libs/ardour/enums.cc | 1 + libs/ardour/event_type_map.cc | 4 ++++ libs/ardour/gain_control.cc | 4 ++++ libs/ardour/luabindings.cc | 1 + libs/ardour/parameter_descriptor.cc | 8 +++++++- libs/surfaces/mackie/strip.cc | 1 + libs/surfaces/maschine2/ui_knob.cc | 1 + libs/surfaces/push2/knob.cc | 1 + 12 files changed, 28 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index d1c39516d2..6f3ac5eefb 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -170,6 +170,7 @@ enum AutomationType { MonitoringAutomation, BusSendLevel, BusSendEnable, + InsertReturnLevel, MainOutVolume, /* used only by Controllable Descriptor to access send parameters */ diff --git a/libs/ardour/ardour/value_as_string.h b/libs/ardour/ardour/value_as_string.h index 84dfeb1cdf..f8430f6231 100644 --- a/libs/ardour/ardour/value_as_string.h +++ b/libs/ardour/ardour/value_as_string.h @@ -53,7 +53,7 @@ value_as_string(const ARDOUR::ParameterDescriptor& desc, // Value is not a scale point, print it normally if (desc.unit == ARDOUR::ParameterDescriptor::MIDI_NOTE) { snprintf(buf, sizeof(buf), "%s", ParameterDescriptor::midi_note_name (rint(v)).c_str()); - } else if (desc.type == GainAutomation || desc.type == BusSendLevel || desc.type == TrimAutomation || desc.type == EnvelopeAutomation || desc.type == MainOutVolume) { + } else if (desc.type == GainAutomation || desc.type == BusSendLevel || desc.type == TrimAutomation || desc.type == EnvelopeAutomation || desc.type == MainOutVolume || desc.type == InsertReturnLevel) { #ifdef PLATFORM_WINDOWS if (v < GAIN_COEFF_SMALL) { snprintf(buf, sizeof(buf), "-inf dB"); diff --git a/libs/ardour/automatable.cc b/libs/ardour/automatable.cc index 866df29b85..3dba0f998a 100644 --- a/libs/ardour/automatable.cc +++ b/libs/ardour/automatable.cc @@ -193,6 +193,8 @@ Automatable::describe_parameter (Evoral::Parameter param) return _("Fader"); } else if (param.type() == BusSendLevel) { return _("Send"); + } else if (param.type() == InsertReturnLevel) { + return _("Return"); } else if (param.type() == TrimAutomation) { return _("Trim"); } else if (param.type() == MainOutVolume) { @@ -561,6 +563,8 @@ Automatable::control_factory(const Evoral::Parameter& param) control = new GainControl(_a_session, param); } else if (param.type() == TrimAutomation) { control = new GainControl(_a_session, param); + } else if (param.type() == InsertReturnLevel) { + control = new GainControl(_a_session, param); } else if (param.type() == MainOutVolume) { control = new GainControl(_a_session, param); } else if (param.type() == BusSendLevel) { diff --git a/libs/ardour/automation_list.cc b/libs/ardour/automation_list.cc index 891a238b55..00bf7f8c3b 100644 --- a/libs/ardour/automation_list.cc +++ b/libs/ardour/automation_list.cc @@ -158,6 +158,7 @@ AutomationList::create_curve_if_necessary() switch (_parameter.type()) { case GainAutomation: case BusSendLevel: + case InsertReturnLevel: case TrimAutomation: case PanAzimuthAutomation: case PanElevationAutomation: @@ -232,6 +233,7 @@ AutomationList::default_interpolation () const switch (_parameter.type()) { case GainAutomation: case BusSendLevel: + case InsertReturnLevel: case EnvelopeAutomation: return ControlList::Exponential; break; diff --git a/libs/ardour/enums.cc b/libs/ardour/enums.cc index 853cfe8608..414583a562 100644 --- a/libs/ardour/enums.cc +++ b/libs/ardour/enums.cc @@ -204,6 +204,7 @@ setup_enum_writer () REGISTER_ENUM (MonitoringAutomation); REGISTER_ENUM (BusSendLevel); REGISTER_ENUM (BusSendEnable); + REGISTER_ENUM (InsertReturnLevel); REGISTER_ENUM (MainOutVolume); REGISTER (_AutomationType); diff --git a/libs/ardour/event_type_map.cc b/libs/ardour/event_type_map.cc index 57b9205348..1d2a2130a5 100644 --- a/libs/ardour/event_type_map.cc +++ b/libs/ardour/event_type_map.cc @@ -131,6 +131,8 @@ EventTypeMap::from_symbol(const string& str) const p_type = GainAutomation; } else if (str == "send") { p_type = BusSendLevel; + } else if (str == "return") { + p_type = InsertReturnLevel; } else if (str == "trim") { p_type = TrimAutomation; } else if (str == "main-out-volume") { @@ -233,6 +235,8 @@ EventTypeMap::to_symbol(const Evoral::Parameter& param) const return "gain"; } else if (t == BusSendLevel) { return "send"; + } else if (t == InsertReturnLevel) { + return "return"; } else if (t == TrimAutomation) { return "trim"; } else if (t == MainOutVolume) { diff --git a/libs/ardour/gain_control.cc b/libs/ardour/gain_control.cc index 807170fd97..7aa946eb83 100644 --- a/libs/ardour/gain_control.cc +++ b/libs/ardour/gain_control.cc @@ -41,6 +41,8 @@ static std::string gain_control_name (Evoral::Parameter const& param) case GainAutomation: /* fallthrough */ case BusSendLevel: + /* fallthrough */ + case InsertReturnLevel: return X_("gaincontrol"); case TrimAutomation: return X_("trimcontrol"); @@ -62,6 +64,8 @@ static boost::shared_ptr automation_list_new (Evoral::Parameter /* fallthrough */ case BusSendLevel: /* fallthrough */ + case InsertReturnLevel: + /* fallthrough */ case TrimAutomation: return boost::shared_ptr (new AutomationList (param, Temporal::AudioTime)); case MainOutVolume: diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index e432cd4e0a..9fa7f8b994 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -2270,6 +2270,7 @@ LuaBindings::common (lua_State* L) .beginNamespace ("AutomationType") .addConst ("GainAutomation", ARDOUR::AutomationType(GainAutomation)) .addConst ("BusSendLevel", ARDOUR::AutomationType(BusSendLevel)) + .addConst ("InsertReturnLevel", ARDOUR::AutomationType(InsertReturnLevel)) .addConst ("PluginAutomation", ARDOUR::AutomationType(PluginAutomation)) .addConst ("SoloAutomation", ARDOUR::AutomationType(SoloAutomation)) .addConst ("SoloIsolateAutomation", ARDOUR::AutomationType(SoloIsolateAutomation)) diff --git a/libs/ardour/parameter_descriptor.cc b/libs/ardour/parameter_descriptor.cc index 17dbde3d3b..1eac7ab33f 100644 --- a/libs/ardour/parameter_descriptor.cc +++ b/libs/ardour/parameter_descriptor.cc @@ -56,6 +56,8 @@ ParameterDescriptor::ParameterDescriptor(const Evoral::Parameter& parameter) switch((AutomationType)parameter.type()) { case BusSendLevel: + /* fallthrough */ + case InsertReturnLevel: inline_ctrl = true; /* fallthrough */ case GainAutomation: @@ -207,7 +209,7 @@ ParameterDescriptor::update_steps() if (unit == ParameterDescriptor::MIDI_NOTE) { step = smallstep = 1; // semitone largestep = 12; // octave - } else if (type == GainAutomation || type == TrimAutomation || type == BusSendLevel || type == MainOutVolume) { + } else if (type == GainAutomation || type == TrimAutomation || type == BusSendLevel || type == MainOutVolume || type == InsertReturnLevel) { /* dB_coeff_step gives a step normalized for [0, max_gain]. This is like "slider position", so we convert from "slider position" to gain to have the correct unit here. */ @@ -326,6 +328,8 @@ ParameterDescriptor::to_interface (float val, bool rotary) const /* fallthrough */ case BusSendLevel: /* fallthrough */ + case InsertReturnLevel: + /* fallthrough */ case EnvelopeAutomation: val = gain_to_slider_position_with_max (val, upper); break; @@ -384,6 +388,7 @@ ParameterDescriptor::from_interface (float val, bool rotary) const case GainAutomation: case EnvelopeAutomation: case BusSendLevel: + case InsertReturnLevel: val = slider_position_to_gain_with_max (val, upper); break; case TrimAutomation: @@ -443,6 +448,7 @@ ParameterDescriptor::is_linear () const case GainAutomation: case EnvelopeAutomation: case BusSendLevel: + case InsertReturnLevel: return false; default: break; diff --git a/libs/surfaces/mackie/strip.cc b/libs/surfaces/mackie/strip.cc index 360e5b9d94..656c318b75 100644 --- a/libs/surfaces/mackie/strip.cc +++ b/libs/surfaces/mackie/strip.cc @@ -715,6 +715,7 @@ Strip::format_parameter_for_display( case GainAutomation: case BusSendLevel: case TrimAutomation: + case InsertReturnLevel: // we can't use value_as_string() that'll suffix "dB" and also use "-inf" w/o space :( if (val == 0.0) { formatted_parameter_display = " -inf "; diff --git a/libs/surfaces/maschine2/ui_knob.cc b/libs/surfaces/maschine2/ui_knob.cc index 75390285a7..92c2905249 100644 --- a/libs/surfaces/maschine2/ui_knob.cc +++ b/libs/surfaces/maschine2/ui_knob.cc @@ -223,6 +223,7 @@ Maschine2Knob::controllable_changed () case ARDOUR::GainAutomation: case ARDOUR::BusSendLevel: + case ARDOUR::InsertReturnLevel: case ARDOUR::TrimAutomation: snprintf (buf, sizeof (buf), "%+4.1f dB", accurate_coefficient_to_dB (_controllable->get_value())); text->set (buf); diff --git a/libs/surfaces/push2/knob.cc b/libs/surfaces/push2/knob.cc index e898744d8c..868bc7cb51 100644 --- a/libs/surfaces/push2/knob.cc +++ b/libs/surfaces/push2/knob.cc @@ -326,6 +326,7 @@ Push2Knob::controllable_changed () case ARDOUR::GainAutomation: case ARDOUR::BusSendLevel: + case ARDOUR::InsertReturnLevel: case ARDOUR::TrimAutomation: set_gain_text (_val); break;