Exemple #1
0
        public static string comExMsg(uint ec)
        {
            string errmsg = WinapiShit.comEx(ec);

            if (errmsg == "")
            {
                errmsg = "(i don't know what this means but please report it)";
            }

            return("could not start audio capture from device; error code 0x" + ec.ToString("x") + "\r\n\r\n" + errmsg);
        }
Exemple #2
0
        public Testfeed(LSDevice src, int[] chans, VolumeSlider[] vus, int outDev)
        {
            this.src   = src;
            this.chans = chans;
            this.vus   = vus;
            this.ok    = false;

            dummies = new List <DummySink>();

            try
            {
                cap = null;
                if (src.isPlay)
                {
                    cap = new WasapiLoopbackCapture(src.mm);
                }
                else
                {
                    cap = new WasapiCapture(src.mm);
                }
            }
            catch (System.Runtime.InteropServices.COMException ce)
            {
                string errmsg = WinapiShit.comEx((uint)ce.ErrorCode);
                if (errmsg == "")
                {
                    errmsg = "(i don't know what this means but please report it)";
                }

                MessageBox.Show("could not access audio device; error code " + ce.ErrorCode.ToString("x") + "\r\n\r\n" + errmsg);
                return;
            }

            cap.DataAvailable += input_DataAvailable;
            wi = new BufferedWaveProvider(cap.WaveFormat);
            var cap_samples   = wi.ToSampleProvider();
            var chan_splitter = new ChannelSplitter(cap_samples, chans);

            for (var a = 0; a < vus.Length; a++)
            {
                vus[a].SetSource(chan_splitter.output[a]);
                dummies.Add(new DummySink(vus[a]));
            }

            if (outDev >= -1)
            {
                wo = new WaveOut();
                wo.DeviceNumber = outDev;
                wo.Init(chan_splitter);
                wo.Play();
            }
            else
            {
                dummies.Add(new DummySink(chan_splitter));
                wo = null;
            }

            try
            {
                cap.StartRecording();
            }
            catch (System.Runtime.InteropServices.COMException ce)
            {
                MessageBox.Show(WinapiShit.comExMsg((uint)ce.ErrorCode));
                return;
            }
            this.ok = true;
        }