Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiband_drc: instantaneous enabled state switch on processing #9329

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions src/audio/multiband_drc/multiband_drc.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ static int multiband_drc_init_coef(struct processing_module *mod, int16_t nch, u
comp_info(dev, "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_err(dev, "multiband_drc_init_coef(), No crossover_split for band count(%i)",
config->num_bands);
return -EINVAL;
}

/* 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 @@ -328,7 +336,10 @@ static int multiband_drc_process(struct processing_module *mod,
}
}

cd->multiband_drc_func(mod, source, sink, frames);
if (cd->process_enabled)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be possible to reassign cd->multiband_drc_func in multiband_drc_process_enable() and avoid the if here?

cd->multiband_drc_func(mod, source, sink, frames);
else
multiband_drc_default_pass(mod, source, sink, frames);

/* calc new free and available */
module_update_buffer_position(&input_buffers[0], &output_buffers[0], frames);
Expand Down Expand Up @@ -364,32 +375,18 @@ static int multiband_drc_prepare(struct processing_module *mod,
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(mod, channels, rate);
if (ret < 0) {
comp_err(dev, "multiband_drc_prepare() error: multiband_drc_setup failed.");
return ret;
}
}

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");
return -EINVAL;
}

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);
return -EINVAL;
}
} 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");
return -EINVAL;
}
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");
return -EINVAL;
}

return ret;
Expand Down
5 changes: 5 additions & 0 deletions src/audio/multiband_drc/multiband_drc.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,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 processing_module *mod,
const struct audio_stream *source,
struct audio_stream *sink,
uint32_t frames);

/**
* \brief Returns Multiband DRC processing function.
*/
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 @@ -11,10 +11,10 @@
#include "multiband_drc.h"
#include "../drc/drc_algorithm.h"

static void multiband_drc_default_pass(const struct processing_module *mod,
const struct audio_stream *source,
struct audio_stream *sink,
uint32_t frames)
void multiband_drc_default_pass(const struct processing_module *mod,
const struct audio_stream *source,
struct audio_stream *sink,
uint32_t frames)
{
audio_stream_copy(source, 0, sink, 0, audio_stream_get_channels(source) * frames);
}
Expand Down
Loading