Tzafrir Cohen | 17f8c11 | 2008-10-12 06:03:14 +0200 | [diff] [blame] | 1 | /* |
| 2 | * OSLEC - A line echo canceller. This code is being developed |
| 3 | * against and partially complies with G168. Using code from SpanDSP |
| 4 | * |
| 5 | * Written by Steve Underwood <steveu@coppice.org> |
| 6 | * and David Rowe <david_at_rowetel_dot_com> |
| 7 | * |
| 8 | * Copyright (C) 2001 Steve Underwood and 2007-2008 David Rowe |
| 9 | * |
| 10 | * All rights reserved. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License version 2, as |
| 14 | * published by the Free Software Foundation. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | #ifndef __OSLEC_H |
| 28 | #define __OSLEC_H |
| 29 | |
| 30 | /* TODO: document interface */ |
| 31 | |
| 32 | /* Mask bits for the adaption mode */ |
| 33 | #define ECHO_CAN_USE_ADAPTION 0x01 |
| 34 | #define ECHO_CAN_USE_NLP 0x02 |
| 35 | #define ECHO_CAN_USE_CNG 0x04 |
| 36 | #define ECHO_CAN_USE_CLIP 0x08 |
| 37 | #define ECHO_CAN_USE_TX_HPF 0x10 |
| 38 | #define ECHO_CAN_USE_RX_HPF 0x20 |
| 39 | #define ECHO_CAN_DISABLE 0x40 |
| 40 | |
| 41 | /*! |
| 42 | G.168 echo canceller descriptor. This defines the working state for a line |
| 43 | echo canceller. |
| 44 | */ |
Tzafrir Cohen | 9d8f2d5 | 2008-10-12 07:17:26 +0200 | [diff] [blame] | 45 | struct oslec_state; |
Tzafrir Cohen | 17f8c11 | 2008-10-12 06:03:14 +0200 | [diff] [blame] | 46 | |
| 47 | /*! Create a voice echo canceller context. |
| 48 | \param len The length of the canceller, in samples. |
| 49 | \return The new canceller context, or NULL if the canceller could not be created. |
| 50 | */ |
Tzafrir Cohen | 9d8f2d5 | 2008-10-12 07:17:26 +0200 | [diff] [blame] | 51 | struct oslec_state *oslec_create(int len, int adaption_mode); |
Tzafrir Cohen | 17f8c11 | 2008-10-12 06:03:14 +0200 | [diff] [blame] | 52 | |
| 53 | /*! Free a voice echo canceller context. |
| 54 | \param ec The echo canceller context. |
| 55 | */ |
Tzafrir Cohen | 9d8f2d5 | 2008-10-12 07:17:26 +0200 | [diff] [blame] | 56 | void oslec_free(struct oslec_state *ec); |
Tzafrir Cohen | 17f8c11 | 2008-10-12 06:03:14 +0200 | [diff] [blame] | 57 | |
| 58 | /*! Flush (reinitialise) a voice echo canceller context. |
| 59 | \param ec The echo canceller context. |
| 60 | */ |
Tzafrir Cohen | 9d8f2d5 | 2008-10-12 07:17:26 +0200 | [diff] [blame] | 61 | void oslec_flush(struct oslec_state *ec); |
Tzafrir Cohen | 17f8c11 | 2008-10-12 06:03:14 +0200 | [diff] [blame] | 62 | |
| 63 | /*! Set the adaption mode of a voice echo canceller context. |
| 64 | \param ec The echo canceller context. |
| 65 | \param adapt The mode. |
| 66 | */ |
Tzafrir Cohen | 9d8f2d5 | 2008-10-12 07:17:26 +0200 | [diff] [blame] | 67 | void oslec_adaption_mode(struct oslec_state *ec, int adaption_mode); |
Tzafrir Cohen | 17f8c11 | 2008-10-12 06:03:14 +0200 | [diff] [blame] | 68 | |
Tzafrir Cohen | 9d8f2d5 | 2008-10-12 07:17:26 +0200 | [diff] [blame] | 69 | void oslec_snapshot(struct oslec_state *ec); |
Tzafrir Cohen | 17f8c11 | 2008-10-12 06:03:14 +0200 | [diff] [blame] | 70 | |
| 71 | /*! Process a sample through a voice echo canceller. |
| 72 | \param ec The echo canceller context. |
| 73 | \param tx The transmitted audio sample. |
| 74 | \param rx The received audio sample. |
| 75 | \return The clean (echo cancelled) received sample. |
| 76 | */ |
Tzafrir Cohen | 9d8f2d5 | 2008-10-12 07:17:26 +0200 | [diff] [blame] | 77 | int16_t oslec_update(struct oslec_state *ec, int16_t tx, int16_t rx); |
Tzafrir Cohen | 17f8c11 | 2008-10-12 06:03:14 +0200 | [diff] [blame] | 78 | |
| 79 | /*! Process to high pass filter the tx signal. |
| 80 | \param ec The echo canceller context. |
| 81 | \param tx The transmitted auio sample. |
| 82 | \return The HP filtered transmit sample, send this to your D/A. |
| 83 | */ |
Tzafrir Cohen | 9d8f2d5 | 2008-10-12 07:17:26 +0200 | [diff] [blame] | 84 | int16_t oslec_hpf_tx(struct oslec_state *ec, int16_t tx); |
Tzafrir Cohen | 17f8c11 | 2008-10-12 06:03:14 +0200 | [diff] [blame] | 85 | |
J.R. Mauro | 4460a86 | 2008-10-20 19:01:31 -0400 | [diff] [blame] | 86 | #endif /* __OSLEC_H */ |