예제 #1
0
        public void Start(int input, int output)
        {
            if (WaveIn.DeviceCount < 1)
            {
                throw new Exception("Insufficient input device(s)!");
            }

            if (WaveOut.DeviceCount < 1)
            {
                throw new Exception("Insufficient output device(s)!");
            }

            frame_size = toxav.CodecSettings.AudioSampleRate * toxav.CodecSettings.AudioFrameDuration / 1000;

            //who doesn't love magic numbers?!
            toxav.PrepareTransmission(CallIndex, 3, 40, false);

            WaveFormat format = new WaveFormat((int)toxav.CodecSettings.AudioSampleRate, (int)toxav.CodecSettings.AudioChannels);

            wave_provider = new BufferedWaveProvider(format);
            wave_provider.DiscardOnBufferOverflow = true;

            wave_out = new WaveOut();

            if (output != -1)
            {
                wave_out.DeviceNumber = output - 1;
            }

            wave_out.Init(wave_provider);

            wave_source = new WaveIn();

            if (input != -1)
            {
                wave_source.DeviceNumber = input - 1;
            }

            wave_source.WaveFormat         = format;
            wave_source.DataAvailable     += wave_source_DataAvailable;
            wave_source.RecordingStopped  += wave_source_RecordingStopped;
            wave_source.BufferMilliseconds = (int)toxav.CodecSettings.AudioFrameDuration;
            wave_source.StartRecording();

            wave_out.Play();
        }
예제 #2
0
파일: ToxCall.cs 프로젝트: TimBo93/Toxy
        public virtual void Start(int input, int output, ToxAvCodecSettings settings, string videoDevice = "")
        {
            toxav.PrepareTransmission(callIndex, true);

            WaveFormat outFormat = new WaveFormat((int)settings.AudioSampleRate, (int)settings.AudioChannels);

            wave_provider = new BufferedWaveProvider(outFormat);
            wave_provider.DiscardOnBufferOverflow = true;

            filterAudio = new FilterAudio((int)settings.AudioSampleRate);
            filterAudio.EchoFilterEnabled = false;

            if (WaveIn.DeviceCount > 0)
            {
                wave_source = new WaveInEvent();

                if (input != -1)
                {
                    wave_source.DeviceNumber = input;
                }

                WaveFormat inFormat = new WaveFormat((int)ToxAv.DefaultCodecSettings.AudioSampleRate, 1);

                wave_source.WaveFormat         = inFormat;
                wave_source.DataAvailable     += wave_source_DataAvailable;
                wave_source.RecordingStopped  += wave_source_RecordingStopped;
                wave_source.BufferMilliseconds = ToxAv.DefaultCodecSettings.AudioFrameDuration;
                wave_source.StartRecording();
            }

            if (WaveOut.DeviceCount > 0)
            {
                wave_out = new WaveOut();

                if (output != -1)
                {
                    wave_out.DeviceNumber = output;
                }

                wave_out.Init(wave_provider);
                wave_out.Play();
            }
        }