speexechocancel.h 2.14 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 *  Copyright (C) 2008 2009 Savoir-Faire Linux inc.
 *  Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

20
21
#ifndef SPEEXECHOCANCEL_H
#define SPEEXECHOCANCEL_H
22

23
#include "global.h"
24

25
26
27
28
29
class RingBuffer;
class SpeexEchoState_;
typedef SpeexEchoState_ SpeexEchoState;
class SpeexPreprocessState_;
typedef SpeexPreprocessState_ SpeexPreprocessState;
30

31
class SpeexEchoCancel
Julien Bonjean's avatar
Julien Bonjean committed
32
33
{
    public:
34

Julien Bonjean's avatar
Julien Bonjean committed
35
36
        SpeexEchoCancel();
        ~SpeexEchoCancel();
37

Julien Bonjean's avatar
Julien Bonjean committed
38
39
40
41
        /**
         * Add speaker data into internal buffer
         * \param inputData containing far-end voice data to be sent to speakers
         */
42
        void putData (SFLDataFormat *, int samples);
43

Julien Bonjean's avatar
Julien Bonjean committed
44
45
46
47
48
        /**
         * Perform echo cancellation using internal buffers
         * \param inputData containing mixed echo and voice data
         * \param outputData containing
         */
49
        int process (SFLDataFormat *, SFLDataFormat *, int samples);
50

Julien Bonjean's avatar
Julien Bonjean committed
51
    private:
52

Julien Bonjean's avatar
Julien Bonjean committed
53
        SpeexEchoState *_echoState;
54

Julien Bonjean's avatar
Julien Bonjean committed
55
        SpeexPreprocessState *_preState;
56

Julien Bonjean's avatar
Julien Bonjean committed
57
58
        RingBuffer *_micData;
        RingBuffer *_spkrData;
59

60
61
62
        int _echoDelay;
        int _echoTailLength;

63
        bool _spkrStopped;
64

Julien Bonjean's avatar
Julien Bonjean committed
65
66
67
        SFLDataFormat _tmpSpkr[5000];
        SFLDataFormat _tmpMic[5000];
        SFLDataFormat _tmpOut[5000];
68

69
#ifdef DUMP_ECHOCANCEL_INTERNAL_DATA
Julien Bonjean's avatar
Julien Bonjean committed
70
71
        ofstream *micFile;
        ofstream *spkrFile;
72
73
        ofstream *micProcessFile;
        ofstream *spkrProcessFile;
Julien Bonjean's avatar
Julien Bonjean committed
74
        ofstream *echoFile;
75
#endif
76
};
77
78

#endif