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: dcblock: Create set of cut-off frequencies #8283

Merged
merged 1 commit into from
Oct 16, 2023

Conversation

singalsu
Copy link
Collaborator

@singalsu singalsu commented Oct 3, 2023

This patch modifies script example_dblock.m to create in addition to existing default coefficients blob with parameter R=0.98 a set of blobs those provide (-3 dB) cut-off frequencies 20, 30, 40, 50, 100, 200 Hz for 16 kHz and 48 kHz for various usages. Human understandable parameters for blobs helps to select the configuration for the needed dcblock usage.

The parameter value R for given frequencies is calculated with iterative function dcblock_rval_calculate(). A closed form equation might be possible to derive from the transfer function. If such is found this function can be replaced with quicker equation -- or with more advanced faster converging iteration.

The topology blob export functions are also modified to add comment line for exact build command.

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

Just needs more inline commentary to make it easier for users to modify and adapt.

tools/tune/dcblock/example_dcblock.m Show resolved Hide resolved
@singalsu singalsu force-pushed the tune_dcblock_how_generated branch from 7671375 to 1fac74c Compare October 4, 2023 15:52
@singalsu singalsu marked this pull request as ready for review October 4, 2023 16:02
Copy link
Contributor

@ShriramShastry ShriramShastry left a comment

Choose a reason for hiding this comment

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

Overall, as a first drafting for changes to cut-off frequencies, it looks good to me, with only a few minor suggestions caught.

Thank you for making the necessary modifications.

R = 0.5;
R_step = 0.005;
sign = 1;
err_prev = inf;
Copy link
Contributor

Choose a reason for hiding this comment

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

The value assigned to err_prev could be unnecessary.


% Iteration 0
h = (1 - z^-1) / (1 - R * z^-1);
a = abs(h);
Copy link
Contributor

Choose a reason for hiding this comment

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

The value assigned to a could be unnecessary.

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, remain from previous iteration code version, both can be deleted.


% Sane result?
if R < eps || R > 1 - eps
error("Calculate of R iteration failed")
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps there is a missing semicolon at the end.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@singalsu issue or not?

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 think it's good to have the semicolon there, Matlab syntax does not require it, but possibly it could display unnecessary return status from error(). I'll do Sriram's suggested fixes, stay tuned.

@kv2019i
Copy link
Collaborator

kv2019i commented Oct 13, 2023

@singalsu Mandatory tests need to pass, otherwise this seems ready to go.

This patch modifies script example_dblock.m to create in
addition to existing default coefficients blob with parameter
R=0.98 a set of blobs those provide (-3 dB) cut-off frequencies
20, 30, 40, 50, 100, 200 Hz for 16 kHz and 48 kHz for various
usages. Human understandable parameters for blobs helps to select
the configuration for the needed dcblock usage.

The parameter value R for given frequencies is calculated
with iterative function dcblock_rval_calculate(). A closed
form equation might be possible to derive from the transfer
function. If such is found this function can be replaced with
quicker equation -- or with more advanced faster converging
iteration.

The topology blob export functions are also modified to add
comment line for exact build command.

Signed-off-by: Seppo Ingalsuo <[email protected]>
@singalsu singalsu force-pushed the tune_dcblock_how_generated branch from 1fac74c to 6bc6574 Compare October 13, 2023 13:41
@singalsu
Copy link
Collaborator Author

@ShriramShastry Thanks for spotting the unnecessary code lines, those are fixed now!

@lgirdwood lgirdwood merged commit d3b7e54 into thesofproject:main Oct 16, 2023
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants