Vapor: add API to query channel count

This commit is contained in:
Robin Gareus 2024-02-26 21:37:32 +01:00
parent bff0f174da
commit 4acd0e9f29
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 21 additions and 6 deletions

View File

@ -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<LV2Plugin> 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;

View File

@ -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 ()

View File

@ -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<SurroundPannable> 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<size_t> (128, cid);
if (_current_n_channels != cid) {
_current_n_channels = cid;
#if defined(LV2_EXTENDED) && defined(HAVE_LV2_1_10_0)