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 Rate | 16000 |
Data Format | pcm16 |
Input Size | stereo 256 (128 per channel) |
Output Size | mono 128 |
Requirements
The specifications required to use the SDK are as follows:
- API 23: Android 6.0 and above
Install Beamformer
Setting Gradle
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.
- setting.gradle (Gradle ≥ 6.8)
- build.gradle (Gradle ≤ 6.7)
dependencyResolutionManagement {
repositories {
maven {
credentials {
username = "username"
password = "password"
}
url "Deep Hearing repository url"
}
}
}
allprojects {
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.
- build.gradle
dependencies {
implementation 'com.deephearing.sdk:beamformer:1.0.0'
}
Initialize the Beamformer instance
An SDK_KEY
is required to initialize the Beamformer SDK.
- Kotlin
lateinit var beamformer: Beamformer
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
beamformer = Beamformer("SDK_KEY")
}
If you enter an invalid key or the key has expired, the initialization will fail.
Destroy the Beamformer instance
Release the allocated resources.
- Kotlin
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)
- Kotlin
val input = ShortArray(256)
val output = ShortArray(128)
// Get input data from real stereo mic
beamformer.process(input, output)
If you pass an array with an invalid length, it will not be processed correctly.