コード例 #1
0
        public SetMicrophone()
        {
            InitializeComponent();

            int waveInDevices = NAudio.Wave.WaveIn.DeviceCount;

            for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
            {
                NAudio.Wave.WaveInCapabilities deviceInfo = NAudio.Wave.WaveIn.GetCapabilities(waveInDevice);
                microphoneList.Items.Add(waveInDevice + ": " + deviceInfo.ProductName);
            }

            microphoneList.SelectedIndex = 0;
            sensitivity.SelectedIndex    = 0;

            sourceStream = new NAudio.Wave.WaveIn();
            sourceStream.DeviceNumber = 0;
            sourceStream.WaveFormat   = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(0).Channels);
            bytesPerChannel           = (sourceStream.WaveFormat.BitsPerSample / 8);
            bytesPerSample            = bytesPerChannel * sourceStream.WaveFormat.Channels;

            sourceStream.DataAvailable += new EventHandler <NAudio.Wave.WaveInEventArgs>(sourceStream_DataAvailable);

            sourceStream.StartRecording();
        }
コード例 #2
0
        private void LoadDeviceLists()
        {
            int iTotalCnt = NAudio.Wave.WaveIn.DeviceCount;

            for (int i = 0; i < iTotalCnt; i++)
            {
                NAudio.Wave.WaveInCapabilities caps = NAudio.Wave.WaveIn.GetCapabilities(i);
                if (caps.Channels > 0)
                {
                    _channelList.Add(new SourceListHolder()
                    {
                        DeviceListNum = i, DeviceName = caps.ProductName, ChannelCount = caps.Channels
                    });
                }
            }

            string[] serialPorts = System.IO.Ports.SerialPort.GetPortNames();
            if (serialPorts != null && serialPorts.Length > 0)
            {
                foreach (string s in serialPorts)
                {
                    _serialPorts.Add(s);
                }
            }
        }
コード例 #3
0
        private void ScanSoundCards()
        {
            Log("Scanning sound cards...");

            listBox1.Items.Clear();
            btnSelect.Enabled = false;
            deviceNumber      = -1;
            for (int i = 0; i < NAudio.Wave.WaveIn.DeviceCount; i++)
            {
                NAudio.Wave.WaveInCapabilities deviceInfo = NAudio.Wave.WaveIn.GetCapabilities(i);
                string name = deviceInfo.ProductName.Trim();
                if (name.Length == 31)
                {
                    name += "...";
                }
                listBox1.Items.Add($"Card {i + 1}: {name}");
            }

            if (listBox1.Items.Count > 0)
            {
                Log($"Identified {listBox1.Items.Count} active microphones. Select the one you wish to monitor from the list.");
            }
            else
            {
                Log($"ERROR: no active microphones were found! Double-check your sound card settings and ensure a recording device is enabled.", true);
            }
        }
コード例 #4
0
        public Form1()
        {
            InitializeComponent();

            protocol = new ConnectionMumbleProtocol();
            protocol.channelMessageReceivedDelegate  = ChannelMessageReceivedDelegate;
            protocol.personalMessageReceivedDelegate = PersonalMessageReceivedDelegate;
            protocol.encodedVoice          = EncodedVoiceDelegate;
            protocol.userJoinedDelegate    = UserJoinedDelegate;
            protocol.userLeftDelegate      = UserLeftDelegate;
            protocol.channelJoinedDelegate = ChannelJoinedDelegate;
            protocol.channelLeftDelegate   = ChannelLeftDelegate;
            protocol.serverConfigDelegate  = ServerConfigDelegate;

            tvUsers.ExpandAll();

            recorder = new MicrophoneRecorder(protocol);
            int deviceCount = NAudio.Wave.WaveIn.DeviceCount;

            for (int i = 0; i < deviceCount; i++)
            {
                NAudio.Wave.WaveInCapabilities deviceInfo = NAudio.Wave.WaveIn.GetCapabilities(i);
                string deviceText = string.Format("{0}, {1} channels", deviceInfo.ProductName, deviceInfo.Channels);
                comboBox1.Items.Add(deviceText);
            }
            if (deviceCount > 0)
            {
                MicrophoneRecorder.SelectedDevice = 0;
                comboBox1.SelectedIndex           = 0;
            }
        }
コード例 #5
0
        private void LoadDeviceLists()
        {
            _waveOutList.Clear();
            _waveOutList.Add(new SourceListHolder()
            {
                DeviceListNum = -1, DeviceName = "Default"
            });

            int iTotalCnt = NAudio.Wave.WaveOut.DeviceCount;

            for (int i = 0; i < iTotalCnt; i++)
            {
                NAudio.Wave.WaveOutCapabilities caps = NAudio.Wave.WaveOut.GetCapabilities(i);
                _waveOutList.Add(new SourceListHolder()
                {
                    DeviceListNum = i, DeviceName = caps.ProductName
                });
            }

            _channelList.Clear();
            iTotalCnt = NAudio.Wave.WaveIn.DeviceCount;
            for (int i = 0; i < iTotalCnt; i++)
            {
                NAudio.Wave.WaveInCapabilities caps = NAudio.Wave.WaveIn.GetCapabilities(i);
                if (caps.Channels > 0)
                {
                    _channelList.Add(new SourceListHolder()
                    {
                        DeviceListNum = i, DeviceName = caps.ProductName, ChannelCount = caps.Channels
                    });
                }
            }

            _noiseFloorList.Clear();
            _noiseFloorList.Add(new NoiseFloorHolder()
            {
                NoiseFloorName = "Low", NoiseFloorValue = Common.NoiseFloor.Low
            });
            _noiseFloorList.Add(new NoiseFloorHolder()
            {
                NoiseFloorName = "Normal", NoiseFloorValue = Common.NoiseFloor.Normal
            });
            _noiseFloorList.Add(new NoiseFloorHolder()
            {
                NoiseFloorName = "High", NoiseFloorValue = Common.NoiseFloor.High
            });
            _noiseFloorList.Add(new NoiseFloorHolder()
            {
                NoiseFloorName = "Extra High", NoiseFloorValue = Common.NoiseFloor.ExtraHigh
            });
            _noiseFloorList.Add(new NoiseFloorHolder()
            {
                NoiseFloorName = "Custom", NoiseFloorValue = Common.NoiseFloor.Custom
            });
        }
コード例 #6
0
                public static List <String> Get_Input_Devices()
                {
                    List <String> InputSelection = new List <string>();
                    int           DC             = NAudio.Wave.WaveIn.DeviceCount;

                    for (int i = 0; i < DC; i++)
                    {
                        NAudio.Wave.WaveInCapabilities DCap = NAudio.Wave.WaveIn.GetCapabilities(i);
                        InputSelection.Add(String.Format("{0}, {1} Channels", DCap.ProductName, DCap.Channels));
                    }
                    return(InputSelection);
                }
コード例 #7
0
        public Form1()
        {
            InitializeComponent();

            protocol = new ConnectionMumbleProtocol();
            protocol.channelMessageReceivedDelegate  = ChannelMessageReceivedDelegate;
            protocol.personalMessageReceivedDelegate = PersonalMessageReceivedDelegate;
            protocol.encodedVoice          = EncodedVoiceDelegate;
            protocol.userJoinedDelegate    = UserJoinedDelegate;
            protocol.userLeftDelegate      = UserLeftDelegate;
            protocol.channelJoinedDelegate = ChannelJoinedDelegate;
            protocol.channelLeftDelegate   = ChannelLeftDelegate;
            protocol.serverConfigDelegate  = ServerConfigDelegate;

            tvUsers.ExpandAll();
            tvUsers.StartUpdating();

            playback = new SpeakerPlayback();
            int playbackDeviceCount = NAudio.Wave.WaveOut.DeviceCount;

            cbPlaybackDevices.Items.Add("Default Playback Device");
            for (int i = 0; i < playbackDeviceCount; i++)
            {
                NAudio.Wave.WaveOutCapabilities deviceInfo = NAudio.Wave.WaveOut.GetCapabilities(i);
                string deviceText = string.Format("{0}, {1} channels", deviceInfo.ProductName, deviceInfo.Channels);
                cbPlaybackDevices.Items.Add(deviceText);
            }
            cbPlaybackDevices.SelectedIndex = 0;
            SpeakerPlayback.SelectedDevice  = cbPlaybackDevices.SelectedIndex - 1;

            recorder = new MicrophoneRecorder(protocol);
            int recorderDeviceCount = NAudio.Wave.WaveIn.DeviceCount;

            for (int i = 0; i < recorderDeviceCount; i++)
            {
                NAudio.Wave.WaveInCapabilities deviceInfo = NAudio.Wave.WaveIn.GetCapabilities(i);
                string deviceText = string.Format("{0}, {1} channels", deviceInfo.ProductName, deviceInfo.Channels);
                cbRecordingDevices.Items.Add(deviceText);
            }
            if (recorderDeviceCount > 0)
            {
                MicrophoneRecorder.SelectedDevice = 0;
                cbRecordingDevices.SelectedIndex  = 0;
            }

            numVoiceDetectorThreshold.Value = Convert.ToDecimal(recorder.VoiceDetectionThreshold) * 100;
        }
コード例 #8
0
        private NAudio.Wave.WaveInEvent FindWaveIn()
        {
            int waveInDevices = NAudio.Wave.WaveIn.DeviceCount;

            for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
            {
                NAudio.Wave.WaveInCapabilities devCaps = NAudio.Wave.WaveIn.GetCapabilities(waveInDevice);
                if (DevicesMatch(devCaps.ProductName, dev.FriendlyName))
                {
                    NAudio.Wave.WaveInEvent wi = new NAudio.Wave.WaveInEvent();
                    wi.DeviceNumber = waveInDevice;
                    wi.WaveFormat   = new NAudio.Wave.WaveFormat(44100, devCaps.Channels);
                    return(wi);
                }
            }
            return(null);
        }
コード例 #9
0
        /// <summary>
        /// デバイス情報を返却
        /// </summary>
        /// <see href="https://github.com/naudio/NAudio/blob/master/NAudio/Wave/MmeInterop/WaveInCapabilities.cs"/>
        /// <example>
        /// string name = capabilities.productName;
        /// </example>
        public static string GetDeveceCapabilities(int deviceId)
        {
            NAudio.Wave.WaveInCapabilities capabilities = NAudio.Wave.WaveIn.GetCapabilities(deviceId);

            return(capabilities.ProductName);
        }