Skip to content

Commit

Permalink
multiband_drc: instantaneous enabled state switch on processing
Browse files Browse the repository at this point in the history
In present multiband_drc design, the enabled state is determined by
the switch control while multiband_drc starts to process. If the
switch control toggles while processing, it will take effects on the
next time multiband_drc starts to process.

This commit makes change to let the enabled state update
instantaneously by the switch control toggle when multiband_drc is
processing.

Signed-off-by: Pin-chih Lin <[email protected]>
(cherry picked from commit 8e8ff75)
  • Loading branch information
johnylin76 authored and mwasko committed Mar 19, 2024
1 parent f91af22 commit fafc1ca
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
45 changes: 21 additions & 24 deletions src/audio/multiband_drc/multiband_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ static int multiband_drc_init_coef(struct multiband_drc_comp_data *cd, int16_t n
"multiband_drc_init_coef(), initializing %i-way crossover",
config->num_bands);

/* Crossover: determine the split function */
cd->crossover_split = crossover_find_split_func(config->num_bands);
if (!cd->crossover_split) {
comp_cl_err(&comp_multiband_drc,
"multiband_drc_init_coef(), No crossover_split for band num %i",
config->num_bands);
ret = -EINVAL;
goto err;
}

/* Crossover: collect the coef array and assign it to every channel */
crossover = config->crossover_coef;
for (ch = 0; ch < nch; ch++) {
Expand Down Expand Up @@ -456,7 +466,10 @@ static void multiband_drc_process(struct comp_dev *dev, struct comp_buffer *sour

buffer_stream_invalidate(source, source_bytes);

cd->multiband_drc_func(dev, &source->stream, &sink->stream, frames);
if (cd->process_enabled)
cd->multiband_drc_func(dev, &source->stream, &sink->stream, frames);
else
multiband_drc_default_pass(dev, &source->stream, &sink->stream, frames);

buffer_stream_writeback(sink, sink_bytes);

Expand Down Expand Up @@ -530,35 +543,19 @@ static int multiband_drc_prepare(struct comp_dev *dev)
comp_dbg(dev, "multiband_drc_prepare(), source_format=%d, sink_format=%d",
cd->source_format, cd->source_format);
cd->config = comp_get_data_blob(cd->model_handler, NULL, NULL);
if (cd->config && cd->process_enabled) {
if (cd->config) {
ret = multiband_drc_setup(cd, sourceb->stream.channels, sourceb->stream.rate);
if (ret < 0) {
comp_err(dev, "multiband_drc_prepare() error: multiband_drc_setup failed.");
goto err;
}
}

cd->multiband_drc_func = multiband_drc_find_proc_func(cd->source_format);
if (!cd->multiband_drc_func) {
comp_err(dev, "multiband_drc_prepare(), No proc func");
ret = -EINVAL;
goto err;
}

cd->crossover_split = crossover_find_split_func(cd->config->num_bands);
if (!cd->crossover_split) {
comp_err(dev, "multiband_drc_prepare(), No crossover_split for band num %i",
cd->config->num_bands);
ret = -EINVAL;
goto err;
}
} else {
comp_info(dev, "multiband_drc_prepare(), DRC is in passthrough mode");
cd->multiband_drc_func = multiband_drc_find_proc_func_pass(cd->source_format);
if (!cd->multiband_drc_func) {
comp_err(dev, "multiband_drc_prepare(), No proc func passthrough");
ret = -EINVAL;
goto err;
}
cd->multiband_drc_func = multiband_drc_find_proc_func(cd->source_format);
if (!cd->multiband_drc_func) {
comp_err(dev, "multiband_drc_prepare(), No proc func");
ret = -EINVAL;
goto err;
}

/* validate sink data format and period bytes */
Expand Down
8 changes: 4 additions & 4 deletions src/audio/multiband_drc/multiband_drc_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include <sof/audio/multiband_drc/multiband_drc.h>
#include <sof/math/iir_df2t.h>

static void multiband_drc_default_pass(const struct comp_dev *dev,
const struct audio_stream *source,
struct audio_stream *sink,
uint32_t frames)
void multiband_drc_default_pass(const struct comp_dev *dev,
const struct audio_stream *source,
struct audio_stream *sink,
uint32_t frames)
{
audio_stream_copy(source, 0, sink, 0, source->channels * frames);
}
Expand Down
5 changes: 5 additions & 0 deletions src/include/sof/audio/multiband_drc/multiband_drc.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ extern const struct multiband_drc_proc_fnmap multiband_drc_proc_fnmap[];
extern const struct multiband_drc_proc_fnmap multiband_drc_proc_fnmap_pass[];
extern const size_t multiband_drc_proc_fncount;

void multiband_drc_default_pass(const struct comp_dev *dev,
const struct audio_stream *source,
struct audio_stream *sink,
uint32_t frames);

/**
* \brief Returns Multiband DRC processing function.
*/
Expand Down

0 comments on commit fafc1ca

Please sign in to comment.