Ejemplo n.º 1
0
        private void StopAudioCapture_Button_Click(object sender, RoutedEventArgs e)
        {
            if (_captureSource != null)
            {
                _captureSource.Stop();

                string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "testFile.wav");

                if (System.IO.File.Exists(path))
                {
                    System.IO.File.Delete(path);
                }

                System.IO.Stream stream = System.IO.File.Create(path);

                using (stream)
                {
                    JSpeexDec decoder = new JSpeexDec();
                    decoder.setDestFormat(JSpeexDec.FILE_FORMAT_WAVE);
                    decoder.setStereo(true);

                    System.IO.Stream memStream = _audioSink.MemFile.InnerStream;
                    memStream.Position = 0;

                    decoder.decode(new RandomInputStream(memStream), new RandomOutputStream(stream));

                    stream.Close();
                }
            }
        }
Ejemplo n.º 2
0
        private void PlayReceivedBuffer(byte[] Encodedbuffer)
        {
            if (MuteCheckBox.IsChecked == false)
                try
                {
                    JSpeexDec decoder = new JSpeexDec();
                    decoder.setDestFormat(JSpeexDec.FILE_FORMAT_WAVE);
                    decoder.setStereo(true);
                    MemoryStream InStream = new MemoryStream(Encodedbuffer);
                    MemoryStream OutStream = new MemoryStream();
                    decoder.decode(new RandomInputStream(InStream), new RandomOutputStream(OutStream));
                    PlayWave(OutStream.GetBuffer());
                }
                catch (Exception) { }

                StartReceiving();
        }