Skip to main content

API

DHDenoiserConfig


Builder

DHDenoiserConfig.Builder is a builder class that initializes and configures a DHDenoiserConfig instance.

info

licenseKey is a mandatory parameter.

DHDenoiserConfig.Builder(String licenseKey)

If you want to set the sample rate and frame size differently, you can configure them as follows:

String LICENSE_KEY = "YOUR_LICENSE_KEY"
int sampleRate = 48000;
int frameSize = 768; // 16ms @48kHz

DHDenoiserConfig denoiserConfig = new DHDenoiserConfig.Builder(LICENSE_KEY)
.setSampleRate(sampleRate)
.setFrameSize(frameSize)
.build();

DHDenoiser.init(this, denoiserConfig);

setSampleRate

DHDenoiserConfig setSampleRate(int sampleRate)

The default sample rate is 16000Hz. The currently additionally supported sample rate is 48000Hz. If you want to change the sample rate, you can use setSampleRate.

setFrameSize

DHDenoiserConfig setFrameSize(int frameSize)

Specifies the size of the audio frame processed each time via the process function. The default frame size is 128 at 16kHz, which is the minimum frame size.

tip

You can adjust the frame size through this method, but it can only be set to multiples of the minimum frame size. If you are using a sample rate of 16000Hz, you can set it to 128, 256, 384, etc.

DHDenoiser


init

void init(Context applicationContext, DHDenoiserConfig denoiserConfig)

Once the instance creation is completed using the DHDenoise.Builder, you can perform the resource allocation and initialization required for noise reduction using the init function.

isExpired

boolean isExpired()

If the SDK Key has expired, the initialization process will not be completed properly. You can use isExpired to check for license expiration.

Here's an example of how to use this method:

// 초기화 코드 ...

DHDenoiser.init(this, denoiserConfig);

if (DHDenoiser.isExpired()) {
Log.e("DHDenoiser", "SDK has expired");
}

destroy

void destroy()

Releases all allocated resources.

caution

You must call this method before exiting the app to release all resources.

This is an example of how to use this method:

DHDenoiser.destroy()

process

void process(float[] input, float[] output)

Processes the input audio data for noise reduction.

Parameter

  • input: The input audio buffer you want to denoise
  • output: Denoised output audio buffer

process

void process(float[] input, float[] output, float denoiserLevel)

Processes the input audio data for noise reduction.

Parameter

  • input: The input audio buffer you want to denoise
  • output: Denoised output audio buffer
  • denoiserLevel: Adjusts the level of noise reduction, and must be in the range 0.0 ~ 1.0.
    • 0.0: Equivalent to not removing noise
    • 1.0: Noise Reduction to the max (default)

This is an example of how to use this method:

float denoiserLevel = 0.8f;
int frameSize = 128; // default size
float[] input = new float[frameSize];
float[] output = new float[frameSize];

DHDenoiser.process(input, output, denoiserLevel);

enableDenoiser()

void enableDenoiser()

This method enables the noise reduction feature. The initial state has the noise reduction enabled.

disableDenoiser()

void disableDenoiser()

This method disables the noise reduction feature. It is set to output the original audio data without noise reduction.

isDenoiserEnabled()

boolean isDenoiserEnabled()

This method returns whether the noise reduction feature is currently enabled.

You can implement a noise reduction Toggle feature as follows:

if (DHDenoiser.isDenoiserEnabled()) {
DHDenoiser.disableDenoiser();
} else {
DHDenoiser.enableDenoiser();
}