From 356374bfb3599f7ce4e7929844e423e2cbe11a57 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 18 Jan 2024 00:14:07 +0100 Subject: [PATCH] Vapor: replace output format API with a controllable --- libs/ardour/ardour/surround_return.h | 24 +++++++++++++++++++++--- libs/ardour/surround_return.cc | 11 ++++++----- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/libs/ardour/ardour/surround_return.h b/libs/ardour/ardour/surround_return.h index 2e1f28c692..5d5e0f3ef8 100644 --- a/libs/ardour/ardour/surround_return.h +++ b/libs/ardour/ardour/surround_return.h @@ -30,6 +30,7 @@ #include "ardour/chan_mapping.h" #include "ardour/lufs_meter.h" +#include "ardour/monitor_processor.h" #include "ardour/processor.h" namespace ARDOUR @@ -69,8 +70,8 @@ public: return _current_output_format; } - void set_output_format (MainOutputFormat mov) { - _target_output_format = mov; + std::shared_ptr output_format_controllable () const { + return _output_format_control; } /* a value <= -200 indicates that no data is available */ @@ -98,12 +99,29 @@ private: std::shared_ptr _trim; + class OutputFormatControl : public MPControl + { + public: + OutputFormatControl (bool v, std::string const& n, PBD::Controllable::Flag f) + : MPControl (v, n, f) + {} + + virtual std::string get_user_string () const { + if (get_value () == 0) { + return "7.1.4"; + } else { + return "5.1"; + } + } + }; + + std::shared_ptr _output_format_control; + LV2_Atom_Forge _forge; uint8_t _atom_buf[8192]; pan_t _current_value[max_object_id][num_pan_parameters]; int _current_render_mode[max_object_id]; size_t _current_n_objects; - MainOutputFormat _target_output_format; MainOutputFormat _current_output_format; BufferSet _surround_bufs; ChanMapping _in_map; diff --git a/libs/ardour/surround_return.cc b/libs/ardour/surround_return.cc index fa5991da93..b975dad862 100644 --- a/libs/ardour/surround_return.cc +++ b/libs/ardour/surround_return.cc @@ -33,8 +33,8 @@ using namespace ARDOUR; SurroundReturn::SurroundReturn (Session& s, Route* r) : Processor (s, _("SurrReturn"), Temporal::TimeDomainProvider (Temporal::AudioTime)) , _lufs_meter (s.nominal_sample_rate (), 5) + , _output_format_control (new OutputFormatControl (false, _("Output Format"), PBD::Controllable::Toggle)) , _current_n_objects (max_object_id) - , _target_output_format (OUTPUT_FORMAT_7_1_4) , _current_output_format (OUTPUT_FORMAT_7_1_4) , _in_map (ChanCount (DataType::AUDIO, 128)) , _out_map (ChanCount (DataType::AUDIO, 14 + 6 /* Loudness Meter */)) @@ -204,11 +204,12 @@ SurroundReturn::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_ #endif } - if (_current_output_format != _target_output_format) { - _current_output_format = _target_output_format; + MainOutputFormat target_output_format = _output_format_control->get_value () == 0 ? OUTPUT_FORMAT_7_1_4 : OUTPUT_FORMAT_5_1; + if (_current_output_format != target_output_format) { + _current_output_format = target_output_format; #if defined(LV2_EXTENDED) && defined(HAVE_LV2_1_10_0) URIMap::URIDs const& urids = URIMap::instance ().urids; - forge_int_msg (urids.surr_Settings, urids.surr_OutputFormat, _target_output_format); + forge_int_msg (urids.surr_Settings, urids.surr_OutputFormat, target_output_format); #endif } @@ -399,7 +400,7 @@ SurroundReturn::set_state (XMLNode const& node, int version) int target_output_format; if (node.get_property (X_("output-format"), target_output_format)) { if (target_output_format == OUTPUT_FORMAT_5_1 || target_output_format == OUTPUT_FORMAT_7_1_4) { - _target_output_format = (MainOutputFormat) target_output_format; + _output_format_control->set_value (target_output_format == OUTPUT_FORMAT_7_1_4 ? 0.0 : 1.0, PBD::Controllable::NoGroup); } } return _trim->set_state (node, version);