/// <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);
        }
        /// <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;
        }
Exemple #3
0
        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;
        }
        public bool Start(SRecordDevice[] DeviceConfig)
        {
            if (!_initialized)
                return false;

            for (int i = 0; i < _Buffer.Length; i++)
            {
                _Buffer[i].Reset();
            }

            _DeviceConfig = DeviceConfig;
            bool[] active = new bool[DeviceConfig.Length];
            Guid[] guid = new Guid[DeviceConfig.Length];
            short[] channels = new short[DeviceConfig.Length];
            for (int dev = 0; dev < DeviceConfig.Length; dev++)
            {
                active[dev] = false;
                for (int inp = 0; inp < DeviceConfig[dev].Inputs.Count; inp++)
                {
                    if (DeviceConfig[dev].Inputs[inp].PlayerChannel1 > 0 ||
                        DeviceConfig[dev].Inputs[inp].PlayerChannel2 > 0)
                        active[dev] = true;
                    guid[dev] = new Guid(DeviceConfig[dev].Driver);
                    channels[dev] = (short)DeviceConfig[dev].Inputs[0].Channels;
                }
            }

            for (int i = 0; i < _Devices.Count; i++)
            {
                if (active[i])
                {
                    SoundCardSource source = new SoundCardSource(guid[i], channels[i]);
                    source.SampleRateKHz = 44.1;
                    source.SampleDataReady += this.OnDataReady;
                    source.Start();

                    _Sources.Add(source);

                }
            }

            _DeviceConfig = DeviceConfig;
            return true;
        }
Exemple #5
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);
        }
        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;
        }
Exemple #7
0
        public bool Start(SRecordDevice[] DeviceConfig)
        {
            for (int i = 0; i < _Buffer.Length; i++)
            {
                _Buffer[i].Reset();
            }

            for (int i = 0; i < _recHandle.Length; i++)
            {
                _recHandle[i] = -1;
            }

            _DeviceConfig = DeviceConfig;
            bool[] active = new bool[DeviceConfig.Length];
            for (int dev = 0; dev < DeviceConfig.Length; dev++)
            {
                active[dev] = false;
                for (int inp = 0; inp < DeviceConfig[dev].Inputs.Count; inp++)
                {
                    if (DeviceConfig[dev].Inputs[inp].PlayerChannel1 > 0 ||
                        DeviceConfig[dev].Inputs[inp].PlayerChannel2 > 0)
                        active[dev] = true;
                }
            }

            bool result = true;
            for (int i = 0; i < _recHandle.Length; i++)
            {
                if (active[i])
                {
                    if (Bass.BASS_RecordInit(i))
                    {
                        _recHandle[i] = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, 20, _myRecProc, IntPtr.Zero);

                        // start recording
                        result |= Bass.BASS_ChannelPlay(_recHandle[i], false);
                    }
                }
            }

            return result;
        }
Exemple #8
-1
        /// <summary>
        /// Start Voice Capturing
        /// </summary>
        /// <param name="DeviceConfig"></param>
        /// <returns></returns>
        public bool Start(SRecordDevice[] DeviceConfig)
        {
            if (!_initialized)
                return false;

            for (int i = 0; i < _Buffer.Length; i++)
            {
                _Buffer[i].Reset();
            }

            for (int i = 0; i < _recHandle.Length; i++)
            {
                _recHandle[i] = IntPtr.Zero;
            }

            _DeviceConfig = DeviceConfig;
            bool[] active = new bool[DeviceConfig.Length];
            for (int dev = 0; dev < DeviceConfig.Length; dev++)
            {
                active[dev] = false;
                for (int inp = 0; inp < DeviceConfig[dev].Inputs.Count; inp++)
                {
                    if (DeviceConfig[dev].Inputs[inp].PlayerChannel1 > 0 ||
                        DeviceConfig[dev].Inputs[inp].PlayerChannel2 > 0)
                        active[dev] = true;
                }
            }

            bool result = true;
            for (int i = 0; i < _recHandle.Length; i++)
            {
                if (active[i])
                {
                    PortAudio.PaStreamParameters inputParams = new PortAudio.PaStreamParameters();
                    inputParams.channelCount = _DeviceConfig[i].Inputs[0].Channels;
                    inputParams.device = _DeviceConfig[i].ID;
                    inputParams.sampleFormat = PortAudio.PaSampleFormat.paInt16;
                    inputParams.suggestedLatency = PortAudio.Pa_GetDeviceInfo(_DeviceConfig[i].ID).defaultLowInputLatency;

                    if (errorCheck("OpenStream", PortAudio.Pa_OpenStream(
                        out _recHandle[i],
                        ref inputParams,
                        IntPtr.Zero,
                        44100,
                        PortAudio.paFramesPerBufferUnspecified,
                        PortAudio.PaStreamFlags.paNoFlag,
                        _myRecProc,
                        new IntPtr(i))))
                        return false;

                    if (errorCheck("Start Stream", PortAudio.Pa_StartStream(_recHandle[i])))
                        return false;
                }
            }

            return result;
        }