Skip to main content

How to apply Beamformer SDK

This is a guide to using the Deep Hearing Beamformer SDK for Android.

Audio Format

The following audio data format is required for beamforming:

Sample Rate16000
Data Formatpcm16
Input Sizestereo 256 (128 per channel)
Output Sizemono 128

Requirements

The specifications required to use the SDK are as follows:

  • API 23: Android 6.0 and above

Install Beamformer

Setting Gradle

info

If you are using Gradle 6.7 or lower, add the following code to the root build.gradle file.

If you are using Gradle 6.8 or higher, add the following code to the settings.gradle file.

dependencyResolutionManagement {
repositories {
maven {
credentials {
username = "username"
password = "password"
}

url "Deep Hearing repository url"

}
}
}

For more details, refer to the Android documentation.

Next, open the application level build.gradle file for all Gradle versions and add the following code.

dependencies {
implementation 'com.deephearing.sdk:beamformer:1.0.0'
}

Initialize the Beamformer instance

An SDK_KEY is required to initialize the Beamformer SDK.

lateinit var beamformer: Beamformer

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

beamformer = Beamformer("SDK_KEY")
}
caution

If you enter an invalid key or the key has expired, the initialization will fail.

Destroy the Beamformer instance

Release the allocated resources.

override fun onDestroy() {
super.onDestroy()
beamformer.destroy()
}

Beamforming

process() function receives 256 samples(stereo) and performs beamforming.

The number of output samples is 128 (mono)

val input = ShortArray(256)
val output = ShortArray(128)

// Get input data from real stereo mic

beamformer.process(input, output)
caution

If you pass an array with an invalid length, it will not be processed correctly.