コード例 #1
0
ファイル: CPortAudioRecord.cs プロジェクト: winterdl/Vocaluxe
        /// <summary>
        /// Init PortAudio and list record devices
        /// </summary>
        /// <returns>true if success</returns>
        public bool Init()
        {
            _Devices = new List <SRecordDevice>();

            try
            {
                if (_initialized)
                {
                    CloseAll();
                }

                if (errorCheck("Initialize", PortAudio.Pa_Initialize()))
                {
                    return(false);
                }

                _initialized = true;
                int hostAPI = apiSelect();

                int numDevices = PortAudio.Pa_GetDeviceCount();
                for (int i = 0; i < numDevices; i++)
                {
                    PortAudio.PaDeviceInfo info = PortAudio.Pa_GetDeviceInfo(i);
                    if (info.hostApi == hostAPI && info.maxInputChannels > 0)
                    {
                        SRecordDevice dev = new SRecordDevice();

                        dev.ID     = i;
                        dev.Name   = info.name;
                        dev.Driver = info.name + i.ToString();
                        dev.Inputs = new List <SInput>();

                        SInput inp = new SInput();
                        inp.Name = "Default";

                        inp.Channels = info.maxInputChannels;
                        if (inp.Channels > 2)
                        {
                            inp.Channels = 2; //more are not supported in vocaluxe
                        }
                        dev.Inputs.Add(inp);
                        _Devices.Add(dev);
                    }
                }

                _recHandle = new IntPtr[_Devices.Count];
                _myRecProc = new PortAudio.PaStreamCallbackDelegate(myPaStreamCallback);

                _DeviceConfig = _Devices.ToArray();
            }
            catch (Exception e)
            {
                _initialized = false;
                CLog.LogError("Error initializing PortAudio: " + e.Message);
                return(false);
            }

            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Init PortAudio and list record devices
        /// </summary>
        /// <returns>true if success</returns>
        public bool Init()
        {
            _Devices = new List<SRecordDevice>();

            try
            {
                if (_initialized)
                    CloseAll();

                if (errorCheck("Initialize", PortAudio.Pa_Initialize()))
                    return false;

                _initialized = true;
                int hostAPI = apiSelect();

                int numDevices = PortAudio.Pa_GetDeviceCount();
                for (int i = 0; i < numDevices; i++)
                {
                    PortAudio.PaDeviceInfo info = PortAudio.Pa_GetDeviceInfo(i);
                    if (info.hostApi == hostAPI && info.maxInputChannels > 0)
                    {
                        SRecordDevice dev = new SRecordDevice();

                        dev.ID = i;
                        dev.Name = info.name;
                        dev.Driver = info.name + i.ToString();
                        dev.Inputs = new List<SInput>();

                        SInput inp = new SInput();
                        inp.Name = "Default";

                        inp.Channels = info.maxInputChannels;
                        if (inp.Channels > 2)
                            inp.Channels = 2; //more are not supported in vocaluxe

                        dev.Inputs.Add(inp);
                        _Devices.Add(dev);
                    }
                }

                _recHandle = new IntPtr[_Devices.Count];
                _myRecProc = new PortAudio.PaStreamCallbackDelegate(myPaStreamCallback);

                _DeviceConfig = _Devices.ToArray();
            }
            catch (Exception e)
            {
                _initialized = false;
                CLog.LogError("Error initializing PortAudio: " + e.Message);
                return false;
            }

            return true;
        }
コード例 #3
0
        public bool Init()
        {
            DeviceCollection devices = DirectSoundCapture.GetDevices();

            _Devices = new List <SRecordDevice>();
            _Sources = new List <SoundCardSource>();

            int id = 0;

            foreach (DeviceInformation dev in devices)
            {
                DirectSoundCapture ds = new DirectSoundCapture(dev.DriverGuid);

                SRecordDevice device = new SRecordDevice();
                device.Driver = dev.DriverGuid.ToString();
                device.ID     = id;
                device.Name   = dev.Description;
                device.Inputs = new List <SInput>();

                SInput inp = new SInput();
                inp.Name     = "Default";
                inp.Channels = ds.Capabilities.Channels;

                if (inp.Channels > 2)
                {
                    inp.Channels = 2; //more are not supported in vocaluxe
                }
                device.Inputs.Add(inp);
                _Devices.Add(device);

                id++;
                ds.Dispose();
            }

            _DeviceConfig = _Devices.ToArray();
            _initialized  = true;

            return(true);
        }
コード例 #4
0
        public bool Init()
        {
            DeviceCollection devices = DirectSoundCapture.GetDevices();
            _Devices = new List<SRecordDevice>();
            _Sources = new List<SoundCardSource>();

            int id = 0;
            foreach (DeviceInformation dev in devices)
            {
                DirectSoundCapture ds = new DirectSoundCapture(dev.DriverGuid);

                SRecordDevice device = new SRecordDevice();
                device.Driver = dev.DriverGuid.ToString();
                device.ID = id;
                device.Name = dev.Description;
                device.Inputs = new List<SInput>();

                SInput inp = new SInput();
                inp.Name = "Default";
                inp.Channels = ds.Capabilities.Channels;

                if (inp.Channels > 2)
                    inp.Channels = 2; //more are not supported in vocaluxe

                device.Inputs.Add(inp);
                _Devices.Add(device);

                id++;
                ds.Dispose();
            }

            _DeviceConfig = _Devices.ToArray();
            _initialized = true;

            return true;
        }
コード例 #5
0
ファイル: CBassRecord.cs プロジェクト: bohning/Vocaluxe
        public bool Init()
        {
            _Devices = new List<SRecordDevice>();

            try
            {
                BASS_DEVICEINFO info = new BASS_DEVICEINFO();
                for (int n = 0; Bass.BASS_RecordGetDeviceInfo(n, info); n++)
                {
                    if (info.IsEnabled)
                    {
                        SRecordDevice dev = new SRecordDevice();

                        dev.ID = n;
                        dev.Name = info.name;
                        dev.Driver = info.driver;
                        dev.Inputs = new List<SInput>();

                        if (Bass.BASS_RecordInit(n))
                        {
                            string name = String.Empty;
                            for (int j = 0; ((name = Bass.BASS_RecordGetInputName(j)) != null); j++)
                            {
                                SInput inp = new SInput();
                                inp.Name = name;

                                inp.Channels = 2; //TODO: how to retrieve the amount of channels?

                                dev.Inputs.Add(inp);
                            }

                            _Devices.Add(dev);
                            Bass.BASS_RecordFree();
                        }
                    }
                }
            }
            catch (Exception)
            {

                //throw;
            }

            return true;
        }