DesignAEC

Version 19 (Adrian Georgescu, 07/25/2010 09:14 am)

1 18 Adrian Georgescu
= Acoustic Echo cancellation =
2 1 Adrian Georgescu
3 1 Adrian Georgescu
[[TOC(Design*, depth=1)]]
4 1 Adrian Georgescu
5 1 Adrian Georgescu
SIP SIMPLE client is a Python software library that allows for easy development of Internet communications end-points based on SIP and related protocols for voice, rich presence, session based instant messaging (IM), file transfers and desktop sharing. Other media types can be easily added by using an extensible high-level API. SIP SIMPLE client uses [http://www.pjsip.org/pjmedia/docs/html/index.htm PJSIP media library] for audio processing (sound card abstraction, audio codec and acoustic echo cancellation).
6 1 Adrian Georgescu
7 18 Adrian Georgescu
For more information see http://sipsimpleclient.com. The project is maintained by AG Projects that can provide help to the developer to integrate its AEC implementation.
8 16 Adrian Georgescu
9 1 Adrian Georgescu
== Background ==
10 1 Adrian Georgescu
11 18 Adrian Georgescu
The present implementation of the Acoustic Echo Canceller from PJSIP media library is not performing to the desired level of quality. Practically, the speakerphone function is not performing satisfactory. The result is that the software phone cannot be used without a head-set, which make people use proprietary applications like Skype or Google Talk.
12 1 Adrian Georgescu
13 1 Adrian Georgescu
[[Image(http://www.pjsip.org/images/media-flow.jpg)]]
14 1 Adrian Georgescu
15 1 Adrian Georgescu
== Project goal ==
16 1 Adrian Georgescu
17 1 Adrian Georgescu
Replace the existing AEC from Pjmedia library (what is displayed as echo.h in the above diagram whihc employes the AEC of the speex project) with an alternative to be developed solution that provides a high quality speakerphone user experience. The acoustic echo cancelation should perform comparable with any other proven VoIP commercial solution like Skype or iChat making the need of a headset un-necessary.
18 1 Adrian Georgescu
19 18 Adrian Georgescu
The developed software will be released under an Open Source licence and distributed with SIP SIMPLE client library. The deliverable is C written program that can be applied to the pjsip  cvs trunk 1.0 with the '''patch''' command.
20 11 Adrian Georgescu
21 1 Adrian Georgescu
== Resources ==
22 1 Adrian Georgescu
23 1 Adrian Georgescu
General
24 1 Adrian Georgescu
25 7 Adrian Georgescu
 * Digital Signal Processing http://www.dsptutor.freeuk.com/
26 1 Adrian Georgescu
 * Graduation thesis about AEC  http://innovexpo.itee.uq.edu.au/2003/exhibits/s365914/
27 7 Adrian Georgescu
 * DSP concepts: http://www.bores.com/courses/intro/basics/index.htm
28 7 Adrian Georgescu
29 18 Adrian Georgescu
== PJMEDIA ==
30 1 Adrian Georgescu
31 18 Adrian Georgescu
This is the actual audio library used by SIP SIMPLE client. It is part of PJSIP, a complete framework for building SIP clients, having an open source license.
32 18 Adrian Georgescu
33 1 Adrian Georgescu
 * PJSIP media library http://pjsip.org, used by this project, AEC is implemented based on the Speex library, the code in pjsip/pjmedia/src/pjmedia/echo_speex.c 
34 1 Adrian Georgescu
 * Media flow - http://trac.pjsip.org/repos/wiki/media-flow
35 12 Adrian Georgescu
 * PJSIP AEC API http://www.pjsip.org/pjmedia/docs/html/group__PJMEDIA__Echo__Cancel.htm
36 1 Adrian Georgescu
37 1 Adrian Georgescu
=== Speex AEC ===
38 1 Adrian Georgescu
39 18 Adrian Georgescu
This is the AEC algorithm used by PJMEDIA that needs to be replaced by a better solution. The actual code is maintained by http://speex.org project.
40 15 Adrian Georgescu
41 1 Adrian Georgescu
 * Speex project http://speex.org, the echo canceller implements AEC based on the MDF algorithm, see speex/libspeex/mdf.c. A test client is available in speex/speexclient, this has been used for developing pjmedia equivalent
42 6 Adrian Georgescu
 * http://speex.org/docs/api/speex-api-reference/group__SpeexEchoState.html
43 1 Adrian Georgescu
44 1 Adrian Georgescu
=== Andree Adrian AEC ===
45 1 Adrian Georgescu
46 17 Adrian Georgescu
Research for other implementations revealed a well documented algorithm together with source code as C++ implementation. 
47 17 Adrian Georgescu
48 1 Adrian Georgescu
 * Draft AEC http://www.andreadrian.de/echo_cancel/draft-aec-03.txt
49 17 Adrian Georgescu
50 17 Adrian Georgescu
The white-paper gave enough insight and trust into its author understanding and capability of implementation for considering its blueprint as an alternative. Unfortunately, the author's claims about its high quality could not be tested, due to the fact that his C++ code dates back from 2004 and the application that used it could not be compiled on todays newer systems.
51 17 Adrian Georgescu
52 1 Adrian Georgescu
 * Kphone AEC implemented using above AEC http://www.andreadrian.de/echo_cancel/ (not tested)
53 17 Adrian Georgescu
 * http://www.andreadrian.de/intercom/ implements AEC based on NLMS algorithm (not tested yet)
54 1 Adrian Georgescu
55 17 Adrian Georgescu
Finally, this AEC has been implemented by a student in plain C and integrated to the SIP SIMPLE project. It does not work properly, audio artifacts being present and further debugging requires DSP knowledge which the developer did not have.
56 1 Adrian Georgescu
57 17 Adrian Georgescu
The actual implementation can be used as working example for how a third party AEC algorithm can be integrated with the SIP SIMPLE project. See attached file for more information.
58 1 Adrian Georgescu
59 1 Adrian Georgescu
== Next steps ==
60 16 Adrian Georgescu
61 17 Adrian Georgescu
At this stage the problem has not been solved due to the lack of knowledge of the developers in this specialized DSP area.
62 17 Adrian Georgescu
63 16 Adrian Georgescu
There are two choices for going further:
64 16 Adrian Georgescu
65 17 Adrian Georgescu
 1. Implement an AEC from scratch and integrated with PJSIP based on its API
66 17 Adrian Georgescu
 2. Debug and fix  Andree Adrian AEC, an analysis of the code  can reveal if the concept is valid but poorly implemented
67 19 Adrian Georgescu
68 19 Adrian Georgescu
69 19 Adrian Georgescu
The AEC software solution should have basically three blocks: 
70 19 Adrian Georgescu
71 19 Adrian Georgescu
== The adaptive filter ==
72 19 Adrian Georgescu
73 19 Adrian Georgescu
Here are to subject for testing NLMS and Kallman algorithms that will approximate the transfer function of the room for the LE (Local End).
74 19 Adrian Georgescu
75 19 Adrian Georgescu
== Double-talk detector ==
76 19 Adrian Georgescu
77 19 Adrian Georgescu
DTD block will be used to detect the double talking in both ends (LE and FE-far end) for full duplex. To implement the DTD here can be considered the next algorithms: Geigel, Cross Correlation, VIRE- variable impulse response and the Gansler optimization (used in Speex)
78 19 Adrian Georgescu
79 19 Adrian Georgescu
== Non-linear processor ==
80 19 Adrian Georgescu
81 19 Adrian Georgescu
NLP block will eliminate the rest of the echo already canceled (the laptop's fan, or the keyboard sounds or the HDD and other types of sounds that are considered noise non-speech. Also in this block can be added some processing tasks that are deeply nonlinears like: increasing the SNR for the small volumed speech signals, eliminate the clipping, smooth transitions between the small signals and loader signals (only voices) and correcting the errors from the previews processing algorithms.
82 19 Adrian Georgescu
 
83 19 Adrian Georgescu
For the supplementary block the idea is to expand the performance of the component and to perform robust cancellation (add more control logic, increase DTD using mutual information for stereo devices, improve the stability of the adaptive filter using the Wiener-Hammerstein method to keep on the convergence of the filter and using Volterra model) and to use the maximum information from all the codecs that are included.