Esempio n. 1
0
        void ASIODeviceControlLoad(object sender, EventArgs e)
        {
            int deviceCount = PortAudio.Pa_GetDeviceCount();

            Console.WriteLine("Device count: " + paHostApiInfo.deviceCount + " default input device: " + paHostApiInfo.defaultInputDevice);

            deviceComboBox.Items.Clear();
            for (int i = 0; i < deviceCount; i++)
            {
                PortAudio.PaDeviceInfo  paDeviceInfo = PortAudio.Pa_GetDeviceInfo(i);
                PortAudio.PaHostApiInfo paHostApi    = PortAudio.Pa_GetHostApiInfo(paDeviceInfo.hostApi);
                if (paHostApi.type == PortAudio.PaHostApiTypeId.paASIO)
                {
                    Console.WriteLine("\n#" + i + "\n" + paDeviceInfo);
                    if (paDeviceInfo.maxOutputChannels > 0)
                    {
                        deviceComboBox.Items.Add(new DeviceItem(i, paDeviceInfo));
                        if (i == paHostApiInfo.defaultOutputDevice)
                        {
                            deviceComboBox.SelectedIndex = deviceComboBox.Items.Count - 1;
                        }
                    }
                }
            }

            bufferSizeComboBox.Items.Clear();
            int bufferSize = 256;

            while (bufferSize < 44100 / 2)
            {
                bufferSizeComboBox.Items.Add(bufferSize);
                bufferSize *= 2;
            }
            bufferSizeComboBox.SelectedIndex = 2;
        }
Esempio n. 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);
        }