API
DHDenoiserConfig
Builder
DHDenoiserConfig.Builder
is a builder class that initializes and configures a DHDenoiserConfig
instance.
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:
- Java
- Kotlin
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);
val LICENSE_KEY = "YOUR_LICENSE_KEY"
val sampleRate = 48000
val frameSize = 768 // 16ms @48kHz
val denoiserConfig = DHDenoiserConfig.Builder(LICENSE_KEY)
.setSampleRate(sampleRate)
.setFrameSize(frameSize)
.build()
DHDenoiser.init(this, denoiserConfig)
setSampleRate
- Java
- Kotlin
DHDenoiserConfig setSampleRate(int sampleRate)
setSampleRate(sampleRate: Int): DHDenoiserConfig
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
- Java
- Kotlin
DHDenoiserConfig setFrameSize(int frameSize)
setFrameSize(frameSize: Int): DHDenoiserConfig
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.
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
- Java
- Kotlin
void init(Context applicationContext, DHDenoiserConfig denoiserConfig)
init(applicationContext: Context, denoiserConfig: DHDenoiserConfig): Unit
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
- Java
- Kotlin
boolean isExpired()
isExpired(): Boolean
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:
- Java
- Kotlin
// 초기화 코드 ...
DHDenoiser.init(this, denoiserConfig);
if (DHDenoiser.isExpired()) {
Log.e("DHDenoiser", "SDK has expired");
}
// 초기화 코드 ...
DHDenoiser.init(this, denoiserConfig)
if (DHDenoiser.isExpired()) {
Log.e("DHDenoiser", "SDK has expired")
}
destroy
- Java
- Kotlin
void destroy()
destroy(): Unit
Releases all allocated resources.
You must call this method before exiting the app to release all resources.
This is an example of how to use this method:
- Java
- Kotlin
DHDenoiser.destroy()
DHDenoiser.destroy()
process
- Java
- Kotlin
void process(float[] input, float[] output)
process(input: FloatArray, output: FloatArray): Unit
Processes the input audio data for noise reduction.
Parameter
input
: The input audio buffer you want to denoiseoutput
: Denoised output audio buffer
process
- Java
- Kotlin
void process(float[] input, float[] output, float denoiserLevel)
process(input: FloatArray, output: FloatArray, denoiserLevel: Float): Unit
Processes the input audio data for noise reduction.
Parameter
input
: The input audio buffer you want to denoiseoutput
: Denoised output audio bufferdenoiserLevel
: 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:
- Java
- Kotlin
float denoiserLevel = 0.8f;
int frameSize = 128; // default size
float[] input = new float[frameSize];
float[] output = new float[frameSize];
DHDenoiser.process(input, output, denoiserLevel);
val denoiserLevel = 0.8f
val frameSize = 128 // default size
val input = FloatArray(frameSize)
val output = FloatArray(frameSize)
DHDenoiser.process(input, output, denoiserLevel)
enableDenoiser()
- Java
- Kotlin
void enableDenoiser()
enableDenoiser(): Unit
This method enables the noise reduction feature. The initial state has the noise reduction enabled.
disableDenoiser()
- Java
- Kotlin
void disableDenoiser()
disableDenoiser(): Unit
This method disables the noise reduction feature. It is set to output the original audio data without noise reduction.
isDenoiserEnabled()
- Java
- Kotlin
boolean isDenoiserEnabled()
isDenoiserEnabled(): Boolean
This method returns whether the noise reduction feature is currently enabled.
You can implement a noise reduction Toggle feature as follows:
- Java
- Kotlin
if (DHDenoiser.isDenoiserEnabled()) {
DHDenoiser.disableDenoiser();
} else {
DHDenoiser.enableDenoiser();
}
if (DHDenoiser.isDenoiserEnabled()) {
DHDenoiser.disableDenoiser()
} else {
DHDenoiser.enableDenoiser()
}