Jump to content
Mumble forums

need help understand the echo cancellation code


billconan
 Share

Recommended Posts

:oops:


Hello there,


I'm trying to understand the echo cancellation code. but I can't make sense of the following code:

 

					QMutexLocker l(&qmEcho);

				if (qlEchoFrames.isEmpty()) {
					iJitterSeq = 0;
					iMinBuffered = 1000;
				} else {
					// Compensate for drift between the microphone and the echo source
					iMinBuffered = qMin(iMinBuffered, qlEchoFrames.count());

					if ((iJitterSeq > 100) && (iMinBuffered > 1)) {
						iJitterSeq = 0;
						iMinBuffered = 1000;
						delete [] qlEchoFrames.takeFirst();
					}
					echo = qlEchoFrames.takeFirst();
				}

 



I understand that the echo frames and the mic frames can have some offset. we need to somehow realign them. but I just can't understand iJitterSeq and iMinBuffered and why when (iJitterSeq > 100) && (iMinBuffered > 1) the queue needs to be popped?


also what do 1000 and 100 mean here? why did we hard code it to 1000?


later in the code, iJitterSeq is updated by this line:

 

			iJitterSeq = qMin(iJitterSeq + 1,10000U);
		qlEchoFrames.append(outbuff);

 

this means iJitterSeq should be the size of qlEchoFrames for most of the time (when the size is less than 10000)


and this line updates iMinBuffered

 

			iMinBuffered = qMin(iMinBuffered, qlEchoFrames.count());

 

meaning iMinBuffered should be also the size of qlEchoFrames for most of the time (when count is less than 1000)


does this mean iMinBuffered == iJitterSeq? then why do we use two variables?


Thanks a lot!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...