aboutsummaryrefslogtreecommitdiff
path: root/src/common_audio/vad/main/interface/webrtc_vad.h
blob: 6e3eb74ab58d1a04afebab301292a0a4490826ac (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */


/*
 * This header file includes the VAD API calls. Specific function calls are given below.
 */

#ifndef WEBRTC_VAD_WEBRTC_VAD_H_
#define WEBRTC_VAD_WEBRTC_VAD_H_

#include "typedefs.h"

typedef struct WebRtcVadInst VadInst;

#ifdef __cplusplus
extern "C"
{
#endif

/****************************************************************************
 * WebRtcVad_get_version(...)
 *
 * This function returns the version number of the code.
 *
 * Output:
 *      - version       : Pointer to a buffer where the version info will
 *                        be stored.
 * Input:
 *      - size_bytes    : Size of the buffer.
 *
 */
WebRtc_Word16 WebRtcVad_get_version(char *version, size_t size_bytes);

/****************************************************************************
 * WebRtcVad_AssignSize(...) 
 *
 * This functions get the size needed for storing the instance for encoder
 * and decoder, respectively
 *
 * Input/Output:
 *      - size_in_bytes : Pointer to integer where the size is returned
 *
 * Return value         : 0
 */
WebRtc_Word16 WebRtcVad_AssignSize(int *size_in_bytes);

/****************************************************************************
 * WebRtcVad_Assign(...) 
 *
 * This functions Assigns memory for the instances.
 *
 * Input:
 *        - vad_inst_addr :  Address to where to assign memory
 * Output:
 *        - vad_inst      :  Pointer to the instance that should be created
 *
 * Return value           :  0 - Ok
 *                          -1 - Error
 */
WebRtc_Word16 WebRtcVad_Assign(VadInst **vad_inst, void *vad_inst_addr);

/****************************************************************************
 * WebRtcVad_Create(...)
 *
 * This function creates an instance to the VAD structure
 *
 * Input:
 *      - vad_inst      : Pointer to VAD instance that should be created
 *
 * Output:
 *      - vad_inst      : Pointer to created VAD instance
 *
 * Return value         :  0 - Ok
 *                        -1 - Error
 */
WebRtc_Word16 WebRtcVad_Create(VadInst **vad_inst);

/****************************************************************************
 * WebRtcVad_Free(...)
 *
 * This function frees the dynamic memory of a specified VAD instance
 *
 * Input:
 *      - vad_inst      : Pointer to VAD instance that should be freed
 *
 * Return value         :  0 - Ok
 *                        -1 - Error
 */
WebRtc_Word16 WebRtcVad_Free(VadInst *vad_inst);

/****************************************************************************
 * WebRtcVad_Init(...)
 *
 * This function initializes a VAD instance
 *
 * Input:
 *      - vad_inst      : Instance that should be initialized
 *
 * Output:
 *      - vad_inst      : Initialized instance
 *
 * Return value         :  0 - Ok
 *                        -1 - Error
 */
WebRtc_Word16 WebRtcVad_Init(VadInst *vad_inst);

/****************************************************************************
 * WebRtcVad_set_mode(...)
 *
 * This function initializes a VAD instance
 *
 * Input:
 *      - vad_inst      : VAD instance
 *      - mode          : Aggressiveness setting (0, 1, 2, or 3) 
 *
 * Output:
 *      - vad_inst      : Initialized instance
 *
 * Return value         :  0 - Ok
 *                        -1 - Error
 */
WebRtc_Word16 WebRtcVad_set_mode(VadInst *vad_inst, WebRtc_Word16 mode);

/****************************************************************************
 * WebRtcVad_Process(...)
 * 
 * This functions does a VAD for the inserted speech frame
 *
 * Input
 *        - vad_inst     : VAD Instance. Needs to be initiated before call.
 *        - fs           : sampling frequency (Hz): 8000, 16000, or 32000
 *        - speech_frame : Pointer to speech frame buffer
 *        - frame_length : Length of speech frame buffer in number of samples
 *
 * Output:
 *        - vad_inst     : Updated VAD instance
 *
 * Return value          :  1 - Active Voice
 *                          0 - Non-active Voice
 *                         -1 - Error
 */
WebRtc_Word16 WebRtcVad_Process(VadInst *vad_inst,
                                WebRtc_Word16 fs,
                                WebRtc_Word16 *speech_frame,
                                WebRtc_Word16 frame_length);

#ifdef __cplusplus
}
#endif

#endif // WEBRTC_VAD_WEBRTC_VAD_H_