diff --git a/libs/ardour/ardour/surround_return.h b/libs/ardour/ardour/surround_return.h index 4c6ad722e3..2f6eb70275 100644 --- a/libs/ardour/ardour/surround_return.h +++ b/libs/ardour/ardour/surround_return.h @@ -63,6 +63,14 @@ public: void setup_export (std::string const&, samplepos_t, samplepos_t); void finalize_export (); + size_t n_channels () const { + return _current_n_channels; + } + + size_t total_n_channels () const { + return _total_n_channels; + } + std::shared_ptr surround_processor () const { return _surround_processor; } @@ -169,6 +177,7 @@ private: int _current_render_mode[max_object_id]; size_t _channel_id_map[max_object_id]; size_t _current_n_channels; + size_t _total_n_channels; MainOutputFormat _current_output_format; BufferSet _surround_bufs; ChanMapping _in_map; diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index 21d3e499ac..2a2ca18624 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -1927,6 +1927,8 @@ LuaBindings::common (lua_State* L) .addFunction ("max_momentary", &SurroundReturn::max_momentary) .addFunction ("momentary", &SurroundReturn::momentary) .addFunction ("max_dbtp", &SurroundReturn::max_dbtp) + .addFunction ("n_channels", &SurroundReturn::n_channels) + .addFunction ("total_n_channels", &SurroundReturn::total_n_channels) .addFunction ("output_format_controllable", &SurroundReturn::output_format_controllable) .endClass () diff --git a/libs/ardour/surround_return.cc b/libs/ardour/surround_return.cc index ed8ddfe271..1c5129daf5 100644 --- a/libs/ardour/surround_return.cc +++ b/libs/ardour/surround_return.cc @@ -82,6 +82,7 @@ SurroundReturn::SurroundReturn (Session& s, Route* r) #endif , _have_au_renderer (false) , _current_n_channels (max_object_id) + , _total_n_channels (max_object_id) , _current_output_format (OUTPUT_FORMAT_7_1_4) , _in_map (ChanCount (DataType::AUDIO, 128)) , _out_map (ChanCount (DataType::AUDIO, 14 + 6 /* Loudness Meter */)) @@ -397,7 +398,12 @@ SurroundReturn::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_ timepos_t unused_start, unused_end; samplecnt_t latency = effective_latency (); - for (uint32_t s = 0; s < ss->bufs ().count ().n_audio () && cid < max_object_id; ++s, ++cid) { + for (uint32_t s = 0; s < ss->bufs ().count ().n_audio (); ++s, ++cid) { + + if (cid >= max_object_id) { + continue; + } + std::shared_ptr const& p (ss->pan_param (s, unused_start, unused_end)); AutoState const as = p->automation_state (); @@ -470,14 +476,12 @@ SurroundReturn::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_ #endif } } - - } - - if (cid >= max_object_id) { - break; } } + _total_n_channels = cid; + cid = std::min (128, cid); + if (_current_n_channels != cid) { _current_n_channels = cid; #if defined(LV2_EXTENDED) && defined(HAVE_LV2_1_10_0)