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(); }
private static async Task <SoundioInput> InitializeInput() { var input = new SoundioInput(); 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); await input.InitializeAsync(format); Console.WriteLine("Device initialized"); return(input); }
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"); }
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(); }