示例#1
0
        public static async Task StartAsync()
        {
            input.Filled += InputOnFilled;
            Console.WriteLine("Input devices");
            for (var i = 0; input.Devices.Count > i; i++)
            {
                Console.WriteLine($"[{i}] {input.Devices[i].Name}");
            }

            var deviceIndex = ReadInt("Input device index : ");
            var inputDevice = input.Devices[deviceIndex];

            for (var i = 0; input.Devices.Count > i; i++)
            {
                if (i != deviceIndex)
                {
                    input.Devices[i].RemoveReference();
                }
            }

            AudioFormat format = new AudioFormat(48000, 2);

            input.SetDevice(inputDevice);
            await input.InitializeAsync(format);

            Console.WriteLine($"{input.Format.SampleRate} {input.Format.Channels}");

            await input.StartAsync();
        }
        public static async Task StartAsync()
        {
            input.Filled += InputOnFilled;
            Console.WriteLine("Input devices");
            for (var i = 0; input.Devices.Count > i; i++)
            {
                Console.WriteLine($"[{i}] {input.Devices[i].Name}");
            }

            var deviceIndex = ReadInt("Input device index : ");
            var inputDevice = input.Devices[deviceIndex];

            for (var i = 0; input.Devices.Count > i; i++)
            {
                if (i != deviceIndex)
                {
                    input.Devices[i].RemoveReference();
                }
            }

            AudioFormat format = new AudioFormat(48000, 2, 16);

            input.SetDevice(inputDevice);
            await input.InitializeAsync(format);

            Console.WriteLine($"{input.Format.SampleRate} {input.Format.Channels}");

            _output = await InitializeOutput(format);

            _ringBuffer = new RingBuffer <byte>((uint)(format.SampleRate * format.Channels * 30));

            await input.StartAsync();

            _output.Start();

            Console.WriteLine("Input latency : " + input.SoftwareLatency.TotalMilliseconds + " ms");
            Console.WriteLine("Output latency : " + _output.SoftwareLatency.TotalMilliseconds + " ms");
        }
示例#3
0
        public static async Task StartAsync()
        {
            input.Filled += InputOnFilled;
            Console.WriteLine("Input devices");
            for (var i = 0; input.Devices.Count > i; i++)
            {
                Console.WriteLine($"[{i}] {input.Devices[i].Name}");
            }

            var deviceIndex = ReadInt("Input device index : ");
            var inputDevice = input.Devices[deviceIndex];

            for (var i = 0; input.Devices.Count > i; i++)
            {
                if (i != deviceIndex)
                {
                    input.Devices[i].RemoveReference();
                }
            }

            AudioFormat format = new AudioFormat(48000, 2, 16);

            input.SetDevice(inputDevice);
            await input.InitializeAsync(format);

            Console.WriteLine($"{input.Format.SampleRate} {input.Format.Channels}");

            _output = await InitializeOutput(format);

            await input.StartAsync();

//            Console.WriteLine("Buffering started");
//            Console.WriteLine("Press any key to start playback...");
//            Console.ReadKey();
            _output.Start();
        }