~ubuntu-branches/ubuntu/saucy/sflphone/saucy

« back to all changes in this revision

Viewing changes to sflphone-common/src/audio/noisesuppress.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2010-12-24 16:33:55 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101224163355-tkvvikqxbrbav6up
Tags: 0.9.11-1
* New upstream release
* Add new build dependencies on libwebkit-dev and libyaml-dev

* Bump Standards-Version up to 3.9.1
* Bump debhelper compatibility to 8
* Patch another typo in the upstream code (lintian notice)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc.
 
3
 *  Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
 
4
 *
 
5
 *  This program is free software; you can redistribute it and/or modify
 
6
 *  it under the terms of the GNU General Public License as published by
 
7
 *  the Free Software Foundation; either version 3 of the License, or
 
8
 *  (at your option) any later version.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
 *
 
19
 *  Additional permission under GNU GPL version 3 section 7:
 
20
 *
 
21
 *  If you modify this program, or any covered work, by linking or
 
22
 *  combining it with the OpenSSL project's OpenSSL library (or a
 
23
 *  modified version of that library), containing parts covered by the
 
24
 *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
 
25
 *  grants you additional permission to convey the resulting work.
 
26
 *  Corresponding Source for a non-source form of such a combination
 
27
 *  shall include the source code for the parts of OpenSSL used as well
 
28
 *  as that of the covered work.
 
29
 */
 
30
 
 
31
#include "noisesuppress.h"
 
32
 
 
33
NoiseSuppress::NoiseSuppress (int smplPerFrame, int samplingRate) : _noiseState (NULL)
 
34
    , _smplPerFrame (smplPerFrame)
 
35
    , _samplingRate (samplingRate)
 
36
{
 
37
    initNewNoiseSuppressor (_smplPerFrame, _samplingRate);
 
38
}
 
39
 
 
40
 
 
41
NoiseSuppress::~NoiseSuppress()
 
42
{
 
43
    speex_preprocess_state_destroy (_noiseState);
 
44
}
 
45
 
 
46
void NoiseSuppress::reset (void)
 
47
{
 
48
 
 
49
    speex_preprocess_state_destroy (_noiseState);
 
50
 
 
51
    initNewNoiseSuppressor (_smplPerFrame, _samplingRate);
 
52
}
 
53
 
 
54
void NoiseSuppress::putData (SFLDataFormat *inputData, int nbBytes) {}
 
55
 
 
56
int NoiseSuppress::getData (SFLDataFormat *outputData)
 
57
{
 
58
    return 0;
 
59
}
 
60
 
 
61
void NoiseSuppress::process (SFLDataFormat *data, int nbBytes)
 
62
{
 
63
    if (_noiseState)
 
64
        speex_preprocess_run (_noiseState, data);
 
65
}
 
66
 
 
67
int NoiseSuppress::process (SFLDataFormat *inputData, SFLDataFormat *outputData, int nbBytes)
 
68
{
 
69
    return 0;
 
70
}
 
71
 
 
72
void NoiseSuppress::process (SFLDataFormat *micData, SFLDataFormat *spkrData, SFLDataFormat *outputData, int nbBytes) {}
 
73
 
 
74
void NoiseSuppress::initNewNoiseSuppressor (int smplPerFrame, int samplingRate)
 
75
{
 
76
    _noiseState = speex_preprocess_state_init (smplPerFrame, samplingRate);
 
77
    int i=1;
 
78
    speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_DENOISE, &i);
 
79
    i=-20;
 
80
    speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &i);
 
81
    i=0;
 
82
    speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_AGC, &i);
 
83
    i=8000;
 
84
    speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_AGC_TARGET, &i);
 
85
    i=16000;
 
86
    speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_AGC_LEVEL, &i);
 
87
    i=0;
 
88
    speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_DEREVERB, &i);
 
89
    float f=0.0;
 
90
    speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_DEREVERB_DECAY, &f);
 
91
    f=0.0;
 
92
    speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_DEREVERB_LEVEL, &f);
 
93
    i = 0;
 
94
    speex_preprocess_ctl (_noiseState, SPEEX_PREPROCESS_SET_VAD, &i);
 
95
}