2008-01-08 13:40:23     Linphone and Speex Echo Cancellation

Document created by Aaronwu Employee on Aug 5, 2013
Version 1Show Document
  • View in full screen mode

2008-01-08 13:40:23     Linphone and Speex Echo Cancellation

Cameron Barfield (UNITED STATES)

Message: 49360    We've got a product that's essentially an intercom with a BF536 and ad198bl (same as always).

 

We're testing with Linphone, which I believe is using the SPEEX library for echo cancellation.

 

We experience rather a bad echo on the other end of the line (not our intercom) when the person on the other end of the line speaks.

 

We have played around with microphone placement, but when we actually place the microphone in the enclosure we experience the rather bad echo. After six seconds or so, the echo cancellation appears to kick in, but it doesn't totally silence the echo; it seems to just distort it.

 

We've been in contact with Jean-Marc Valin, and, -- oddly enough -- he told us that he "remember[s] that there were some issues with the AEC and how Linphone was doing the audio capture/playback." He directed us to Robin Getz and Juergen Hennerich.

 

Does anyone else have any experience using the Speex echo cancellation? Does anyone have any ideas to what the issues with AEC and Linphone are/were?

QuoteReplyEditDelete

 

 

2008-01-08 15:37:31     Re: Linphone and Speex Echo Cancellation

Robin Getz (UNITED STATES)

Message: 49367    Cameron:

 

Yes - but that was for the OSS driver (which is what Jean Marc was thinking). For ALSA - there shouldn't be much problems - and it is back on him. Are you using the ALSA or OSS interface in Linphone?

 

-Robin

QuoteReplyEditDelete

 

 

2008-01-08 15:40:47     Re: Linphone and Speex Echo Cancellation

Cameron Barfield (UNITED STATES)

Message: 49369    We're using ALSA.

 

Thanks for the clarification.

QuoteReplyEditDelete

 

 

2008-01-08 16:36:12     Re: Linphone and Speex Echo Cancellation

Cameron Barfield (UNITED STATES)

Message: 49371    Just out of curiosity, do you know of anyone using Linphone/Speex not in a standard phone or headset configuration?

QuoteReplyEditDelete

 

 

2008-01-08 22:13:10     Re: Linphone and Speex Echo Cancellation

Yi Li (CHINA)

Message: 49376    Have you set "echocancelation=1" in the [sound] section? Also please set "echocancelation=1" on both sides of linphone (caller & receiver).

QuoteReplyEditDelete

 

 

2008-01-08 22:14:44     Re: Linphone and Speex Echo Cancellation

Yi Li (CHINA)

Message: 49377    " using Linphone/Speex not in a standard phone or headset configuration"

 

Not sure what do you mean, but we have tried to make linphone work as video doorbell application (two-way audio with one-way video).

QuoteReplyEditDelete

 

 

2008-01-09 10:51:15     Re: Linphone and Speex Echo Cancellation

Cameron Barfield (UNITED STATES)

Message: 49400    Echo cancellation is enabled on both sides.

 

"we have tried to make linphone work as video doorbell application..."

 

Were you successful in squashing the echo in this application?

QuoteReplyEditDelete

 

 

2008-01-09 11:31:40     Re: Linphone and Speex Echo Cancellation

Michele d'Amico (ITALY)

Message: 49405    Hi Cameron,

echo cancellation doesn't mean "remove every kind of echo effect". AFAIK: Usually the best performance of echo cancellation algorithms/implementation is a reduction of 30 Db of the feedback signal.

What you are asking about is strange to understand... How many Db is the feedback of your system?

I don't know the performance of speex echo cancellation, but if in your intercom application you would like perform a complete full duplex communication you should assume that the best you can do is reduce the echo of 30Db (IMHO: if you are lucky 20-25 Db).

 

I'm sorry, but I can't help you more of that if I don't know your real setting. Anyway, I've never experimented speex echo cancellation but I think you can found some tests result on the net.

 

Regards

 

--Michele d'Amico

QuoteReplyEditDelete

 

 

2008-01-09 12:12:26     Re: Linphone and Speex Echo Cancellation

Cameron Barfield (UNITED STATES)

Message: 49408    Hi, Michele --

 

We've not yet measured the level of the feedback signal. I'll see if we can manage to figure out what it is. Sorry for my ignorance, but how exactly would we go about measuring the level of the feedback signal? Also, can anyone tell me what the echo level was on the ADI project was?

 

We've spent a significant amount of time trying different microphones, placements, angles, etc. Using these hardware changes combined with speex echo cancellation we are able to remove most of the echo but we still experience much more echo than traditional non-VoIP intercom systems.

 

QuoteReplyEditDelete

 

 

2008-01-09 16:36:05     Re: Linphone and Speex Echo Cancellation

Robin Getz (UNITED STATES)

Message: 49416    Cameron:

 

When working with Jean Marc before, he pointed to a debug mode in the AEC which will save all the wave files (as PCM samples) to the drive.

 

Just add -DDUMP_ECHO_CANCEL_DATA to the speex make...

 

-Robin

QuoteReplyEditDelete

 

 

2008-01-10 03:21:50     Re: Linphone and Speex Echo Cancellation

Michele d'Amico (ITALY)

Message: 49428    Hi Cameron,

 

As Robin said you could dump speex debug data. Moreover, you can play a tone by the speakers and record it by the microphone. What you can expect from echo cancellation system is reduce the level of the signal recorded from the microphone of "some Db": in the best case since 30 Db.

 

After that you can connect the two endpoints by a VoIP call and send the signal from the other endpoint (by software or by waveform generator HW) and record it (by software or by a O-Scope).

 

So the first step give you the feedback signal level A in Db, the second step give you the echo level B in Db. So the performance of the echo cancellation speex algorithm  is A-B.

 

Note that: a single tone is not a good test case but you can start from that simple case for building your test plant.

 

Regards

 

--Michele

QuoteReplyEditDelete

 

 

2008-01-11 12:03:18     Re: Linphone and Speex Echo Cancellation

Cameron Barfield (UNITED STATES)

Message: 49505    On both the Blackfin and my PC (with identical versions of linphone and speex), I get the following error when linphone connects on a call:

 

Fatal (internal) error: Opening dump files twice

 

The error comes from speex/libspeex/mdf.c

 

My first guess is that the way linphone is calling into the speex library is either incorrect, or the speex library is not closing the files as it should.

 

As a quick test, I changed:

 

    #ifdef DUMP_ECHO_CANCEL_DATA

       if (rFile || pFile || oFile)

          speex_error("Opening dump files twice");

       rFile = fopen("aec_rec.sw", "w");

       pFile = fopen("aec_play.sw", "w");

       oFile = fopen("aec_out.sw", "w");

    #endif

 

to:

 

    #ifdef DUMP_ECHO_CANCEL_DATA

       if (rFile || pFile || oFile)

       {

    //       speex_error("Opening dump files twice");

            speex_warning("Tried to open dump files a second time\n");

        }

 

        else

        {

           rFile = fopen("aec_rec.sw", "w");

           pFile = fopen("aec_play.sw", "w");

           oFile = fopen("aec_out.sw", "w");

        }

    #endif

 

The warning I added prints out once and the debug files are created. However, they seem to be nothing but garbage. I've tried playing them with various media players and importing them as various data types with audacity, but it always sounds and looks like garbage. The only thing I can see that is correct about the files is that when I import them as 8KHz, the length of the squelchy audio is the same as the duration of my call.

QuoteReplyEditDelete

 

 

2008-01-11 12:34:14     Re: Linphone and Speex Echo Cancellation

Cameron Barfield (UNITED STATES)

Message: 49506    At least with the garbage, I can see that the peaks in the noise do match the speaking during the call.

QuoteReplyEditDelete

 

 

2008-01-11 12:59:44     Re: Linphone and Speex Echo Cancellation

Juergen Hennerich (GERMANY)

Message: 49508    Hi Cameron,

 

the files should be 16 bit (-w) 8kHz (-r 8000) 1 channel (-c 1) raw (-t raw) audio files. They have no header and therefore you can't play them with a normal player, but you can convert them with sox:  "sox -t raw -r 8000 -s -w -c 1 aec_rec.sw aec_rec.wav".

 

You could also use aplay, sox and snd to play them. Also "snd" can be used to visualize the data.

 

 

Juergen

QuoteReplyEditDelete

 

 

2008-01-11 15:39:49     Re: Linphone and Speex Echo Cancellation

Cameron Barfield (UNITED STATES)

Message: 49517    Ah, thank you Juergen. I am able to play and analyse the files now.

QuoteReplyEditDelete

 

 

2008-01-12 03:52:33     Re: Linphone and Speex Echo Cancellation

Mike Frysinger (UNITED STATES)

Message: 49521    i thought i had sent a patch to fix that "opened twice" error ... iirc, your change is fine for getting things up and working ... the resulting files shouldnt be corrupt by the issue

QuoteReplyEditDelete

 

 

2008-01-15 11:44:05     Re: Linphone and Speex Echo Cancellation

Cameron Barfield (UNITED STATES)

Message: 49601    Mike --

 

Sent a patch to me directly/in forum post or checked something in to the trunk? Last posts were running svn 5953 from 07 Jan.

QuoteReplyEditDelete

 

 

2008-01-15 17:56:18     Re: Linphone and Speex Echo Cancellation

Cameron Barfield (UNITED STATES)

Message: 49623    So everything's working fine on my PC, but when I enable the debug mode for speex on my board, all audio plays and records very choppy. It seems like the BF536 can't handle the RTP streams AND the speex debug files.

 

Can you verify that the speex debug mode works on a stamp board?

QuoteReplyEditDelete

 

 

2008-01-15 18:36:34     Re: Linphone and Speex Echo Cancellation

Mike Frysinger (UNITED STATES)

Message: 49627    sent upstream

QuoteReplyEditDelete

 

 

2008-01-15 18:37:10     Re: Linphone and Speex Echo Cancellation

Mike Frysinger (UNITED STATES)

Message: 49628    last time i tested it and wrote the debug files to ramfs, it seemed to work fine.  but i was testing with an 8k codec (AD73311).

QuoteReplyEditDelete

 

 

2008-01-16 12:02:57     Re: Linphone and Speex Echo Cancellation

Cameron Barfield (UNITED STATES)

Message: 49676    Doesn't ALSA do the re-sampling to 48KHz for the 1981? I'd thought that the audio data would go through the speex echo canceler before hitting ALSA and going out to the 1981.

 

I suppose the microphone input may come in at 48KHz from the 1981, though.

QuoteReplyEditDelete

 

 

2008-01-16 14:49:47     Re: Linphone and Speex Echo Cancellation

Robin Getz (UNITED STATES)

Message: 49682    Cameron:

 

ALSA (userspace) does all the reformatting/resampling.

 

The audio codec can only handle 48k on playback (stereo) and record (not sure if this is stereo or mono - codec supports both).

 

-Robin

QuoteReplyEditDelete

 

 

2008-01-22 13:46:14     Re: Linphone and Speex Echo Cancellation

Cameron Barfield (UNITED STATES)

Message: 49962    The AD1981BL data sheet states that the codec supports "Full-duplex variable sample rates from 7040 Hz to 48 kHz with 1 Hz resolution."

 

If I were to change slave.pcm.rate in the .conf file to 8000, would there be any adverse consequences?

QuoteReplyEditDelete

 

 

2008-01-23 10:11:21     Re: Linphone and Speex Echo Cancellation

Michael Hennerich (GERMANY)

Message: 50029   

 

This feature only works in real AC97 systems.

The only Sample Rate Blackfin SPORT and a AC97 CODEC support is 48KHz.

(This is because the AC97 Codec tells which frames should contain data and which ones are blank)

 

I know I shouldn't recommend this - but I just tried to use a 4.9152MHz (I didn't find a 4.096MHz in my box) crystal instead of the 24.576MHz.

 

This seams to work fine  for me ...

 

 

In case you only need to have 8000Hz PCM capture/playback then this "might" work for you:

 

48Khz / 8KHz = 6 => 24.576 / 6 = 4.096MHz (are available everywhere in the same package)

 

michael@mhenneri-D02:~/devel/svn/uclinux-dist-trunk_3/linux-2.6.x> svn diff sound/

Index: sound/soc/codecs/ad1980.c

===================================================================

--- sound/soc/codecs/ad1980.c   (revision 4139)

+++ sound/soc/codecs/ad1980.c   (working copy)

@@ -146,13 +146,13 @@

                .stream_name = "Playback",

                .channels_min = 2,

                .channels_max = 2,

-               .rates = SNDRV_PCM_RATE_48000,

+               .rates = SNDRV_PCM_RATE_8000,

                .formats = SNDRV_PCM_FMTBIT_S16_LE, },

        .capture = {

                .stream_name = "Capture",

                .channels_min = 2,

                .channels_max = 2,

-               .rates = SNDRV_PCM_RATE_48000,

+               .rates = SNDRV_PCM_RATE_8000,

                .formats = SNDRV_PCM_FMTBIT_S16_LE, },

};

EXPORT_SYMBOL_GPL(ad1980_dai);

Index: sound/soc/blackfin/bf5xx-ac97.c

===================================================================

--- sound/soc/blackfin/bf5xx-ac97.c     (revision 4139)

+++ sound/soc/blackfin/bf5xx-ac97.c     (working copy)

@@ -346,13 +346,13 @@

                .stream_name = "AC97 Playback",

                .channels_min = 2,

                .channels_max = 2,

-               .rates = SNDRV_PCM_RATE_48000,

+               .rates = SNDRV_PCM_RATE_8000,

                .formats = SNDRV_PCM_FMTBIT_S16_LE, },

        .capture = {

                .stream_name = "AC97 Capture",

                .channels_min = 2,

                .channels_max = 2,

-               .rates = SNDRV_PCM_RATE_48000,

+               .rates = SNDRV_PCM_RATE_8000,

                .formats = SNDRV_PCM_FMTBIT_S16_LE, },

};

EXPORT_SYMBOL_GPL(bfin_ac97_dai);

QuoteReplyEditDelete

 

 

2008-01-23 12:04:16     Re: Linphone and Speex Echo Cancellation

Cameron Barfield (UNITED STATES)

Message: 50045    Thank you for the clarification, Michael.

 

Don't worry. If I try what you aren't recommending, it will be just so I can get the debug files from the speex echo canceler so that I can debug them

Attachments

    Outcomes