zohann commited on
Commit
9ef2672
·
verified ·
1 Parent(s): e41bbf1

Upload Audio_Effects_SDK/nvafx/include/nvAudioEffects.h with huggingface_hub

Browse files
Audio_Effects_SDK/nvafx/include/nvAudioEffects.h ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved.
3
+
4
+ NVIDIA CORPORATION and its licensors retain all intellectual property
5
+ and proprietary rights in and to this software, related documentation
6
+ and any modifications thereto. Any use, reproduction, disclosure or
7
+ distribution of this software and related documentation without an express
8
+ license agreement from NVIDIA CORPORATION is strictly prohibited.
9
+ */
10
+
11
+ /* AUDIOEFFECTS_VERSION_1.3.0 */
12
+
13
+ #ifndef __linux__
14
+ #error "This header is only supported on linux."
15
+ #endif /* __linux__ */
16
+
17
+ #ifndef __NVAUDIOEFFECTS_H__
18
+ #define __NVAUDIOEFFECTS_H__
19
+
20
+ #if defined(__cplusplus)
21
+ extern "C" {
22
+ #endif
23
+
24
+ /** API return values */
25
+ typedef enum {
26
+ /** Success */
27
+ NVAFX_STATUS_SUCCESS = 0,
28
+ /** Failure */
29
+ NVAFX_STATUS_FAILED = 1,
30
+ /** Handle invalid */
31
+ NVAFX_STATUS_INVALID_HANDLE = 2,
32
+ /** Parameter value invalid */
33
+ NVAFX_STATUS_INVALID_PARAM = 3,
34
+ /** Parameter value immutable */
35
+ NVAFX_STATUS_IMMUTABLE_PARAM = 4,
36
+ /** Insufficient data to process */
37
+ NVAFX_STATUS_INSUFFICIENT_DATA = 5,
38
+ /** Effect not supported */
39
+ NVAFX_STATUS_EFFECT_NOT_AVAILABLE = 6,
40
+ /** Given buffer length too small to hold requested data */
41
+ NVAFX_STATUS_OUTPUT_BUFFER_TOO_SMALL = 7,
42
+ /** Model file could not be loaded */
43
+ NVAFX_STATUS_MODEL_LOAD_FAILED = 8,
44
+ /** Model is not loaded, it needs to be loaded for this operation */
45
+ NVAFX_STATUS_MODEL_NOT_LOADED = 9,
46
+ /** Selected model is incompatible */
47
+ NVAFX_STATUS_INCOMPATIBLE_MODEL = 10,
48
+ /** The selected GPU is not supported. The SDK requires Turing and above GPU with Tensor cores */
49
+ NVAFX_STATUS_GPU_UNSUPPORTED = 11,
50
+ /** No supported GPU found on the system */
51
+ NVAFX_STATUS_NO_SUPPORTED_GPU_FOUND = 12,
52
+ /** Current GPU is not the one selected */
53
+ NVAFX_STATUS_WRONG_GPU = 13,
54
+ /** Cuda operation failure */
55
+ NVAFX_STATUS_CUDA_ERROR = 14,
56
+ /** Invalid operation performed **/
57
+ NVAFX_STATUS_INVALID_OPERATION = 15,
58
+ /** CUDA runtime is less than supported version*/
59
+ NVAFX_UNSUPPORTED_RUNTIME = 16
60
+ } NvAFX_Status;
61
+
62
+ /** Bool type (stdbool is available only with C99) */
63
+ #define NVAFX_TRUE 1
64
+ #define NVAFX_FALSE 0
65
+ typedef char NvAFX_Bool;
66
+
67
+ /** Minimum supported cuda runtime is 11.8 */
68
+ #define CUDA_SUPPORTED_RUNTIME 11080
69
+
70
+ /** Logging level to enable, each level is inclusive of the level preceding it */
71
+ typedef enum LoggingSeverity_t {
72
+ LOG_LEVEL_ERROR,
73
+ LOG_LEVEL_WARNING,
74
+ LOG_LEVEL_INFO,
75
+ } LoggingSeverity;
76
+
77
+ typedef enum LoggingTarget_t
78
+ {
79
+ // No logging.
80
+ LOG_TARGET_NONE = 0x0,
81
+ // Log to stderr.
82
+ LOG_TARGET_STDERR = 0x1,
83
+ // Log to specified file.
84
+ LOG_TARGET_FILE = 0x2,
85
+ // Log through invocation of a user-specified callback.
86
+ LOG_TARGET_CALLBACK = 0x4,
87
+ } LoggingTarget;
88
+
89
+ inline const char* LogSeverityToString(LoggingSeverity severity) {
90
+ switch (severity) {
91
+ case LOG_LEVEL_ERROR: return "ERROR";
92
+ case LOG_LEVEL_WARNING: return "WARNING";
93
+ case LOG_LEVEL_INFO: return "INFO";
94
+ default: return "UNKNOWN";
95
+ }
96
+ }
97
+
98
+ /** Function used for logging callback */
99
+ typedef void(*logging_cb_t)(LoggingSeverity level, const char* log, void* userdata);
100
+
101
+ /** We use strings as effect selectors */
102
+ typedef const char* NvAFX_EffectSelector;
103
+
104
+ /** We use strings as parameter selectors. */
105
+ typedef const char* NvAFX_ParameterSelector;
106
+
107
+ /** Each effect instantiation is associated with an opaque handle. */
108
+ typedef void* NvAFX_Handle;
109
+
110
+ /** @brief Get a list of audio effects supported
111
+ *
112
+ * @param[out] num_effects Number of effects returned in effects array
113
+ * @param[out] effects A list of effects returned by the API. This list is
114
+ * statically allocated by the API implementation. Caller
115
+ * does not need to allocate.
116
+ *
117
+ * @return Status values as enumerated in @ref NvAFX_Status
118
+ */
119
+ NvAFX_Status NvAFX_GetEffectList(int* num_effects, NvAFX_EffectSelector* effects[]);
120
+
121
+ /** @brief Create a new instance of an audio effect.
122
+ *
123
+ * @param[in] code The selector code for the desired audio Effect.
124
+ * @param[out] effect A handle to the effect instance.
125
+ *
126
+ * @return Status values as enumerated in @ref NvAFX_Status
127
+ */
128
+ NvAFX_Status NvAFX_CreateEffect(NvAFX_EffectSelector code, NvAFX_Handle* effect);
129
+
130
+ /** @brief Create a new instance of a chained audio effect.
131
+ *
132
+ * @param[in] code The selector code for the desired chain.
133
+ * @param[out] effect A handle to the created effect instance.
134
+ */
135
+ NvAFX_Status NvAFX_CreateChainedEffect(NvAFX_EffectSelector code, NvAFX_Handle* effect);
136
+
137
+ /** @brief Delete a previously instantiated audio Effect.
138
+ *
139
+ * @param[in] effect A handle to the audio Effect to be deleted.
140
+ *
141
+ * @return Status values as enumerated in @ref NvAFX_Status
142
+ */
143
+ NvAFX_Status NvAFX_DestroyEffect(NvAFX_Handle effect);
144
+
145
+ /** Set the value of the selected parameter (unsigned int, char*, float)
146
+ *
147
+ * @param[in] effect The effect to configure.
148
+ * @param[in] param_name The selector of the effect parameter to configure.
149
+ * @param[in] val The value to be assigned to the selected effect parameter.
150
+ * @param[in] list[] The list with values to be assigned to the selected effect parameter.
151
+ * @param[in] list_size Number of elements of the list[]
152
+
153
+ * @return Status values as enumerated in @ref NvAFX_Status
154
+ */
155
+ NvAFX_Status NvAFX_SetU32(NvAFX_Handle effect, NvAFX_ParameterSelector param_name,
156
+ unsigned int val);
157
+ NvAFX_Status NvAFX_SetU32List(NvAFX_Handle effect, NvAFX_ParameterSelector param_name,
158
+ unsigned int* list, unsigned int list_size);
159
+ NvAFX_Status NvAFX_SetString(NvAFX_Handle effect, NvAFX_ParameterSelector param_name,
160
+ const char* val);
161
+ NvAFX_Status NvAFX_SetStringList(NvAFX_Handle effect, NvAFX_ParameterSelector param_name,
162
+ const char** list, unsigned int list_size);
163
+ NvAFX_Status NvAFX_SetFloat(NvAFX_Handle effect, NvAFX_ParameterSelector param_name, float val);
164
+ NvAFX_Status NvAFX_SetBoolList(NvAFX_Handle effect, NvAFX_ParameterSelector param_name,
165
+ const NvAFX_Bool* list, unsigned int list_size);
166
+
167
+ /** Get the value of the selected parameter (unsigned int, char*, float)
168
+ *
169
+ * @param[in] effect The effect handle.
170
+ * @param[in] param_name The selector of the effect parameter to read.
171
+ * @param[out] val Buffer in which the parameter value will be assigned.
172
+ * @param[in] max_length The length in bytes of the buffer provided.
173
+ * @param[out] list[] The list with values to be retrieved for the selected effect parameter.
174
+ * @param[out] list_size Number of elements of list[]
175
+ *
176
+ * @return Status values as enumerated in @ref NvAFX_Status
177
+ */
178
+ NvAFX_Status NvAFX_GetU32(NvAFX_Handle effect, NvAFX_ParameterSelector param_name, unsigned int* val);
179
+ NvAFX_Status NvAFX_GetString(NvAFX_Handle effect, NvAFX_ParameterSelector param_name,
180
+ char* val, int max_length);
181
+ NvAFX_Status NvAFX_GetFloat(NvAFX_Handle effect, NvAFX_ParameterSelector param_name, float* val);
182
+ NvAFX_Status NvAFX_GetU32List(NvAFX_Handle effect, NvAFX_ParameterSelector param_name,
183
+ unsigned int* list, unsigned int* list_size);
184
+ NvAFX_Status NvAFX_GetBoolList(NvAFX_Handle effect, NvAFX_ParameterSelector param_name,
185
+ NvAFX_Bool* list, unsigned int* list_size);
186
+
187
+ /** Load the Effect based on the set params.
188
+ *
189
+ * @param[in] effect The effect object handle.
190
+ *
191
+ * @return Status values as enumerated in @ref NvAFX_Status
192
+ */
193
+ NvAFX_Status NvAFX_Load(NvAFX_Handle effect);
194
+
195
+ /** Process the input buffer as per the effect selected. e.g. denoising
196
+ *
197
+ * @note The input float data is expected to be standard 32-bit float type with values in range [-1.0, +1.0]
198
+ *
199
+ * @param[in] effect The effect handle.
200
+ * @param[in] input Input float buffer array. It points to an array of buffers where each buffer holds
201
+ * audio data for a single channel. Array size should be same as number of
202
+ * input channels expected by the effect. Also ensure sampling rate is same as
203
+ * expected by the Effect.
204
+ * For e.g. for denoiser it should be equal to the value returned by NvAFX_GetU32()
205
+ * returned value for NVAFX_FIXED_PARAM_SAMPLE_RATE parameter.
206
+ * @param[out] output Output float buffer array. The layout is same as input. It points to an an array of
207
+ * buffers where buffer has audio data corresponding to that channel. The buffers have
208
+ * to be preallocated by caller. Size of each buffer (i.e. channel) is same as that of
209
+ * input. However, number of channels may differ (can be queried by calling
210
+ * NvAFX_GetU32() with NVAFX_PARAM_NUM_OUTPUT_CHANNELS as parameter).
211
+ * @param[in] num_samples The number of samples in the input buffer. After this call returns output will
212
+ * have same number of samples.
213
+ * @param[in] num_channels The number of channels in the input buffer. The @a input should point
214
+ * to @ num_channels number of buffers for input, which can be determined by
215
+ * calling NvAFX_GetU32() with NVAFX_PARAM_NUM_INPUT_CHANNELS as parameter.
216
+ *
217
+ * @return Status values as enumerated in @ref NvAFX_Status
218
+ */
219
+ NvAFX_Status NvAFX_Run(NvAFX_Handle effect, const float** input, float** output,
220
+ unsigned num_input_samples, unsigned num_input_channels);
221
+
222
+
223
+ /** Reset effect state
224
+ *
225
+ * @note Allows the state of an effect to be reset. This operation will reset the state of selected in the next
226
+ * NvAFX_Run call
227
+ *
228
+ * @param[in] effect The effect handle.
229
+ * @param[in] bitmap Array of NvAFX_Bool parameters which indicates whether a stream is to be reset.
230
+ * If the i-th stream is to be reset, the i-th value of the array should be set to NVAFX_TRUE,
231
+ * else it should be set to NVAFX_FALSE.
232
+ * @param[in] length The length of the array.
233
+ *
234
+ * @return Status values as enumerated in @ref NvAFX_Status
235
+ */
236
+ NvAFX_Status NvAFX_Reset(NvAFX_Handle effect, NvAFX_Bool* bitmap, int length);
237
+
238
+ /** Initialize Logger
239
+ *
240
+ * @note Initializes Logger
241
+ *
242
+ * @param[in] level The logging level to enable.
243
+ * @param[in] LoggingTarget Logging targets to write logs to, LoggingTarget_t can be OR'd
244
+ * @param[in] filename The name of the file where to write logs.
245
+ * @param[in] cb Callback to use if LOG_TARGET_CALLBACK is enabled.
246
+ * @param[in] userdata Data passed back with log callback. Used only when LOG_TARGET_CALLBACK
247
+ * is enabled.
248
+ *
249
+ * @return Status values as enumerated in @ref NvAFX_Status
250
+ */
251
+ NvAFX_Status NvAFX_InitializeLogger(LoggingSeverity level, int target,
252
+ const char *filename, logging_cb_t cb,
253
+ void* userdata);
254
+
255
+ /** Un-initializes Logger
256
+ *
257
+ * @note Un-initializes Logger
258
+ *
259
+ * @return Status values as enumerated in @ref NvAFX_Status
260
+ */
261
+ NvAFX_Status NvAFX_UninitializeLogger();
262
+
263
+ /** Effect selectors. @ref NvAFX_EffectSelector */
264
+
265
+ /** Denoiser Effect */
266
+ #define NVAFX_EFFECT_DENOISER "denoiser"
267
+ /** De-reverb Effect */
268
+ #define NVAFX_EFFECT_DEREVERB "dereverb"
269
+ /** Combined De-reverb and Denoiser Effects */
270
+ #define NVAFX_EFFECT_DEREVERB_DENOISER "dereverb_denoiser"
271
+ /** Aucostic Echo Cancellation Effect */
272
+ #define NVAFX_EFFECT_AEC "aec"
273
+ /** Super-resolution Effect */
274
+ #define NVAFX_EFFECT_SUPERRES "superres"
275
+
276
+ /** Denoiser 16k + Superres 16k to 48k */
277
+ #define NVAFX_CHAINED_EFFECT_DENOISER_16k_SUPERRES_16k_TO_48k "denoiser16k_superres16kto48k"
278
+ /** De-reverb 16k + Superres 16k to 48k */
279
+ #define NVAFX_CHAINED_EFFECT_DEREVERB_16k_SUPERRES_16k_TO_48k "dereverb16k_superres16kto48k"
280
+ /** Combined De-reverb and Denoiser 16k + Superres 16k to 48k */
281
+ #define NVAFX_CHAINED_EFFECT_DEREVERB_DENOISER_16k_SUPERRES_16k_TO_48k "dereverb_denoiser16k_superres16kto48k"
282
+ /** Superres 8k to 16k + Denoiser 16k */
283
+ #define NVAFX_CHAINED_EFFECT_SUPERRES_8k_TO_16k_DENOISER_16k "superres8kto16k_denoiser16k"
284
+ /** Superres 8k to 16k + De-reverb 16k */
285
+ #define NVAFX_CHAINED_EFFECT_SUPERRES_8k_TO_16k_DEREVERB_16k "superres8kto16k_dereverb16k"
286
+ /** Superres 8k to 16k + Combined De-reverb and Denoiser 16k */
287
+ #define NVAFX_CHAINED_EFFECT_SUPERRES_8k_TO_16k_DEREVERB_DENOISER_16k "superres8kto16k_dereverb_denoiser16k"
288
+
289
+ /** Parameter selectors */
290
+
291
+ /** Common Effect parameters. @ref NvAFX_ParameterSelector */
292
+ /** Stream activity flags for each stream (NvAFX_Bool[]) */
293
+ #define NVAFX_PARAM_ACTIVE_STREAMS "active_streams"
294
+ /** Scalar defining the strength of the effect (float). Can only range from 0 to 1. */
295
+ #define NVAFX_PARAM_INTENSITY_RATIO "intensity_ratio"
296
+ /** Model path (char*) for the Effect */
297
+ #define NVAFX_PARAM_MODEL_PATH "model_path"
298
+ /** Number of input audio channels */
299
+ #define NVAFX_PARAM_NUM_INPUT_CHANNELS "num_input_channels"
300
+ /** Number of output audio channels */
301
+ #define NVAFX_PARAM_NUM_OUTPUT_CHANNELS "num_output_channels"
302
+ /** Number of input audio samples per input channel processed in a call to NvAFX_Run */
303
+ #define NVAFX_PARAM_NUM_SAMPLES_PER_INPUT_FRAME "num_samples_per_input_frame"
304
+ /** Number of output audio samples per input channel processed in a call to NvAFX_Run */
305
+ #define NVAFX_PARAM_NUM_SAMPLES_PER_OUTPUT_FRAME "num_samples_per_output_frame"
306
+ /** Number of audio streams in I/O (unsigned int). */
307
+ #define NVAFX_PARAM_NUM_STREAMS "num_streams"
308
+ /** Sample rate (unsigned int) of input audio streams.
309
+ Currently supported sample rate(s): 48000, 16000. */
310
+ #define NVAFX_PARAM_INPUT_SAMPLE_RATE "input_sample_rate"
311
+ /** Output sample rate. */
312
+ #define NVAFX_PARAM_OUTPUT_SAMPLE_RATE "output_sample_rate"
313
+ /** Supported number of samples per frame (unsigned int*[]) for the effect */
314
+ #define NVAFX_PARAM_SUPPORTED_NUM_SAMPLES_PER_FRAME "supported_num_samples_per_frame"
315
+ /** To set if SDK should select the default GPU to run the effects in a Multi-GPU setup
316
+ (unsigned int). Default value is 0. Please see user manual for details. */
317
+ #define NVAFX_PARAM_USE_DEFAULT_GPU "use_default_gpu"
318
+ /** Enable/disable VAD (set 1 to enable, 0 to disable disabled by default) */
319
+ #define NVAFX_PARAM_ENABLE_VAD "enable_vad"
320
+ /** Voice activity status (boolean). This is immutable parameter */
321
+ #define NVAFX_PARAM_VAD_RESULT "vad_result"
322
+ /** GPUs to run effect on (chained effects only). Please see user manual for details */
323
+ #define NVAFX_PARAM_CHAINED_EFFECT_GPU_LIST "chained_effect_gpu_list"
324
+
325
+ /** Deprecated parameters */
326
+ /** Denoiser Model Path v0.5 */
327
+ #define NVAFX_PARAM_DENOISER_MODEL_PATH NVAFX_PARAM_MODEL_PATH
328
+ /** Denoiser sample rate v0.5 */
329
+ #define NVAFX_PARAM_DENOISER_SAMPLE_RATE NVAFX_PARAM_SAMPLE_RATE
330
+ /** Denoiser number of samples per frame v0.5 */
331
+ #define NVAFX_PARAM_DENOISER_NUM_SAMPLES_PER_FRAME NVAFX_PARAM_NUM_SAMPLES_PER_FRAME
332
+ /** Denoiser number of audio channels v0.5 */
333
+ #define NVAFX_PARAM_DENOISER_NUM_CHANNELS NVAFX_PARAM_NUM_CHANNELS
334
+ /** Denoising factor v0.5 */
335
+ #define NVAFX_PARAM_DENOISER_INTENSITY_RATIO NVAFX_PARAM_INTENSITY_RATIO
336
+ #define NVAFX_PARAM_DENOISER_SUPPORTED_NUM_SAMPLES_PER_FRAME NVAFX_PARAM_SUPPORTED_NUM_SAMPLES_PER_FRAME
337
+ /** Number of audio channels in I/O v1.0*/
338
+ #define NVAFX_PARAM_NUM_CHANNELS "num_channels"
339
+ /** Number of audio samples processed in a call to NvAFX_Run v1.0 parameter. */
340
+ #define NVAFX_PARAM_NUM_SAMPLES_PER_FRAME "num_samples_per_frame"
341
+ /** Sample rate (unsigned int) of audio streams v1.0 parameter. */
342
+ #define NVAFX_PARAM_SAMPLE_RATE "sample_rate"
343
+
344
+
345
+ #if defined(__cplusplus)
346
+ }
347
+ #endif
348
+
349
+ #endif /* __NVAUDIOEFFECTS_H__ */