Exemplo n.º 1
0
        internal void OnCallback(XtStream stream, object input, object output, int frames,
                                 double time, ulong position, bool timeValid, ulong error, object user)
        {
            if (error != 0)
            {
                onError(() => "Stream callback error: " + XtPrint.ErrorToString(error));
                return;
            }

            XtFormat format      = stream.GetFormat();
            bool     interleaved = stream.IsInterleaved();

            OnCallback(format, interleaved, stream.IsRaw(), input, output, frames);
            processed += frames;
            if (processed < format.mix.rate * 3)
            {
                return;
            }

            processed = 0;
            XtLatency latency      = stream.GetLatency();
            string    formatString = "Stream {1}:{0}\tinput latency:{2}{0}\toutput latency:{3}{0}\t" +
                                     "buffer frames:{4}{0}\tcurrent frames:{5}{0}\ttime:{6}{0}\tposition:{7}{0}\ttimeValid:{8}{0}\tuser:{9}.";

            OnMessage(() => string.Format(formatString, Environment.NewLine, name, latency.input,
                                          latency.output, stream.GetFrames(), frames, time, position, timeValid, user));
        }
Exemplo n.º 2
0
        private void ServiceChanged()
        {
            XtService s = (XtService)(service.SelectedItem);

            inputDevice.DataSource  = null;
            outputDevice.DataSource = null;
            ClearDevices();

            DeviceView inputView = new DeviceView();

            inputView.defaultInput = true;
            inputView.device       = s.OpenDefaultDevice(false);
            if (inputView.device != null)
            {
                deviceViews.Add(inputView);
            }

            DeviceView outputView = new DeviceView();

            outputView.defaultOutput = true;
            outputView.device        = s.OpenDefaultDevice(true);
            if (outputView.device != null)
            {
                deviceViews.Add(outputView);
            }

            for (int i = 0; i < s.GetDeviceCount(); i++)
            {
                DeviceView view = new DeviceView();
                view.device = s.OpenDevice(i);
                view.index  = i;
                deviceViews.Add(view);
            }

            List <DeviceView> inputViews = (from v in deviceViews
                                            where v.defaultInput || v.device.GetChannelCount(false) > 0
                                            select v).ToList();

            inputViews.Insert(0, new DeviceView());

            List <DeviceView> outputViews = (from v in deviceViews
                                             where v.defaultOutput || v.device.GetChannelCount(true) > 0
                                             select v).ToList();

            outputViews.Insert(0, new DeviceView());

            inputDevice.DataSource     = new List <DeviceView>(inputViews);
            outputDevice.DataSource    = new List <DeviceView>(outputViews);
            secondaryInput.DataSource  = new List <DeviceView>(inputViews);
            secondaryOutput.DataSource = new List <DeviceView>(outputViews);
            inputDevice.SelectedIndex  = inputViews.Count == 1 ? 0 : 1;
            outputDevice.SelectedIndex = outputViews.Count == 1 ? 0 : 1;

            system.Text                = s.GetSystem().ToString();
            capabilities.Text          = XtPrint.CapabilitiesToString(s.GetCapabilities());
            defaultInput.Text          = inputView.device == null ? "null" : inputView.device.ToString();
            defaultOutput.Text         = outputView.device == null ? "null" : outputView.device.ToString();
            inputControlPanel.Enabled  = s.GetSystem() == XtSystem.Asio;
            outputControlPanel.Enabled = s.GetSystem() == XtSystem.Asio;
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            int index = -1;

            if (args.Length == 1)
            {
                index = int.Parse(args[0]);
            }
            try
            {
                if (index == -1 || index == 0)
                {
                    Console.WriteLine("PrintSimple:");
                    PrintSimple.Main(args);
                }
                if (index == -1 || index == 1)
                {
                    Console.WriteLine("PrintDetailed:");
                    PrintDetailed.Main(args);
                }
                if (index == -1 || index == 2)
                {
                    Console.WriteLine("CaptureSimple:");
                    CaptureSimple.Main(args);
                }
                if (index == -1 || index == 3)
                {
                    Console.WriteLine("RenderSimple:");
                    RenderSimple.Main(args);
                }
                if (index == -1 || index == 4)
                {
                    Console.WriteLine("CaptureAdvanced:");
                    CaptureAdvanced.Main(args);
                }
                if (index == -1 || index == 5)
                {
                    Console.WriteLine("RenderAdvanced:");
                    RenderAdvanced.Main(args);
                }
                if (index == -1 || index == 6)
                {
                    Console.WriteLine("FullDuplex:");
                    FullDuplex.Main(args);
                }
                if (index == -1 || index == 7)
                {
                    Console.WriteLine("Aggregate:");
                    Aggregate.Main(args);
                }
            } catch (XtException e)
            {
                Console.WriteLine("Error:");
                Console.WriteLine("\tSystem: " + XtPrint.SystemToString(XtException.GetSystem(e.GetError())));
                Console.WriteLine("\tCause: " + XtPrint.CauseToString(XtException.GetCause(e.GetError())));
                Console.WriteLine("\tFault: " + XtException.GetFault(e.GetError()));
                Console.WriteLine("\tText: " + XtException.GetText(e.GetError()));
            }
        }
Exemplo n.º 4
0
        public static void Main(String[] args)
        {
            using (XtAudio audio = new XtAudio("Sample", IntPtr.Zero, OnTrace, OnFatal))
            {
                try
                {
                    Console.WriteLine("Win32: " + XtAudio.IsWin32());
                    Console.WriteLine("Version: " + XtAudio.GetVersion());
                    XtService pro = XtAudio.GetServiceBySetup(XtSetup.ProAudio);
                    Console.WriteLine("Pro Audio: " + (pro == null ? "None" : pro.GetName()));
                    XtService system = XtAudio.GetServiceBySetup(XtSetup.SystemAudio);
                    Console.WriteLine("System Audio: " + (system == null ? "None" : system.GetName()));
                    XtService consumer = XtAudio.GetServiceBySetup(XtSetup.ConsumerAudio);
                    Console.WriteLine("Consumer Audio: " + (consumer == null ? "None" : consumer.GetName()));

                    for (int s = 0; s < XtAudio.GetServiceCount(); s++)
                    {
                        XtService service = XtAudio.GetServiceByIndex(s);
                        Console.WriteLine("Service " + service.GetName() + ":");
                        Console.WriteLine("  System: " + service.GetSystem());
                        Console.WriteLine("  Device count: " + service.GetDeviceCount());
                        Console.WriteLine("  Capabilities: " + XtPrint.CapabilitiesToString(service.GetCapabilities()));

                        using (XtDevice defaultInput = service.OpenDefaultDevice(false))
                            Console.WriteLine("  Default input: " + defaultInput);

                        using (XtDevice defaultOutput = service.OpenDefaultDevice(true))
                            Console.WriteLine("  Default output: " + defaultOutput);

                        for (int d = 0; d < service.GetDeviceCount(); d++)
                        {
                            using (XtDevice device = service.OpenDevice(d))
                            {
                                Console.WriteLine("  Device " + device.GetName() + ":");
                                Console.WriteLine("    System: " + device.GetSystem());
                                Console.WriteLine("    Current mix: " + device.GetMix());
                                Console.WriteLine("    Input channels: " + device.GetChannelCount(false));
                                Console.WriteLine("    Output channels: " + device.GetChannelCount(true));
                                Console.WriteLine("    Interleaved access: " + device.SupportsAccess(true));
                                Console.WriteLine("    Non-interleaved access: " + device.SupportsAccess(false));
                            }
                        }
                    }
                } catch (XtException e)
                {
                    Console.WriteLine("Error: system %s, fault %s, cause %s, text %s, message: %s.\n",
                                      XtException.GetSystem(e.GetError()),
                                      XtException.GetFault(e.GetError()),
                                      XtException.GetCause(e.GetError()),
                                      XtException.GetText(e.GetError()),
                                      e.ToString());
                }
            }
        }
Exemplo n.º 5
0
 public override string ToString() => XtPrint.BufferToString(this);
Exemplo n.º 6
0
 public override string ToString()
 {
     return(XtPrint.MixToString(this));
 }
Exemplo n.º 7
0
 public override string ToString()
 {
     return(XtPrint.LatencyToString(this));
 }
Exemplo n.º 8
0
 public override string ToString()
 {
     return(XtPrint.BufferToString(this));
 }
Exemplo n.º 9
0
 public override string ToString()
 {
     return(XtPrint.ChannelsToString(this));
 }
Exemplo n.º 10
0
 public override string ToString() => XtPrint.ChannelsToString(this);
Exemplo n.º 11
0
        private void FormatOrDeviceChanged()
        {
            if (sample.SelectedItem != null)
            {
                var attrs = XtAudio.GetSampleAttributes((XtSample)sample.SelectedItem);
                attributes.Text = XtPrint.AttributesToString(attrs);
            }

            XtFormat inputFormat = GetFormat(false);
            XtDevice inputDevice = this.inputDevice.SelectedItem == null ?
                                   null : ((DeviceView)(this.inputDevice.SelectedItem)).device;
            bool inputSupported = inputDevice == null ? false : inputDevice.SupportsFormat(inputFormat);

            inputFormatSupported.Text = inputSupported.ToString();
            XtBuffer inputBuffer = !inputSupported ? null : inputDevice.GetBuffer(inputFormat);

            inputBufferSizes.Text = !inputSupported ? "N/A" : string.Format("{0} / {1} / {2}",
                                                                            inputBuffer.min.ToString("N1"), inputBuffer.current.ToString("N1"), inputBuffer.max.ToString("N1"));
            inputMix.Text         = inputDevice == null || inputDevice.GetMix() == null ? "N/A" : inputDevice.GetMix().ToString();
            inputInterleaved.Text = inputDevice == null
                ? "N/A"
                : inputDevice.SupportsAccess(true) && inputDevice.SupportsAccess(false)
                ? "Both"
                : inputDevice.SupportsAccess(false)
                ? "False"
                : "True";
            List <ChannelView> inputViews = new List <ChannelView>();

            if (inputDevice != null)
            {
                inputViews = (from i in Enumerable.Range(0, inputDevice.GetChannelCount(false))
                              select new ChannelView {
                    index = i, name = (1 + i) + ": " + inputDevice.GetChannelName(false, i)
                })
                             .ToList();
            }
            inputChannels.DataSource = null;
            inputChannels.DataSource = inputViews;
            inputChannels.SelectedItems.Clear();

            XtFormat outputFormat = GetFormat(true);
            XtDevice outputDevice = this.outputDevice.SelectedItem == null ?
                                    null : ((DeviceView)(this.outputDevice.SelectedItem)).device;
            bool outputSupported = outputDevice == null ? false : outputDevice.SupportsFormat(outputFormat);

            outputFormatSupported.Text = outputSupported.ToString();
            XtBuffer outputBuffer = !outputSupported ? null : outputDevice.GetBuffer(outputFormat);

            outputBufferSizes.Text = !outputSupported ? "N/A" : string.Format("{0} / {1} / {2}",
                                                                              outputBuffer.min.ToString("N1"), outputBuffer.current.ToString("N1"), outputBuffer.max.ToString("N1"));
            outputMix.Text         = outputDevice == null || outputDevice.GetMix() == null ? "N/A" : outputDevice.GetMix().ToString();
            outputInterleaved.Text = outputDevice == null
                ? "N/A"
                : outputDevice.SupportsAccess(true) && outputDevice.SupportsAccess(false)
                ? "Both"
                : outputDevice.SupportsAccess(false)
                ? "False"
                : "True";
            List <ChannelView> outputViews = new List <ChannelView>();

            if (outputDevice != null)
            {
                outputViews = (from i in Enumerable.Range(0, outputDevice.GetChannelCount(true))
                               select new ChannelView {
                    index = i, name = (1 + i) + ": " + outputDevice.GetChannelName(true, i)
                })
                              .ToList();
            }
            outputChannels.DataSource = null;
            outputChannels.DataSource = outputViews;
            outputChannels.SelectedItems.Clear();

            bufferSize.Minimum = 1;
            bufferSize.Maximum = 5000;
            bufferSize.Value   = 1000;
            if (outputBuffer != null)
            {
                bufferSize.Minimum       = (int)Math.Floor(outputBuffer.min);
                bufferSize.Maximum       = (int)Math.Ceiling(outputBuffer.max);
                bufferSize.Value         = (int)Math.Ceiling(outputBuffer.current);
                bufferSize.TickFrequency = (bufferSize.Maximum - bufferSize.Minimum) / 10;
            }
        }
Exemplo n.º 12
0
 public override string ToString() => XtPrint.MixToString(this);
Exemplo n.º 13
0
 public override string ToString() => XtPrint.AttributesToString(this);
Exemplo n.º 14
0
 public override string ToString()
 {
     return(XtPrint.ErrorToString(GetError()));
 }
Exemplo n.º 15
0
 public override string ToString()
 {
     return(XtPrint.AttributesToString(this));
 }
Exemplo n.º 16
0
 public override string ToString() => XtPrint.LatencyToString(this);