13
0

Update Lua Convolver API

* allow to update IR data
* allow to use mono processing in base-class
  This is handy for FIR (Readable/ROM), and operating directly
  on local data (ratherer than mapped buffers)
This commit is contained in:
Robin Gareus 2022-09-29 23:26:50 +02:00
parent ea1dfa5d80
commit d0b490d1b7
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 33 additions and 5 deletions

View File

@ -51,9 +51,13 @@ public:
uint32_t n_inputs () const { return _n_inputs; }
uint32_t n_outputs () const { return _n_outputs; }
void clear_impdata ();
void restart ();
void run (BufferSet&, ChanMapping const&, ChanMapping const&, pframes_t, samplecnt_t);
void run_mono_buffered (float*, uint32_t);
void run_mono_no_latency (float*, uint32_t);
protected:
ArdourZita::Convproc _convproc;

View File

@ -63,7 +63,7 @@ Convolution::add_impdata (
samplecnt_t length,
uint32_t channel)
{
if (_configured || c_in >= _n_inputs || c_out >= _n_outputs) {
if (c_in >= _n_inputs || c_out >= _n_outputs) {
return false;
}
if (!readable || readable->readable_length_samples () <= offset || readable->n_channels () <= channel) {
@ -74,6 +74,12 @@ Convolution::add_impdata (
return true;
}
void
Convolution::clear_impdata ()
{
_impdata.clear ();
}
bool
Convolution::ready () const
{
@ -87,6 +93,11 @@ Convolution::restart ()
_convproc.cleanup ();
_convproc.set_options (0);
if (_impdata.empty ()) {
_configured = false;
return;
}
uint32_t n_part;
if (_threaded) {
@ -316,8 +327,14 @@ Convolver::Convolver (
void
Convolver::run_mono_buffered (float* buf, uint32_t n_samples)
{
assert (_convproc.state () == Convproc::ST_PROC);
assert (_irc == Mono);
Convolution::run_mono_buffered (buf, n_samples);
}
void
Convolution::run_mono_buffered (float* buf, uint32_t n_samples)
{
assert (_convproc.state () == Convproc::ST_PROC);
uint32_t done = 0;
uint32_t remain = n_samples;
@ -375,8 +392,14 @@ Convolver::run_stereo_buffered (float* left, float* right, uint32_t n_samples)
void
Convolver::run_mono_no_latency (float* buf, uint32_t n_samples)
{
assert (_convproc.state () == Convproc::ST_PROC);
assert (_irc == Mono);
Convolution::run_mono_no_latency (buf, n_samples);
}
void
Convolution::run_mono_no_latency (float* buf, uint32_t n_samples)
{
assert (_convproc.state () == Convproc::ST_PROC);
uint32_t done = 0;
uint32_t remain = n_samples;

View File

@ -2983,7 +2983,10 @@ LuaBindings::common (lua_State* L)
.beginClass <DSP::Convolution> ("Convolution")
.addConstructor <void (*) (Session&, uint32_t, uint32_t)> ()
.addFunction ("add_impdata", &ARDOUR::DSP::Convolution::add_impdata)
.addFunction ("clear_impdata", &ARDOUR::DSP::Convolution::clear_impdata)
.addFunction ("run", &ARDOUR::DSP::Convolution::run)
.addFunction ("run_mono_buffered", &ARDOUR::DSP::Convolution::run_mono_buffered)
.addFunction ("run_mono_no_latency", &ARDOUR::DSP::Convolution::run_mono_no_latency)
.addFunction ("restart", &ARDOUR::DSP::Convolution::restart)
.addFunction ("ready", &ARDOUR::DSP::Convolution::ready)
.addFunction ("latency", &ARDOUR::DSP::Convolution::latency)
@ -3003,9 +3006,7 @@ LuaBindings::common (lua_State* L)
.deriveClass <DSP::Convolver, DSP::Convolution> ("Convolver")
.addConstructor <void (*) (Session&, std::string const&, DSP::Convolver::IRChannelConfig, DSP::Convolver::IRSettings)> ()
.addFunction ("run_mono_buffered", &ARDOUR::DSP::Convolver::run_mono_buffered)
.addFunction ("run_stereo_buffered", &ARDOUR::DSP::Convolver::run_stereo_buffered)
.addFunction ("run_mono_no_latency", &ARDOUR::DSP::Convolver::run_mono_no_latency)
.addFunction ("run_stereo_no_latency", &ARDOUR::DSP::Convolver::run_stereo_no_latency)
.endClass ()