I just tried the below code, and it works fine to reduce the echo on head phones. But the problem of echo remains as it is in case of speakers.
public var intCountMilliSec:int = 0;
public var intLastActivityLevel:int = 0;
public var intLastLowestActivityLevel:int = 100;//07-Dec-09
private function CancelEcho(e:TimerEvent):void
{
intCountMilliSec = intCountMilliSec + 50;
if (Red5OutgoingMic.activityLevel > intLastActivityLevel)
{
intLastActivityLevel = Red5OutgoingMic.activityLevel;
}
if (Red5OutgoingMic.activityLevel < intLastLowestActivityLevel)
{
intLastLowestActivityLevel = Red5OutgoingMic.activityLevel;
}
if (intCountMilliSec >= 1500)
{
if (intLastActivityLevel > 20)
{
Red5OutgoingMic.gain *= 0.8;
}
if (intLastLowestActivityLevel < 20)
{
if (Red5OutgoingMic.gain <= 30)
{
Red5OutgoingMic.gain = Red5OutgoingMic.gain/0.8;
}
}
intCountMilliSec = 0;
intLastActivityLevel = 0;
intLastLowestActivityLevel = 0;
}
}
Any 开发者_StackOverflowimmediate help is appreciated.
what your experiencing is called feedback, its a hardware issue, the microphone picks up the sound emmitting from the speakers and plays it back again through the speakers.
Typically it comes out as a squeal but with the delay of over ip it can just recycle the sound. This is a common problem.
Headphones are a common solution. Another solution is to move your audio output away from your audio input: i.e. move the speakers away from the microphone.
See: http://en.wikipedia.org/wiki/Audio_feedback
The solution you're looking for is called echo cancellation. Unfortunately today there are only two options:
1) do the echo cancelling in Flash. Adobe has the ability to do this embedded in flash, but unfortunately they only allow it to be used when running against Adobe Connect's conferencing server. Lame, but true.
2) your other option is to decode the audio from all participants in a server, mix the audio there, and remove echo using an echo cancelling library. An example of a C library that does this is spandsp, but this requires a lot of extra code, and a media server that can decode from Flash. The Red5 open-source server can receive audio and video from Flash, and you can use the Xuggle library to decode the audio into raw audio. Removing the echo though would require integration with the right echo canelling library.
In short, unless Adobe decides to actually enable echo-canelling in Flash for non-Adobe-proprietary apps, you're left with a hard road to fix the issue (i.e. there is no way to fix this from ActionScript today).
Hope that helps.
- Art
精彩评论