protected override RecorderAec GetRecorder()
        {
            var recorder = new RecorderAec(CaptureSource, AudioSinkAdapter, mSpeakersAudioVisualizer, mCancelledAudioVisualizer, mEchoCancelFilter, mCancelledFrames);

            AudioSinkAdapter.InstanceName = "ForTestRunnerLive";
            return(recorder);
        }
        protected virtual void StartNextTest()
        {
            Deployment.Current.Dispatcher.BeginInvoke(() => Status = string.Format("Executing test for latency {0} and filter length {1}", ExpectedLatency, FilterLength));

            mTestStartTime = DateTime.Now;
            IAudioFilter playedResampler;
            IAudioFilter recordedResampler;

            mCancelledFrames = new List <byte[]>();

            // Decide whether to synchronize the audio or not.
            if (AecIsSynchronized)
            {
                playedResampler   = new ResampleFilter(audioFormat, audioFormat);
                recordedResampler = new ResampleFilter(audioFormat, audioFormat);
            }
            else
            {
                playedResampler   = new NullAudioFilter(audioFormat.BytesPerFrame);
                recordedResampler = new NullAudioFilter(audioFormat.BytesPerFrame);
            }

            // Initialize the echo canceller
            playedResampler.InstanceName     = "EchoCanceller_played";
            recordedResampler.InstanceName   = "EchoCanceller_recorded";
            mediaConfig.ExpectedAudioLatency = ExpectedLatency;
            mediaConfig.FilterLength         = FilterLength;

            switch (mEchoCancellerType)
            {
            case EchoCancellerType.Speex2:
                mEchoCancelFilter = new SpeexEchoCanceller2(mediaConfig, audioFormat, AudioFormat.Default);
                break;

            case EchoCancellerType.WebRtc:
                mEchoCancelFilter = new WebRtcFilter(mediaConfig.ExpectedAudioLatency,
                                                     mediaConfig.FilterLength,
                                                     audioFormat,
                                                     AudioFormat.Default,
                                                     true,
                                                     true,
                                                     false,
                                                     playedResampler, recordedResampler);
                break;

            case EchoCancellerType.TimeDomain:
                mEchoCancelFilter = new TimeDomainEchoCancelFilter(ExpectedLatency, FilterLength, audioFormat, AudioFormat.Default, playedResampler, recordedResampler);
                break;

            case EchoCancellerType.Speex:
                mEchoCancelFilter = new SpeexEchoCancelFilter(ExpectedLatency, FilterLength, audioFormat, AudioFormat.Default, playedResampler, recordedResampler);
                break;

            default:
                throw new Exception();
            }

            mPlayer   = GetPlayer();
            mRecorder = GetRecorder();

            mRecorder.StartRecording(SpeakerFrames, FinishTest);
            mPlayer.StartPlaying(SourceFrames, mRecorder.StopRecording);
        }