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

Fixed rust capi RuntimeParams struct default value. #607

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

whyb
Copy link

@whyb whyb commented Sep 25, 2024

Why do this changes

When I use the C API, the audio noise reduction effect is different from the binary execution effect downloaded from the github release page.

Finding the difference

I carefully compared the implementation of the following two files:
libDF/src/bin/enhance_wav.rs
libDF/src/capi.rs

I found that RuntimeParams did not initialize all parameters in the capi.rs file. It only publish two functions, df_set_atten_lim() and df_set_post_filter_beta(), to set the values ​​of atten_lim_db and post_filter_beta in RuntimeParams.

In the enhance_wav.rs file, the command parser default_value_t is used to assign initial values ​​to each member variable of struct RuntimeParams.

enhance_wav.rs RuntimeParams default value:

pub struct RuntimeParams {
    pub n_ch: usize,         // enhance_wav.rs default: 1
    pub post_filter: bool,  // enhance_wav.rs default: false
    pub post_filter_beta: f32,  // enhance_wav.rs default: 0.02
    pub atten_lim_db: f32,  // enhance_wav.rs default: 100
    pub min_db_thresh: f32,   // enhance_wav.rs default: -15.0f32
    pub max_db_erb_thresh: f32,    // enhance_wav.rs default: 35.0f32
    pub max_db_df_thresh: f32,   // enhance_wav.rs default: 35.0f32
    pub reduce_mask: ReduceMask,  // enhance_wav.rs default: ReduceMask::MAX
}

Currently(before this pull requests) capi.rs RuntimeParams's default value:

pub fn default_with_ch(channels: usize) -> Self {
        RuntimeParams {
            n_ch: 1,
            post_filter: false,
            post_filter_beta: 0.02,
            atten_lim_db: 100.,
            min_db_thresh: -10.,
            max_db_erb_thresh: 30.,
            max_db_df_thresh: 20.,
            reduce_mask: ReduceMask::MEAN,
        }
    }

reference link: libDF/src/tract.rs#L176C1-L187C6

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.

1 participant