From db7a67980d2a8c677ceae19c894c78db195cab6f Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 11 Jan 2024 05:16:21 +0100 Subject: [PATCH] Vapor: allow to toggle 5.1 and 7.1.4 main output --- libs/ardour/ardour/surround_return.h | 15 +++++++++++++++ libs/ardour/ardour/uri_map.h | 1 + libs/ardour/surround_return.cc | 17 +++++++++++++++++ libs/ardour/uri_map.cc | 1 + 4 files changed, 34 insertions(+) diff --git a/libs/ardour/ardour/surround_return.h b/libs/ardour/ardour/surround_return.h index cf559ff948..2e1f28c692 100644 --- a/libs/ardour/ardour/surround_return.h +++ b/libs/ardour/ardour/surround_return.h @@ -60,6 +60,19 @@ public: return _surround_processor; } + enum MainOutputFormat { + OUTPUT_FORMAT_5_1 = 2, + OUTPUT_FORMAT_7_1_4 = 6 + }; + + MainOutputFormat output_format () const { + return _current_output_format; + } + + void set_output_format (MainOutputFormat mov) { + _target_output_format = mov; + } + /* a value <= -200 indicates that no data is available */ float integrated_loudness () const; float max_dbtp () const; @@ -90,6 +103,8 @@ private: 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; ChanMapping _out_map; diff --git a/libs/ardour/ardour/uri_map.h b/libs/ardour/ardour/uri_map.h index 35a96450a7..0b4ec4916e 100644 --- a/libs/ardour/ardour/uri_map.h +++ b/libs/ardour/ardour/uri_map.h @@ -112,6 +112,7 @@ public: uint32_t surr_BinauralRenderMode; uint32_t surr_ChannelCount; uint32_t surr_DownmixMode; + uint32_t surr_OutputFormat; uint32_t surr_WarpMode; uint32_t surr_ExportStart; uint32_t surr_ExportStop; diff --git a/libs/ardour/surround_return.cc b/libs/ardour/surround_return.cc index 39c94b45a6..fa5991da93 100644 --- a/libs/ardour/surround_return.cc +++ b/libs/ardour/surround_return.cc @@ -34,6 +34,8 @@ SurroundReturn::SurroundReturn (Session& s, Route* r) : Processor (s, _("SurrReturn"), Temporal::TimeDomainProvider (Temporal::AudioTime)) , _lufs_meter (s.nominal_sample_rate (), 5) , _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 */)) , _exporting (false) @@ -202,6 +204,14 @@ 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; +#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); +#endif + } + uint32_t meter_nframes = nframes; uint32_t meter_offset = 0; @@ -386,6 +396,12 @@ SurroundReturn::max_dbtp () const int 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; + } + } return _trim->set_state (node, version); } @@ -395,5 +411,6 @@ SurroundReturn::state () const XMLNode& node (_trim->state ()); node.set_property ("name", "SurrReturn"); node.set_property ("type", "surreturn"); + node.set_property ("output-format", (int) _current_output_format); return node; } diff --git a/libs/ardour/uri_map.cc b/libs/ardour/uri_map.cc index 91bec92ddf..00719effcc 100644 --- a/libs/ardour/uri_map.cc +++ b/libs/ardour/uri_map.cc @@ -89,6 +89,7 @@ URIMap::URIDs::init(URIMap& uri_map) surr_BinauralRenderMode = uri_map.uri_to_id("urn:ardour:a-vapor#BinauralRenderMode"); surr_ChannelCount = uri_map.uri_to_id("urn:ardour:a-vapor#ChannelCount"); surr_DownmixMode = uri_map.uri_to_id("urn:ardour:a-vapor#DownmixMode"); + surr_OutputFormat = uri_map.uri_to_id("urn:ardour:a-vapor#OutputFormat"); surr_WarpMode = uri_map.uri_to_id("urn:ardour:a-vapor#WarpMode"); surr_ExportStart = uri_map.uri_to_id("urn:ardour:a-vapor#ExportStart"); surr_ExportStop = uri_map.uri_to_id("urn:ardour:a-vapor#ExportStop");