private void Form1_Load(object sender, EventArgs e) { notifyIcon1.Visible = false; MMDeviceEnumerator enumerator = new MMDeviceEnumerator(); MMDeviceCollection devices = enumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active); sel_device.Items.AddRange(devices.ToArray()); bool configOk = config.ReadConfig(); sel_fft.SelectedItem = config.fftLen.ToString(); num_cols.Value = config.cols; num_rows.Value = config.rows; sel_serial.SelectedIndex = config.com_port; sel_device.SelectedIndex = config.deviceIdx; serial_buffer = new byte[config.cols]; if (configOk) { _serialPort = new SerialPort(sel_serial.SelectedItem.ToString(), 19200, Parity.None, 8, StopBits.One); } device = devices[config.deviceIdx]; picH = pictureBox1.Height; picW = pictureBox1.Width; bitmap = new Bitmap(picW, picH); }
private void Audio_Load(object sender, EventArgs e) { capture.DataAvailable += waveIn_DataAvailable; targetPanel = panelFrom; MMDeviceEnumerator enumerator = new MMDeviceEnumerator(); MMDeviceCollection audioDevices = enumerator.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active); devices.Items.AddRange(audioDevices.ToArray()); devices.SelectedItem = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia); targetDevice = devices.SelectedItem as MMDevice; chart1.ChartAreas[0].AxisX.Minimum = 0; chart1.ChartAreas[0].AxisX.Maximum = Mathf.Clamp(1 / multiplier, 0.1f, 1); chart1.ChartAreas[0].AxisY.Minimum = 0; chart1.ChartAreas[0].AxisY.Maximum = 1; chart1.ChartAreas[0].AxisX.LabelStyle.ForeColor = Color.Black; chart1.ChartAreas[0].AxisY.LabelStyle.ForeColor = Color.Black; chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false; chart1.ChartAreas[0].AxisX.MinorGrid.Enabled = false; chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false; chart1.ChartAreas[0].AxisY.MinorGrid.Enabled = false; chart1.ChartAreas[0].AxisX.MajorTickMark.Enabled = false; chart1.ChartAreas[0].AxisY.MajorTickMark.Enabled = false; chart1.ChartAreas[0].AxisX.MinorTickMark.Enabled = false; chart1.ChartAreas[0].AxisY.MinorTickMark.Enabled = false; chart1.ChartAreas[0].AxisX.LabelStyle.Interval = 0.2; chart1.ChartAreas[0].AxisY.LabelStyle.Interval = 0.2; chart1.ChartAreas[0].BackColor = Color.White; chart1.Series[0].Color = Color.Black; chart1.Series[0]["PieLabelStyle"] = "Disabled"; }
public static MMDevice[] GetActiveDevices() { UpdateDevices(); try { return(deviceCol.ToArray()); } catch (ArgumentNullException) { XtraMessageBox.Show("We cannot find any devices at your computer.", "Device error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } }
private void Form1_Load(object sender, EventArgs e) { MMDeviceEnumerator enumerator = new MMDeviceEnumerator(); MMDeviceCollection devices = enumerator.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active); comboBox1.Items.AddRange(devices.ToArray()); textBox1.Text = 0 + ""; textBox2.Text = 1 + ""; textBox3.Text = 0 + ""; textBox4.Text = 0 + ""; textBox5.Text = 1000 + ""; open = Image.FromFile("open.png"); closed = Image.FromFile("closed.png"); pictureBox1.Image = closed; timer1.Start(); }
private void Form1_Load(object sender, EventArgs e) { xAudio2 = new XAudio2(); xAudio2.StartEngine(); masteringVoice = new MasteringVoice(xAudio2); textBox2.Text = "Nagrywanie wylaczone"; MMDeviceEnumerator enumerator = new MMDeviceEnumerator(); MMDeviceCollection audioDevices = enumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active); comboBox2.Items.AddRange(audioDevices.ToArray()); comboBox3.Items.Add("Bez"); comboBox3.Items.Add("Echo"); comboBox3.Items.Add("Reverb"); comboBox3.SelectedIndex = 0; }
private void frmMain_Load(object sender, EventArgs e) { MMDeviceEnumerator enumerator = new MMDeviceEnumerator(); defaultDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Multimedia); devices = enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active); cmbWasapiDevices.Items.AddRange(devices.ToArray()); if (cmbWasapiDevices.Items.Count > 0) { cmbWasapiDevices.SelectedIndex = 0; } else { MessageBox.Show("Не обнаружено ни одного устройства для записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } totalRecodrTime = 0; sectionRecordTime = 0; lblTime.Text = ""; tsslDirPath.Text = ""; tsslDirPath.Visible = false; cmbCutTimeVariant.SelectedIndex = 0; cmbTypeFile.SelectedIndex = 0; // Параметры приложения if (Properties.Settings.Default.p_device == 0) { rbnInputDefault.Checked = true; } else if (Properties.Settings.Default.p_device > 0 && Properties.Settings.Default.p_device <= cmbWasapiDevices.Items.Count) { rbnInputSelect.Checked = true; cmbWasapiDevices.SelectedIndex = Properties.Settings.Default.p_device - 1; } switch (Properties.Settings.Default.p_cut_type) { case "timer": rbnCutTimer.Checked = true; break; case "clock": rbnCutClock.Checked = true; break; default: rbnNoCut.Checked = true; break; } if (Properties.Settings.Default.p_cut_timer >= 5) { nudCutTime.Value = Properties.Settings.Default.p_cut_timer; } if (Properties.Settings.Default.p_cut_clock >= 0 && Properties.Settings.Default.p_cut_clock < cmbCutTimeVariant.Items.Count) { cmbCutTimeVariant.SelectedIndex = Properties.Settings.Default.p_cut_clock; } if (Directory.Exists(Properties.Settings.Default.p_dir)) { pathToFolderForRecodreFiles = Properties.Settings.Default.p_dir; btnRecord.Enabled = true; tsslDirPath.Text = pathToFolderForRecodreFiles; tsslDirPath.Visible = true; } if (Properties.Settings.Default.p_save == 0) { rbnSaveFiles.Checked = true; } if (Properties.Settings.Default.p_save == 1) { rbnSaveFolderFiles.Checked = true; } // Аргументы коммандной строки String[] arguments = Environment.GetCommandLineArgs(); bool autoStart = false; for (int i = 1; i < arguments.Length; i++) { switch (arguments[i]) { case "--device": if (i + 1 < arguments.Length) { i += 1; int num = Int32.Parse(arguments[i]); if (num == 0) { rbnInputDefault.Checked = true; } else { if (num > 0 && num <= cmbWasapiDevices.Items.Count) { rbnInputSelect.Checked = true; cmbWasapiDevices.SelectedIndex = num - 1; } } } break; case "--save-type-file": rbnSaveFiles.Checked = true; break; case "--save-type-folder-file": rbnSaveFolderFiles.Checked = true; break; case "--cut-type": if (i + 1 < arguments.Length) { i += 1; switch (arguments[i]) { case "no": rbnNoCut.Checked = true; break; case "timer": if (i + 1 < arguments.Length) { i += 1; int num = Int32.Parse(arguments[i]); if (num >= 5) { rbnCutTimer.Checked = true; nudCutTime.Value = num; } } break; case "clock": if (i + 1 < arguments.Length) { i += 1; int num = Int32.Parse(arguments[i]); if (num > 0 && num <= cmbCutTimeVariant.Items.Count) { cmbCutTimeVariant.SelectedIndex = num - 1; rbnCutClock.Checked = true; } } break; default: rbnNoCut.Checked = true; break; } } break; case "--dir": if (i + 1 < arguments.Length) { i += 1; if (Directory.Exists(arguments[i])) { pathToFolderForRecodreFiles = arguments[i]; btnRecord.Enabled = true; tsslDirPath.Text = pathToFolderForRecodreFiles; tsslDirPath.Visible = true; } } break; case "--record": autoStart = true; break; case "--title": if (i + 1 < arguments.Length) { i += 1; this.Text = arguments[i]; } break; } } if (autoStart && btnRecord.Enabled) { btnRecord_Click(sender, e); } }