Line data Source code
1 : /*
2 : * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 : *
4 : * Use of this source code is governed by a BSD-style license
5 : * that can be found in the LICENSE file in the root of the source
6 : * tree. An additional intellectual property rights grant can be found
7 : * in the file PATENTS. All contributing project authors may
8 : * be found in the AUTHORS file in the root of the source tree.
9 : */
10 :
11 : #include "webrtc/modules/audio_processing/ns/noise_suppression.h"
12 :
13 : #include <stdlib.h>
14 : #include <string.h>
15 :
16 : #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h"
17 : #include "webrtc/modules/audio_processing/ns/defines.h"
18 : #include "webrtc/modules/audio_processing/ns/ns_core.h"
19 :
20 0 : NsHandle* WebRtcNs_Create() {
21 0 : NoiseSuppressionC* self = malloc(sizeof(NoiseSuppressionC));
22 0 : self->initFlag = 0;
23 0 : return (NsHandle*)self;
24 : }
25 :
26 0 : void WebRtcNs_Free(NsHandle* NS_inst) {
27 0 : free(NS_inst);
28 0 : }
29 :
30 0 : int WebRtcNs_Init(NsHandle* NS_inst, uint32_t fs) {
31 0 : return WebRtcNs_InitCore((NoiseSuppressionC*)NS_inst, fs);
32 : }
33 :
34 0 : int WebRtcNs_set_policy(NsHandle* NS_inst, int mode) {
35 0 : return WebRtcNs_set_policy_core((NoiseSuppressionC*)NS_inst, mode);
36 : }
37 :
38 0 : void WebRtcNs_Analyze(NsHandle* NS_inst, const float* spframe) {
39 0 : WebRtcNs_AnalyzeCore((NoiseSuppressionC*)NS_inst, spframe);
40 0 : }
41 :
42 0 : void WebRtcNs_Process(NsHandle* NS_inst,
43 : const float* const* spframe,
44 : size_t num_bands,
45 : float* const* outframe) {
46 0 : WebRtcNs_ProcessCore((NoiseSuppressionC*)NS_inst, spframe, num_bands,
47 : outframe);
48 0 : }
49 :
50 0 : float WebRtcNs_prior_speech_probability(NsHandle* handle) {
51 0 : NoiseSuppressionC* self = (NoiseSuppressionC*)handle;
52 0 : if (handle == NULL) {
53 0 : return -1;
54 : }
55 0 : if (self->initFlag == 0) {
56 0 : return -1;
57 : }
58 0 : return self->priorSpeechProb;
59 : }
60 :
61 0 : const float* WebRtcNs_noise_estimate(const NsHandle* handle) {
62 0 : const NoiseSuppressionC* self = (const NoiseSuppressionC*)handle;
63 0 : if (handle == NULL || self->initFlag == 0) {
64 0 : return NULL;
65 : }
66 0 : return self->noise;
67 : }
68 :
69 0 : size_t WebRtcNs_num_freq() {
70 0 : return HALF_ANAL_BLOCKL;
71 : }
|