示例#1
0
        static void FileLoadExample()
        {
            OpenFileDialog selectFileDialog = new OpenFileDialog();

            selectFileDialog.Filter           = "wav files (*.wav)|*.wav";
            selectFileDialog.RestoreDirectory = true;
            selectFileDialog.ShowDialog();
            var wavePlayer = new WaveFileReader(selectFileDialog.FileName);

            Console.WriteLine("File format: " + wavePlayer.WaveFormat.ToString());

            FDecoder = new LTCSharp.Decoder(wavePlayer.WaveFormat.SampleRate, 25, 32);

            int size = 1600;

            byte[] buffer = new byte[size];
            int    total  = 0;

            while (wavePlayer.Position < wavePlayer.Length)
            {
                var task = wavePlayer.Read(buffer, 0, size);

                FDecoder.WriteAsU16(buffer, size / 2, total);

                total += size / 2;

                try
                {
                    var frame    = FDecoder.Read();
                    var timecode = frame.getTimecode();
                    Console.WriteLine(wavePlayer.CurrentTime.ToString() + "\t" + timecode.ToString());
                }
                catch
                {
                    //no frames available
                }
            }

            Console.WriteLine("END OF FILE");
        }
示例#2
0
        static void WaveInExample()
        {
            var waveIn = new WasapiCapture();

            waveIn.WaveFormat = new WaveFormat(44100, 8, 2);

            Console.WriteLine("Device format: " + waveIn.WaveFormat.ToString());
            FDecoder              = new LTCSharp.Decoder(waveIn.WaveFormat.SampleRate, 25, 32);
            waveIn.DataAvailable += waveIn_DataAvailable;
            waveIn.StartRecording();

            Stopwatch timer = new Stopwatch();

            timer.Start();
            while (true)             //timer.Elapsed < new TimeSpan(0, 0, 60))
            {
                lock (FDecoder)
                {
                    if (FDecoder.GetQueueLength() > 0)
                    {
                        try
                        {
                            var frame    = FDecoder.Read();
                            var timecode = frame.getTimecode();
                            Console.WriteLine(timecode.ToString());
                        }
                        catch (Exception e)
                        {
                            Console.Write(e);
                        }
                    }
                    else
                    {
                        Thread.Sleep(10);
                    }
                }
            }
            timer.Stop();
        }
示例#3
0
        static void FileLoadExample()
        {
            OpenFileDialog selectFileDialog = new OpenFileDialog();
            selectFileDialog.Filter = "wav files (*.wav)|*.wav";
            selectFileDialog.RestoreDirectory = true;
            selectFileDialog.ShowDialog();
            var wavePlayer = new WaveFileReader(selectFileDialog.FileName);
            Console.WriteLine("File format: " + wavePlayer.WaveFormat.ToString());

            FDecoder = new LTCSharp.Decoder(wavePlayer.WaveFormat.SampleRate, 25, 32);

            int size = 1600;
            byte[] buffer = new byte[size];
            int total = 0;
            while (wavePlayer.Position < wavePlayer.Length)
            {
                var task = wavePlayer.Read(buffer, 0, size);

                FDecoder.WriteAsU16(buffer, size / 2, total);

                total += size / 2;

                try
                {
                    var frame = FDecoder.Read();
                    var timecode = frame.getTimecode();
                    Console.WriteLine(wavePlayer.CurrentTime.ToString() + "\t" + timecode.ToString());
                }
                catch
                {
                    //no frames available
                }
            }

            Console.WriteLine("END OF FILE");
        }
示例#4
0
        static void WaveInExample()
        {
            var waveIn = new WasapiCapture();
            waveIn.WaveFormat = new WaveFormat(44100, 8, 2);

            Console.WriteLine("Device format: " + waveIn.WaveFormat.ToString());
            FDecoder = new LTCSharp.Decoder(waveIn.WaveFormat.SampleRate, 25, 32);
            waveIn.DataAvailable += waveIn_DataAvailable;
            waveIn.StartRecording();

            Stopwatch timer = new Stopwatch();
            timer.Start();
            while (true) //timer.Elapsed < new TimeSpan(0, 0, 60))
            {
                lock (FDecoder)
                {
                    if (FDecoder.GetQueueLength() > 0)
                    {
                        try
                        {
                            var frame = FDecoder.Read();
                            var timecode = frame.getTimecode();
                            Console.WriteLine(timecode.ToString());
                        }
                        catch (Exception e)
                        {
                            Console.Write(e);
                        }
                    }
                    else
                    {
                        Thread.Sleep(10);
                    }
                }
            }
            timer.Stop();
        }