AN1384 STMicroelectronics, AN1384 Datasheet

no-image

AN1384

Manufacturer Part Number
AN1384
Description
HANDLING TRAPS WITH THE ST120 CORE-2001-11-30
Manufacturer
STMicroelectronics
Datasheet
AN1384
APPLICATION NOTE
Implementing an Acoustic Echo Canceller
Algorithm using the ST120DSP
By Aude ANDOLFATTO
1 - INTRODUCTION
This application note describes an Acoustic Echo Canceller (16 bits, 8KHz, 256ms) implementation on
the ST120 DSP.
The first chapter presents the general principle of an AEC based on the NLMS (Normalized
Least-Mean-Squared) filtering.
The second, third, and fourth chapters detail the main parts of an AEC: nlms filtering, power estimation,
and speech detection.
The sixth and seventh chapters provide results concerning C floating point and C fixed point
implementation.
The last chapter describes the assembly implementation of the NLMS function and gives results in terms
of MCPS (Mega Cycle Per Second - of speech) and code size.
October 2001
1/28

Related parts for AN1384

AN1384 Summary of contents

Page 1

... The sixth and seventh chapters provide results concerning C floating point and C fixed point implementation. The last chapter describes the assembly implementation of the NLMS function and gives results in terms of MCPS (Mega Cycle Per Second - of speech) and code size. October 2001 APPLICATION NOTE Implementing an Acoustic Echo Canceller Algorithm using the ST120DSP AN1384 By Aude ANDOLFATTO 1/28 ...

Page 2

... AN1384 - APPLICATION NOTE TABLE OF CONTENTS 1 INTRODUCTION ........................................................................................................ 2 AEC ALGORITHM ..................................................................................................... 2.1 GENERAL PURPOSE ................................................................................................ 2.2 NLMS ALGORITHM ................................................................................................... 2.3 RESTRICTIONS ......................................................................................................... 3 NLMS ALGORITHM ................................................................................................... 4 SIGNAL POWER ESTIMATION ................................................................................ 5 SPEECH DETECTION ............................................................................................... 5.1 INTRODUCTION ........................................................................................................ 5.2 FAR-END SPEECH DETECTION .............................................................................. 5.3 DOUBLE TALK DETECTION ..................................................................................... 5.4 NEAR-END SPEECH DETECTION ........................................................................... 5.5 HANGOVER COUNTERS .......................................................................................... 5.6 SPEECH DETECTION PROGRAM FLOW ................................................................ 6 MEASUREMENTS ..................................................................................................... 6.1 ALGORITHM EFFICIENCY ........................................................................................ 6.1.1 Input Test Files ........................................................................................................... ...

Page 3

... Tests in Quiet Environment ........................................................................................ 8.3.2 Tests During Double-talk Conditions .......................................................................... 8.4 BENCH RESULTS ..................................................................................................... 8.4.1 Front End .................................................................................................................... 8.4.2 NLMS Filtering ............................................................................................................ 9 IMPROVING PERFORMANCES ............................................................................... 9.1 FIRST STEP ............................................................................................................... 9.2 SECOND STEP .......................................................................................................... 10 CONCLUSION ........................................................................................................... 11 ANNEX ....................................................................................................................... 11.1 ASM GENERATED BY GHS+LAO ............................................................................. AN1384 - APPLICATION NOTE 3/28 ...

Page 4

... AN1384 - APPLICATION NOTE 2 - AEC ALGORITHM 2.1 - General Purpose The coupling between a loudspeaker and a microphone generates some specific problems. The loudspeaker signal is echoed back to the microphone and transmitted back to its origin result, the far-end participant perceives this as an echo. The longer the transmission delay is, the more disturbing the acoustic echo is ...

Page 5

... The following table summarizes the AEC principle: Table 2 : AEC conditions and actions Conditions far-end speech alone double talk near-end speech AN1384 - APPLICATION NOTE Actions nlms algorithm: filtering and update Filtering BUT NO update Residual echo = near-end signal 5/28 ...

Page 6

... AN1384 - APPLICATION NOTE 3 - NLMS ALGORITHM The following steps constitute the NLMS algorithm: r ˆ k – Adaptive filter output: – Estimation error – Tap weight filter where --------------- is NLMS constant at given sample time and where is the step size. ...

Page 7

... These estimates are used in far-end and near-end speech detection important that the functionality of the speech detectors be accurate to avoid erroneous detection, which could lead to an unstable system AN1384 - APPLICATION NOTE 7/28 ...

Page 8

... AN1384 - APPLICATION NOTE 5 - SPEECH DETECTION 5.1 - Introduction Speech detection is a very important part of AEC. It must be done before the software can determine whether to filter, update or freeze the adaptive filter. There are three speech detectors: – Far-end speech detector – Double-talk detector – Near-end speech detector The speech detection software always checks for the presence of the far-end speech first, then it goes to double-talk detection ...

Page 9

... Table 3 : Hangover Counters and LMS Mode Bit Settings HANGOVER COUNTERS DT_HANG>=0 NES_HANG>=0 NES_HANG<0 DT_HANG<0 NES_HANG>=0 NES_HANG < NESMAR GIN > ne slo ngp wr SET FILTERING MODE BIT YES YES NO YES AN1384 - APPLICATION NOTE . SET UPDATING MODE BIT YES 9/28 ...

Page 10

... AN1384 - APPLICATION NOTE 5.6 - Speech Detection Program Flow The following flowchart shows the speech detection program flow. Figure 2 : Speech Detection Flowchart DOUBLE_TALK=1 FAR_SPEECH=0 NEAR_SPEECH=0 NES_HANG=600 DT_HANG=600 ControlLMS() NEAR_SPEECH=0 NES_HANG-- NO DT_HANG>=0 ? AEC_FILTERING=0 AEC_FILTERING=1 AEC_UPDATE=0 10/28 DATA FROM POWER ESTIMATE Far speech ? NO FAR_SPEECH=0 YES Double talk ? ...

Page 11

... The result is the number of MCPS. 6.3.2 - Code Size The code size indicated in the further tables is the size given by the "gfunsize" command. This command (with as argument the object file) returns the number of bytes for each function. AN1384 - APPLICATION NOTE ...

Page 12

... AN1384 - APPLICATION NOTE FLOATING POINT IMPLEMENTATION 7.1 - Role Regarding the dynamic precision range of floating variables, the aim of such an implementation is to obtain a reference system. All further fixed point (ASM, LAI, C ...) implementations should have the same properties (convergence, same output file for the same input files...). ...

Page 13

... Following figure shows that the filter is no more adapted at all to the signal during double-talk period. An excellent recovery time is realized after double-talk. Following double-talk, the TCL resumes its average value within 2-3 seconds. Figure 5 : TCL( in dB) versus the number of samples in Double-Talk conditions Number of samples Tests during double talk conditions Number of samples AN1384 - APPLICATION NOTE 13/28 ...

Page 14

... AN1384 - APPLICATION NOTE 7.4 - Bench Results In this paragraph the best results are presented. GHS options are -OLAMI -Onounroll and LAO options are -Ounroll=1 .A library of floating point intrinsics was used (fast float addition, fast float mac, fast float multiplication and division important to note that the call and the rts instructions are included in all MCPS results. However, the number of MCPS is sufficient to hide the cycles due to the CALL/RTS instructions impact ...

Page 15

... Program Flow The following flowchart describes the AEC process. Figure 6 : AEC Flowchart The difference with the floating point version is the test of overflow important to check overflows as they could make the algorithm diverge, if not treated. AN1384 - APPLICATION NOTE PowerEstimate SpeechDetector NO Adaptive filtering ? ...

Page 16

... AN1384 - APPLICATION NOTE 8 Prototypes Table 5 through Table 8 show the protoypes used for the LMS adaptive filter function, the power estimate function, the speech detection function and the calc erf function. Table 5 : Prototype for AEC NLMS Adaptive Filter Function Syntax Void NLMS_filtering(short *input, short erf, short out) ...

Page 17

... Following figure shows that the filter is no more adapted at all to the signal during double-talk period. An excellent recovery time is realized after double-talk. Following double-talk, the TCL resumes its average value within 2-3 seconds. Figure 8 : TCL in dB versus the number of cycles in Double-Talk Conditions AN1384 - APPLICATION NOTE 17/28 ...

Page 18

... AN1384 - APPLICATION NOTE 8.4 - Bench Results In this paragraph the best results are presented. They are obtained with GHS-ST100-2.1-01 MULTI 2000 environment and LAO . GHS options are -OLAMI -Onounroll, as specified in chapter 6. 8.4.1 - Front End This module contains all functions excepted Filtering: PowerEstimate, SpeechDetection, UpdateErf ... ...

Page 19

... The difference between both results gives the number of cycle to perform the entire loop (with 2-unrolling, it means 64 iterations). Consequently the numbers presented do not include neither call and rts instructions nor loop initialization. Best case is 1286 * 8000 = 10.3 MCPS. ASM generated is presented p. 20. Temp; iInd; tempo;; AN1384 - APPLICATION NOTE 19/28 ...

Page 20

... AN1384 - APPLICATION NOTE 9 - IMPROVING PERFORMANCES 9.1 - First Step GHS and LAO do not take into account packed arithmetic [2] that could be largely used in the NLMS Filtering module necessary to re-write this function in assembly. To take advantage of the sliw functionality of the ST120, an iteration of the nlmsFiltering loop processes 2 samples of the data buffer (instead of one) ...

Page 21

... At C level, the process is presented on pages 23 and 24 Nb Cycles/Sample 535 se rf psWo Wait for the sFilter[ psWo Wait for the sFilter[ psWo psWo sFilter[1] is ready se rf psWo sFilter[2] is ready AN1384 - APPLICATION NOTE Code Size 192 21/28 ...

Page 22

... AN1384 - APPLICATION NOTE Like in the paragraph 9.1, an iteration of the loop fits perfectly into 3 sliw bundles but without any latencies, which should lead to a real 1.5N cycle loop. This time, the difference between the number of cycles returned by the "cycle" command called at the beginning and at the end of the loop equals to 390. ...

Page 23

... FiltPrec2 + (short)tempo; Temp = __mafcw ( Temp, FiltPrec1, ptrPrec1); tempo = __mpfrch(ptr[iInd + 1], adaptRate); sFilter[iInd+1] = sFilter[iInd+1] + (short)tempo; Temp = __mafcw ( Temp, sFilter[iInd], ptrPrec2 ); FiltPrec1 = sFilter[iInd+1]; FiltPrec2 = sFilter[iInd+2]; ptrPrec1 = ptr[iInd]; ptrPrec2 = ptr[iInd+1]; } Temp = __mafcw ( Temp, sFilter[WIN_LEN-1], psWork[WIN_LEN-1]); *psOutSig = Temp >> 16; } AN1384 - APPLICATION NOTE 23/28 ...

Page 24

... AN1384 - APPLICATION NOTE The assembly code is presented below. f_NLMSFiltering: push R4-R11 .align 8 makea PR , %abs16to31(sFilter) ldf makec LC0 , 127 ldf morea PR , %abs0to15(sFilter) ldf ldf mafrchh sdf @( ldf addha setuls0 start_loop mafrchh ...

Page 25

... ldf R10 , @( mafchh R11 mafrclh R6 , R10 , mafchl R11 extw R11 , R4 sdf @( sdf @( end_loop: ldh 510 ) ldh mafcll nop nop nop sdf @( gp32md poprts R4-R11 .leave f_NLMSFiltering AN1384 - APPLICATION NOTE 25/28 ...

Page 26

... AN1384 - APPLICATION NOTE 10 - CONCLUSION During single-talk period, the computational-time cost is 2.32 + 3.2 = 5.6 MCPS (front-end + nlms filtering); during double-talk periods reduced to 2.32 MCPS (front-end). Single talk periods represent the main part of a conversation, whereas double-talk periods are present only during brief and limited instances. ...

Page 27

... G15? ldh G15? shrw R1 , R12 , 16 G15? addu G15? sdh @( G15? ldh R12 , @( G15? mafcll R12 .align 8 .LAO5: .align 8 .LAO10: .L56: G15? subha G15? sdf @( G15? make G15? rts .LAO1: .leave f_NLMSFiltering AN1384 - APPLICATION NOTE 27/28 ...

Page 28

... AN1384 - APPLICATION NOTE ACRONYMS AND DEFINITIONS – AEC : Acoustic Echo Cancellation/Canceller – Double Talk – ERLE : Echo Return Loss Enhancement – ETSI : European Telecom Standard Institute – GHS : GreenHills – LAI : Linear Assembly Input language – LAO : Linear Assembly Optimizer – MCPS : Megacycle per second – ...

Related keywords