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

Tools: Tune: DRC: Add calculation of blob for speaker processing #8475

Merged
merged 6 commits into from
Dec 19, 2023
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
1 change: 1 addition & 0 deletions tools/ctl/ipc4/drc/generic_notebook_speaker.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
877023059,0,108,50438144,0,0,0,0,108,0,0,0,0,1,3875536896,251658240,167772160,6442451,60380940,107374182,12708444,2327743,4292230659,5305422,162898102,73470028,7456540,4286019447,2062296,5,4423680,294359,2477728,622039,46513,
1 change: 1 addition & 0 deletions tools/ctl/ipc4/drc/passthrough.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
877023059,0,108,50438144,0,0,0,0,108,0,0,0,0,0,3892314112,503316480,201326592,6442451,67748529,89478485,2030160,9723989,4285175934,33474947,575096676,24401431,7456540,4286019447,2062296,5,4423680,294359,2477728,622039,46513,
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Exported with script example_drc.m 18-Dec-2023
# cd tools/tune/drc; octave --no-window-system example_drc.m
CONTROLBYTES_PRIV(DRC_priv,
` bytes "0x53,0x4f,0x46,0x00,0x00,0x00,0x00,0x00,'
` 0x6c,0x00,0x00,0x00,0x00,0xa0,0x01,0x03,'
` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,'
` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,'
` 0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,'
` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,'
` 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,'
` 0x00,0x00,0x00,0xe7,0x00,0x00,0x00,0x0f,'
` 0x00,0x00,0x00,0x0a,0xd3,0x4d,0x62,0x00,'
` 0x0c,0x57,0x99,0x03,0x66,0x66,0x66,0x06,'
` 0x5c,0xea,0xc1,0x00,0xbf,0x84,0x23,0x00,'
` 0x03,0x3e,0xd6,0xff,0x4e,0xf4,0x50,0x00,'
` 0xb6,0xa0,0xb5,0x09,0x4c,0x10,0x61,0x04,'
` 0x1c,0xc7,0x71,0x00,0x77,0x77,0x77,0xff,'
` 0xd8,0x77,0x1f,0x00,0x05,0x00,0x00,0x00,'
` 0x00,0x80,0x43,0x00,0xd7,0x7d,0x04,0x00,'
` 0xa0,0xce,0x25,0x00,0xd7,0x7d,0x09,0x00,'
` 0xb1,0xb5,0x00,0x00"'
)
2 changes: 1 addition & 1 deletion tools/topology/topology1/sof/pipe-drc-playback.m4
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ W_PCM_PLAYBACK(PCM_ID, DRC Playback, 2, 0, SCHEDULE_CORE)

define(DRC_priv, concat(`drc_bytes_', PIPELINE_ID))
define(MY_DRC_CTRL, concat(`drc_control_', PIPELINE_ID))
include(`drc_coef_default.m4')
include(`drc_coef_generic_notebook_speaker.m4')
C_CONTROLBYTES(MY_DRC_CTRL, PIPELINE_ID,
CONTROLBYTES_OPS(bytes, 258 binds the control to bytes get/put handlers, 258, 258),
CONTROLBYTES_EXTOPS(258 binds the control to bytes get/put handlers, 258, 258),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Exported Control Bytes 17-May-2023
# Exported with script example_drc.m 18-Dec-2023
# cd tools/tune/drc; octave --no-window-system example_drc.m
Object.Base.data."drc_config" {
bytes "
0x53,0x4f,0x46,0x34,0x00,0x00,0x00,0x00,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Exported with script example_drc.m 18-Dec-2023
# cd tools/tune/drc; octave --no-window-system example_drc.m
Object.Base.data."drc_config" {
bytes "
0x53,0x4f,0x46,0x34,0x00,0x00,0x00,0x00,
0x6c,0x00,0x00,0x00,0x00,0xa0,0x01,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x6c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0xe7,0x00,0x00,0x00,0x0f,
0x00,0x00,0x00,0x0a,0xd3,0x4d,0x62,0x00,
0x0c,0x57,0x99,0x03,0x66,0x66,0x66,0x06,
0x5c,0xea,0xc1,0x00,0xbf,0x84,0x23,0x00,
0x03,0x3e,0xd6,0xff,0x4e,0xf4,0x50,0x00,
0xb6,0xa0,0xb5,0x09,0x4c,0x10,0x61,0x04,
0x1c,0xc7,0x71,0x00,0x77,0x77,0x77,0xff,
0xd8,0x77,0x1f,0x00,0x05,0x00,0x00,0x00,
0x00,0x80,0x43,0x00,0xd7,0x7d,0x04,0x00,
0xa0,0xce,0x25,0x00,0xd7,0x7d,0x09,0x00,
0xb1,0xb5,0x00,0x00"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Exported Control Bytes 17-May-2023
# Exported with script example_drc.m 18-Dec-2023
# cd tools/tune/drc; octave --no-window-system example_drc.m
Object.Base.data."drc_config" {
bytes "
0x53,0x4f,0x46,0x34,0x00,0x00,0x00,0x00,
Expand Down
1 change: 1 addition & 0 deletions tools/tune/drc/drc_gen_coefs.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
% Calculate makeup gain coefficients
full_range_makeup_gain = (1 / coefs.ratio_base) ^ 0.6; % Empirical/perceptual tuning
coefs.master_linear_gain = db2mag(params.post_gain) * full_range_makeup_gain;
coefs.master_linear_gain_db = 20*log10(coefs.master_linear_gain);

andrula-song marked this conversation as resolved.
Show resolved Hide resolved
% Calculate attack time coefficients
attack_time = max(0.001, params.attack);
Expand Down
15 changes: 13 additions & 2 deletions tools/tune/drc/example_drc.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ function example_drc()
params.enabled = 1;
drc_coefs_and_config_export(params, 'enabled');

% Export experimental configuration for a small speaker
Copy link
Contributor

Choose a reason for hiding this comment

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

In my view the only purpose for these lines is to generate the config "threshold_-25_knee_15_ratio_10_post_3", they are not supposed to land upstream. Alternatively, the applied param set could be put into the comment together with the generated config files.
Another point is that the generated config will be changed by any parameter which is not specified here, e.g. attack and release.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, there's more parameters. I guess I should change the file name, but the intention of this is to become the default notebook speaker (hda-generic PC) DRC so used by their default topology so it should be in upstream. The parameters are still likely to change with more subjective testing. I used these parameters for an internal demo to show how DRC can be used to make a very audible loudness change. The EQ in the pipeline is also part of the enhance effect.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. It should be a good idea to separate them into multiple files, e.g. example_drc_default.m, example_drc_notebook.m, and others for different use cases. I found that the same way is applied under eq/ and tfdb/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree, that would be a small and ease maintenance of the tools files.

params.enabled = 1;
params.threshold = -25;
params.knee = 15;
params.ratio = 10;
params.post_gain = 3;
drc_coefs_and_config_export(params, 'generic_notebook_speaker');

rmpath ../common

end
Expand Down Expand Up @@ -60,8 +68,11 @@ function drc_coefs_and_config_export(params, id)
blob8_ipc4 = drc_build_blob(config, endian, 4);

% Generate output files
tplg_write(tplg1_fn, blob8, "DRC");
tplg2_write(tplg2_fn, blob8_ipc4, "drc_config", 'Exported Control Bytes');
my_name = mfilename();
drc_note = sprintf("Exported with script %s.m", my_name);
drc_howto = sprintf("cd tools/tune/drc; octave --no-window-system %s.m", my_name);
tplg_write(tplg1_fn, blob8, "DRC", drc_note, drc_howto);
tplg2_write(tplg2_fn, blob8_ipc4, "drc_config", drc_note, drc_howto);
blob_write(blob3_fn, blob8);
alsactl_write(alsa3_fn, blob8);
blob_write(blob4_fn, blob8_ipc4);
Expand Down