1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
/***
* Summary
* types:
* NSinst_t : the type of noise suppression instance structure.
* NsHandle : actually the same type of NSinst_t, defined in
* "noise_suppression.h" as a empty struct type named
* "NsHandleT".
*
* Note:
* 1.You have no need to pass env and jclazz to these functions,
* cus' JVM will does it for you.
* 2.We only support 10ms frames, that means you can only input 320
* Bytes a time.
**/
/**
* This function wraps the "WebRtcNs_Create" function in "noise_suppression.c".
* Input:
* none.
* Output:
* the handler of created noise suppression instance.
* Return value:
* -1 : error occurs.
* other value : available handler of created NS instance.
*
* @author billhoo
* @version 1.0 2013-1-29
*/
JNIEXPORT jint JNICALL
Java_你的类限定名_createNSInstance(JNIEnv *env,
jclass jclazz) {
NsHandle *hNS = NULL;
//create a pointer to NsHandle on native stack.
if
(WebRtcNs_Create(&hNS) == -1) {
//allocate dynamic memory on native heap for NS instance pointed by hNS.
return
-1;
//error occurs
}
else
{
return
((
int
) (NSinst_t *) hNS);
//returns the address of NS instance on native heap.
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/**
* This function wraps the "WebRtcNs_Init" function in
* "noise_suppression.c".
* Initializes a NS instance and has to be called before any other
* processing is made.
*
* Input:
* - nsHandler - Handler of NS instance that should be
* initialized.
* - sf - sampling frequency, only 8000, 16000, 32000
* are available.
* Output:
* nsHandler - the handler of initialized instance.
* Return value:
* 0 - OK
* -1 - Error
*
* @author billhoo
* @version 1.0 2013-1-29
*/
JNIEXPORT jint JNICALL
Java_你的类限定名_initiateNSInstance(JNIEnv *env,
jclass jclazz, jint nsHandler, jlong sf) {
NsHandle *hNS = (NsHandle*) nsHandler;
return
WebRtcNs_Init(hNS, sf);
}
|
1
2
3
4
5
6
7
8
9
|
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := webrtc_ns
LOCAL_SRC_FILES := \
noise_suppression.c \
ns_core.c \
fft4g.c \
ns_jni_wrapper.c
include $(BUILD_SHARED_LIBRARY)
|