// =================  Audio Engineering & Frequency Analysis =================
        public void LlenarComboDispositivos()
        {
            for (int i = 0; i < WaveIn.DeviceCount; i++)
            {
                // La variable tipo WaveInCapabilities almacena los dispositivos en la iteración [i] hasta guardar todos los aparatos de entrada
                WaveInCapabilities capacidades = WaveIn.GetCapabilities(i);

                // Ahora agregamos a los "items" de nuestro combo box el Nombre del dispositivo almacenado en capacidades[i]
                cmb_Dispositivos.Items.Add(capacidades.ProductName);
            }
            cmb_Dispositivos.SelectedIndex = 0;
        }
Esempio n. 2
0
        /// <summary>
        /// Start audio source.
        /// </summary>
        ///
        /// <remarks>Starts audio source and return execution to caller. audio source
        /// object creates background thread and notifies about new frames with the
        /// help of <see cref="DataAvailable"/> event.</remarks>
        ///
        /// <exception cref="ArgumentException">audio source is not specified.</exception>
        ///
        public void Start()
        {
            if (string.IsNullOrEmpty(_source))
            {
                throw new ArgumentException("Audio source is not specified.");
            }


            if (_started)
            {
                return;
            }

            // check source
            lock (_lock)
            {
                if (_started)
                {
                    return;
                }

                int i = 0, selind = -1;
                for (var n = 0; n < WaveIn.DeviceCount; n++)
                {
                    if (WaveIn.GetCapabilities(n).ProductName == _source)
                    {
                        selind = i;
                    }
                    i++;
                }
                if (selind == -1)
                {
                    AudioFinished?.Invoke(this, new PlayingFinishedEventArgs(ReasonToFinishPlaying.DeviceLost));
                    return;
                }

                _started = true;
                _waveIn  = new WaveInEvent
                {
                    BufferMilliseconds = 200,
                    DeviceNumber       = selind,
                    WaveFormat         = RecordingFormat
                };
                _waveIn.DataAvailable    += WaveInDataAvailable;
                _waveIn.RecordingStopped += WaveInRecordingStopped;

                _waveProvider  = new WaveInProvider(_waveIn);
                _sampleChannel = new SampleChannel(_waveProvider);
                _sampleChannel.PreVolumeMeter += SampleChannelPreVolumeMeter;
                _waveIn.StartRecording();
            }
        }
Esempio n. 3
0
        private void setupMicList()
        {
            int waveInDevices = WaveIn.DeviceCount;

            for (int i = 0; i < waveInDevices; i++)
            {
                WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(i);                  //device info

                devicesComboBox.Items.Add(deviceInfo.ProductName);
            }

            devicesComboBox.SelectedIndex = 0;
        }
Esempio n. 4
0
        private void GetInputDevices()
        {
            for (int i = 0; i < WaveIn.DeviceCount; i++)
            {
                var capabilities = WaveIn.GetCapabilities(i);
                Cmb_InputDevices.Items.Add(capabilities.ProductName);
            }

            if (Cmb_InputDevices.Items.Count > 0)
            {
                Cmb_InputDevices.SelectedIndex = 0;
            }
        }
Esempio n. 5
0
        public static IList <Device> GetDevices()
        {
            var list = new List <Device>();

            var waveInDevices = WaveIn.DeviceCount;

            for (int deviceIndex = 0; deviceIndex < waveInDevices; deviceIndex++)
            {
                list.Add(DeviceMapper.Map(deviceIndex, WaveIn.GetCapabilities(deviceIndex)));
            }

            return(list);
        }
Esempio n. 6
0
        public SoundBoard()
        {
            InitializeComponent();
            Console.WriteLine("INIT");
            int waveInDevices = WaveIn.DeviceCount;

            for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
            {
                WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
                Console.WriteLine("Device {0}: {1}, {2} channels", waveInDevice, deviceInfo.ProductName, deviceInfo.Channels);
            }
            load_platforms();
        }
Esempio n. 7
0
        public void Setup()
        {
            WaveInCapabilities capabilities = WaveIn.GetCapabilities(deviceNumber);

            foreach (int waveFormat in Enum.GetValues(typeof(SupportedWaveFormat)))
            {
                if (capabilities.SupportsWaveFormat((SupportedWaveFormat)waveFormat))
                {
                    SetWaveFormat((SupportedWaveFormat)waveFormat);
                    break;
                }
            }
        }
Esempio n. 8
0
 public void Activated(object state)
 {
     this.recordingDevices.Clear();
     for (int n = 0; n < WaveIn.DeviceCount; n++)
     {
         this.recordingDevices.Add(WaveIn.GetCapabilities(n).ProductName);
     }
     this.recordingDevices2.Clear();
     for (int n = 0; n < WaveIn.DeviceCount; n++)
     {
         this.recordingDevices2.Add(WaveIn.GetCapabilities(n).ProductName);
     }
 }
Esempio n. 9
0
        // Obtain all current recording devices.
        public static string[] GetDevices()
        {
            deviceTotal = WaveIn.DeviceCount;
            string[] devices = new string[deviceTotal];

            for (int deviceCount = 0; deviceCount < deviceTotal; deviceCount++)
            {
                WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(deviceCount);
                devices[deviceCount] = deviceCount + ": " + deviceInfo.ProductName + " - " + deviceInfo.Channels + " Channels";
            }

            return(devices);
        }
Esempio n. 10
0
        public static string[] WaveInDevices()
        {
            List <string> str           = new List <string>();
            int           waveInDevices = WaveIn.DeviceCount;

            for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
            {
                WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
                str.Add(String.Format("Device {0}: {1}", waveInDevice, deviceInfo.ProductName));
            }
            ;
            return(str.ToArray());
        }
Esempio n. 11
0
        public string[] GetIDev()
        {
            string [] res           = new string[WaveIn.DeviceCount];
            int       waveInDevices = WaveIn.DeviceCount;

            for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
            {
                WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
                res[waveInDevice] = string.Format("Device {0}: {1}, {2} channels",
                                                  waveInDevice, deviceInfo.ProductName, deviceInfo.Channels);
            }
            return(res);
        }
Esempio n. 12
0
        public RecordingDevice(bool enabled)
        {
            this.enabled = enabled;

            if (DeviceManager.Instance.RecordingDevice != null)
            {
                if (DeviceManager.Instance.RecordingDevice.Number < WaveIn.DeviceCount)
                {
                    var deviceCaps = WaveIn.GetCapabilities(DeviceManager.Instance.RecordingDevice.Number);
                    this.SetRecordingSettings(48000, (deviceCaps.Channels > 2) ? 2 : deviceCaps.Channels);
                }
            }
        }
Esempio n. 13
0
        private int SearchDeviceNumber(DataFlow dataflow, string friendlyName)
        {
            int result = 0;

            for (int i = 0; i < WaveIn.DeviceCount; i++)
            {
                if (WaveIn.GetCapabilities(i).ProductName.Equals(friendlyName, StringComparison.OrdinalIgnoreCase))
                {
                    result = i;
                }
            }
            return(result);
        }
Esempio n. 14
0
 private void GetWaveInDeviceId(string deviceName)
 {
     this.WaveInDevices = new string[WaveIn.DeviceCount];
     for (int i = 0; i < WaveIn.DeviceCount; i++)
     {
         var caps = WaveIn.GetCapabilities(i);
         this.WaveInDevices[i] = caps.ProductName;
         if (caps.ProductName.StartsWith(deviceName) || deviceName.StartsWith(caps.ProductName))
         {
             this.WaveInDeviceId = i;
         }
     }
 }
Esempio n. 15
0
        private void RefreshIn()
        {
            RecordInputCheck.Checked = true;
            InputsCombo.Items.Clear();
            _inDevices.Clear();

            for (int i = 0; i < WaveIn.DeviceCount; i++)
            {
                InputsCombo.Items.Add(WaveIn.GetCapabilities(i).ProductName);
                _inDevices.Add(i == 0);
            }
            InputsCombo.SelectedItem = 0;
        }
Esempio n. 16
0
        public AudioEngine()
        {
            if (Config.Instance.RecordingDevice != null && WaveIn.DeviceCount != 0 && Config.Instance.RecordingDevice.Number <= WaveIn.DeviceCount)
            {
                var capabilities = WaveIn.GetCapabilities(Config.Instance.RecordingDevice.Number);
                SetRecordingSettings(48000, capabilities.Channels > 2 ? 2 : capabilities.Channels);
            }

            if (Config.Instance.PlaybackDevice != null && WaveOut.DeviceCount != 0 && Config.Instance.PlaybackDevice.Number <= WaveOut.DeviceCount)
            {
                var capabilities = WaveOut.GetCapabilities(Config.Instance.PlaybackDevice.Number);
                SetPlaybackSettings(48000, capabilities.Channels > 2 ? 2 : capabilities.Channels);
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Gets a list of Windows recording devices.
        /// </summary>
        /// <returns>Collection of devices.</returns>
        public static IEnumerable <RecordingDeviceInfo> GetRecordingDeviceList()
        {
            var result = new List <RecordingDeviceInfo>();

            var count = WaveIn.DeviceCount;

            for (var n = 0; n < count; ++n)
            {
                var caps = WaveIn.GetCapabilities(n);
                result.Add(new RecordingDeviceInfo(n, caps.ProductName));
            }

            return(result);
        }
Esempio n. 18
0
        /// <summary>
        /// Returns a list of audio device names that support recording in the format we need.
        /// </summary>
        internal static List <string> GetInputDeviceNames()
        {
            List <string> names = new List <string>();

            for (int i = 0; i < WaveIn.DeviceCount; i++)
            {
                var capabilities = WaveIn.GetCapabilities(i);
                if (capabilities.SupportsWaveFormat(RequiredSupportedWaveFormat))
                {
                    names.Add(capabilities.ProductName);
                }
            }
            return(names);
        }
Esempio n. 19
0
        /// <summary>
        /// Returns a list of audio device names that support recording in the format we need.
        /// </summary>
        public IReadOnlyList <IAudioInput> GetInputs()
        {
            List <IAudioInput> inputs = new List <IAudioInput>();

            for (int i = 0; i < WaveIn.DeviceCount; i++)
            {
                var capabilities = WaveIn.GetCapabilities(i);
                if (capabilities.SupportsWaveFormat(RequiredSupportedWaveFormat))
                {
                    inputs.Add(new InputDevice(capabilities.ProductName, i));
                }
            }
            return(inputs.AsReadOnly());
        }
Esempio n. 20
0
        public void start_voice_chat(Socket voice_socket)
        {
            voice_state  = true;
            sourceStream = new WaveInEvent
            {
                DeviceNumber = 0,
                WaveFormat   = new WaveFormat(8000, 16, WaveIn.GetCapabilities(0).Channels)
            };

            sourceStream.DataAvailable += sourceStream_DataAvailable;
            P2P_Communication.Voice_Receive(voice_socket, recievedStream, waveProvider, this);
            //sourceStream.DataAvailable += sourceStream_DataAvailable;
            sourceStream.StartRecording();
        }
Esempio n. 21
0
        public static string[] GetDeviceNames()
        {
            var res           = new List <string>();
            int waveInDevices = WaveIn.DeviceCount;

            for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
            {
                WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
                res.Add(deviceInfo.ProductName);
                //Console.WriteLine("Device {0}: {1}, {2} channels", waveInDevice, deviceInfo.ProductName, deviceInfo.Channels);
            }

            return(res.ToArray());
        }
Esempio n. 22
0
 private int GetMicDeviceId()
 {
     int waveInDevices = WaveIn.DeviceCount;
     for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
     {
         WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
         if (deviceInfo.ProductName.Contains("麦克风"))
         {
             return waveInDevice;
         }
         //   Console.WriteLine("Device {0}: {1}, {2} channels", waveInDevice, deviceInfo.ProductName, deviceInfo.Channels);
     }
     return 0;
 }
Esempio n. 23
0
        private void Form2_Load(object sender, EventArgs e)
        {
            for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
            {
                WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
                richTextBox1.AppendText("Device " + waveInDevice + " " + deviceInfo.ProductName + ", " + deviceInfo.Channels + " channels \n");
                Values.micname = deviceInfo.ProductName;
            }

            lblCreator.Text = "by /id/beggarboy";

            txtMic.Text = Convert.ToString(Values.micpicked);
            txtVol.Text = Convert.ToString(Values.prefvol);
        }
Esempio n. 24
0
        public zStackoverflowTest()
        {
            InitializeComponent();

            int waveInDevices = WaveIn.DeviceCount;

            for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
            {
                WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
                txtArea.AppendText(String.Format("Device {0}: {1}, {2} channels\n", waveInDevice, deviceInfo.ProductName, deviceInfo.Channels));
            }

            waveIn = null;
        }
Esempio n. 25
0
        public object Execute(DevicesArgs args)
        {
            var model = new DevicesViewModel();

            int waveInDevices = WaveIn.DeviceCount;

            for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
            {
                WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
                model.Devices.Add($"Device {waveInDevice}: {deviceInfo.ProductName}, {deviceInfo.Channels} channels");
            }

            return(View("Devices", model));
        }
Esempio n. 26
0
        public MachineTool()
        {
            InitializeComponent();
            stop.Enabled = false;

            mAdapter.AddDataItem(mAvail);
            mAvail.Value = "AVAILABLE";

            mAdapter.AddDataItem(mEStop);

            mAdapter.AddDataItem(mMode);
            mAdapter.AddDataItem(mExec);

            mAdapter.AddDataItem(mFunctionalMode);
            mAdapter.AddDataItem(mProgram);
            mAdapter.AddDataItem(mMessage);

            mAdapter.AddDataItem(mPosition);
            mAdapter.AddDataItem(mxLoad);

            mAdapter.AddDataItem(mSpeed);
            mAdapter.AddDataItem(mcLoad);

            mAdapter.AddDataItem(mSystem);
            mAdapter.AddDataItem(mTemp);
            mAdapter.AddDataItem(mOverload);
            mAdapter.AddDataItem(mTravel);
            mAdapter.AddDataItem(mFillLevel);

            mAdapter.AddDataItem(mAudio);

            int count = WaveIn.DeviceCount;

            for (int dev = 0; dev < count; dev++)
            {
                WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(dev);
                Console.WriteLine("Device {0}: {1}, {2} channels",
                                  dev, deviceInfo.ProductName, deviceInfo.Channels);
            }

            mWave = new WaveIn();
            mWave.DeviceNumber   = 0;
            mWave.WaveFormat     = new WaveFormat(8000, 1);
            mWave.DataAvailable += waveIn_DataAvailable;

            mAdapter.AddDataItem(mCommonVariable);

            string[] row = { "1", "2", "3", "4" };
            commonVariables.Rows.Add(row);
        }
Esempio n. 27
0
        private void LoadDevices()
        {
            for (int deviceId = 0; deviceId < WaveIn.DeviceCount; deviceId++)
            {
                var deviceInfo = WaveIn.GetCapabilities(deviceId);
                RecordingDeviceComboBox.Items.Add(deviceInfo.ProductName);
            }

            for (int deviceId = 0; deviceId < WaveOut.DeviceCount; deviceId++)
            {
                var deviceInfo = WaveOut.GetCapabilities(deviceId);
                PlaybackDeviceComboBox.Items.Add(deviceInfo.ProductName);
            }
        }
Esempio n. 28
0
        private void Start_Click(object sender, RoutedEventArgs e)
        {
            waveIn = new WaveIn();
            waveIn.DeviceNumber = 0;
            string outputFilename = @"F:\demo.mp3";

            waveIn.WaveFormat = new WaveFormat(44100, WaveIn.GetCapabilities(waveIn.DeviceNumber).Channels);

            waveIn.DataAvailable += new EventHandler <WaveInEventArgs>(waveIn_DataAvailable);
            waveWriter            = new WaveFileWriter(outputFilename, waveIn.WaveFormat);
            waveIn.StartRecording();
            MainWindow.SnackbarMessage.Content = "Запись началась!";
            MainWindow.Snackbar.IsActive       = true;
        }
Esempio n. 29
0
        /// <summary>
        /// Start audio source.
        /// </summary>
        ///
        /// <remarks>Starts audio source and return execution to caller. audio source
        /// object creates background thread and notifies about new frames with the
        /// help of <see cref="DataAvailable"/> event.</remarks>
        ///
        /// <exception cref="ArgumentException">audio source is not specified.</exception>
        ///
        public void Start()
        {
            if (!IsRunning)
            {
                // check source

                int i = 0, selind = -1;
                for (int n = 0; n < WaveIn.DeviceCount; n++)
                {
                    if (WaveIn.GetCapabilities(n).ProductName == _source)
                    {
                        selind = i;
                    }
                    i++;
                }
                if (selind == -1)
                {
                    //device no longer connected or not configured
                    if (i > 0)
                    {
                        selind = 0;
                    }
                    else
                    {
                        //if (AudioSourceError != null)
                        //    AudioSourceError(this, new AudioSourceErrorEventArgs("not connected"));
                        if (AudioFinished != null)
                        {
                            AudioFinished(this, ReasonToFinishPlaying.DeviceLost);
                        }
                        return;
                    }
                }

                _waveIn = new WaveIn {
                    BufferMilliseconds = 200, DeviceNumber = selind, WaveFormat = RecordingFormat
                };
                _waveIn.DataAvailable    += WaveInDataAvailable;
                _waveIn.RecordingStopped += WaveInRecordingStopped;

                _waveProvider  = new WaveInProvider(_waveIn);
                _sampleChannel = new SampleChannel(_waveProvider);

                if (LevelChanged != null)
                {
                    _sampleChannel.PreVolumeMeter += SampleChannelPreVolumeMeter;
                }
                _waveIn.StartRecording();
            }
        }
Esempio n. 30
0
        private void RefreshAudioDevices()
        {
            inputDeviceComboBox.SelectedIndex = 0;

            while (inputDeviceComboBox.Items.Count > 2)
            {
                inputDeviceComboBox.Items.RemoveAt(inputDeviceComboBox.Items.Count - 1);
            }

            for (int i = 0; i < WaveIn.DeviceCount; i++)
            {
                inputDeviceComboBox.Items.Add(WaveIn.GetCapabilities(i).ProductName);
            }
        }