Example #1
0
        public override bool Init()
        {
            if (!base.Init())
            {
                return(false);
            }

            _Sources = new List <CSoundCardSource>();

            DeviceCollection devices = DirectSoundCapture.GetDevices();

            foreach (DeviceInformation dev in devices)
            {
                using (var ds = new DirectSoundCapture(dev.DriverGuid))
                {
                    var device = new CRecordDevice(_Devices.Count, dev.DriverGuid.ToString(), dev.Description, ds.Capabilities.Channels);

                    _Devices.Add(device);
                }
            }

            _Initialized = true;

            return(true);
        }
Example #2
0
        private PortAudioSharp.PortAudio.PaStreamCallbackResult _MyPaStreamCallback(
            IntPtr input,
            IntPtr output,
            uint frameCount,
            ref PortAudioSharp.PortAudio.PaStreamCallbackTimeInfo timeInfo,
            PortAudioSharp.PortAudio.PaStreamCallbackFlags statusFlags,
            IntPtr userData)
        {
            try
            {
                if (frameCount > 0 && input != IntPtr.Zero)
                {
                    CRecordDevice dev = _Devices[userData.ToInt32()];
                    uint          numBytes;
                    numBytes = frameCount * (uint)dev.Channels * 2;

                    byte[] recbuffer = new byte[numBytes];

                    // copy from managed to unmanaged memory
                    Marshal.Copy(input, recbuffer, 0, (int)numBytes);
                    _HandleData(dev, recbuffer);
                }
            }
            catch (Exception e)
            {
                CLog.LogError("Error on Stream Callback (rec): " + e);
            }

            return(PortAudioSharp.PortAudio.PaStreamCallbackResult.paContinue);
        }
Example #3
0
        private void _OnDataReady(object sender, CSampleDataEventArgs e)
        {
            if (!_Initialized)
            {
                return;
            }
            CRecordDevice dev = _Devices.FirstOrDefault(device => device.Driver == e.Guid);

            if (dev == null)
            {
                return;
            }
            _HandleData(dev, e.Data);
        }
Example #4
0
        /// <summary>
        ///     Init PortAudio and list record devices
        /// </summary>
        /// <returns>true if success</returns>
        public override bool Init()
        {
            if (!base.Init())
            {
                return(false);
            }

            try
            {
                _PaHandle = new CPortAudioHandle();

                int hostAPI    = _PaHandle.GetHostApi();
                int numDevices = PortAudioSharp.PortAudio.Pa_GetDeviceCount();
                for (int i = 0; i < numDevices; i++)
                {
                    PortAudioSharp.PortAudio.PaDeviceInfo info = PortAudioSharp.PortAudio.Pa_GetDeviceInfo(i);
                    if (info.hostApi == hostAPI && info.maxInputChannels > 0)
                    {
                        var dev = new CRecordDevice(i, info.name, info.name + i, info.maxInputChannels);

                        _Devices.Add(dev);
                    }
                }

                _RecHandle   = new IntPtr[_Devices.Count];
                _MyRecProc   = _MyPaStreamCallback;
                _Initialized = true;
            }
            catch (Exception e)
            {
                _Initialized = false;
                CLog.LogError("Error initializing PortAudio: " + e.Message);
                Close();
                return(false);
            }

            return(true);
        }
Example #5
0
        private void _SetMicConfig()
        {
            if (_DeviceNr < 0)
            {
                return;
            }
            CRecordDevice device = _Devices[_DeviceNr];

            for (int ch = 0; ch < device.Channels; ++ch)
            {
                device.PlayerChannel[ch] = 0;
            }

            for (int p = 0; p < CSettings.MaxNumPlayer; ++p)
            {
                int ch = _SelectSlides[_SelectSlideRecordPlayer[p]].Selection;

                if (ch > 0)
                {
                    device.PlayerChannel[ch - 1] = p + 1;
                }
            }
        }
Example #6
0
        private void _SetMicConfig()
        {
            if (_DeviceNr < 0)
            {
                return;
            }

            for (int d = 0; d < _Devices.Count; d++)
            {
                for (int c = 0; c < _Devices[d].Channels; c++)
                {
                    if (_Devices[d].PlayerChannel[c] == _SelectedPlayer + 1)
                    {
                        _Devices[d].PlayerChannel[c] = 0;
                    }
                }
            }

            CRecordDevice device = _Devices[_DeviceNr];

            _Texts[_TextDelayPlayer[_SelectedPlayer]].Text = "––– ms";
            if (_SelectSlides[_EditSelectSlideRecordChannels].Selection > 0)
            {
                if (device.PlayerChannel[_SelectSlides[_EditSelectSlideRecordChannels].Selection - 1] > 0)
                {
                    string delay = _Texts[_TextDelayPlayer[device.PlayerChannel[_SelectSlides[_EditSelectSlideRecordChannels].Selection - 1] - 1]].Text;
                    _Texts[_TextDelayPlayer[device.PlayerChannel[_SelectSlides[_EditSelectSlideRecordChannels].Selection - 1] - 1]].Text = _Texts[_TextDelayPlayer[_SelectedPlayer]].Text;
                    _Texts[_TextDelayPlayer[_SelectedPlayer]].Text = delay;
                }

                device.PlayerChannel[_SelectSlides[_EditSelectSlideRecordChannels].Selection - 1] = _SelectedPlayer + 1;
            }

            _SaveMicConfig();

            _UpdatePlayerTexts();
        }