public static void SelectDevice(bool overrideSettings = false) { int i = 0; if (Program.Settings.DeviceInfo.IsEmpty() || DirectSoundOut.Devices.FirstOrDefault(f => f.Description == Program.Settings.DeviceInfo) == null || overrideSettings) { foreach (DirectSoundDeviceInfo dso in DirectSoundOut.Devices) { Console.WriteLine($"({i++}) {dso.Description} {( $"- {dso.Guid}" ),25} "); } Console.WriteLine($"{i} devices available\r\n"); Console.Write($"Please select a number between 0 and {i - 1}[0]> "); int.TryParse(Console.ReadLine( ), out int devi); devi = devi > i || devi < 0 ? 0 : devi; SelectedDevice = DirectSoundOut.Devices.ToArray( )[devi]; Program.Settings.DeviceInfo = SelectedDevice.Description; Program.Settings.Save( ); } else { SelectedDevice = DirectSoundOut.Devices.First(f => f.Description == Program.Settings.DeviceInfo); } Console.WriteLine($"Selected device is now \"{SelectedDevice.Description}\""); }
private void CbxSweepDeviceOne_SelectionChanged(object sender, SelectionChangedEventArgs e) { DirectSoundDeviceInfo ds = cbxSweepDeviceOne.SelectedItem as DirectSoundDeviceInfo; PlayerModel.DirectSoundOutDeviceOne = (Guid)cbxSweepDeviceOne.SelectedValue; LogHelper.WriteInfoLog("选择的声卡一:" + ds.ModuleName + "||" + ds.Description + "||" + ds.Guid); }
public FunstimDeviceSelector(List <DirectSoundDeviceInfo> devices) { Devices = devices; SelectedDevice = Devices.FirstOrDefault(); InitializeComponent(); }
private void audioRenderComboBox_SelectedValueChanged(object sender, EventArgs e) { var selectedItem = audioRenderComboBox.SelectedItem; if (selectedItem != null) { currentDirectSoundDeviceInfo = selectedItem as DirectSoundDeviceInfo; } }
public void SetDevice(DirectSoundDeviceInfo device, EstimParameters parameters) { if (_device != null) { _device.Dispose(); OnDeviceRemoved(_device); } _device = new EStimAudioDevice(device, parameters); OnDeviceFound(_device); }
private void CbDeviceList_SelectionChanged(object sender, SelectionChangedEventArgs e) { DirectSoundDeviceInfo selectedItem = cbDeviceList.SelectedItem as DirectSoundDeviceInfo; if (selectedItem.Guid != selectedDevice) { selectedDevice = selectedItem.Guid; lSelectedDevice.Content = $"Selected Device: {selectedDevice.ToString()}"; Properties.Settings.Default.LastOutputDevice = selectedDevice; Properties.Settings.Default.Save(); } }
public EStimAudioDevice(DirectSoundDeviceInfo device, EstimParameters parameters) { Name = device.Description; _parameters = parameters; _generator = new SineWaveProvider(); _generator.Frequency = 600; _stereo = new MonoToStereoSampleProvider(_generator); _stereo.LeftVolume = 0f; _stereo.RightVolume = 0f; _soundOut = new DirectSoundOut(device.Guid); _soundOut.Init(_stereo); _soundOut.Play(); MinDelayBetweenCommands = TimeSpan.Zero; }
public FunstimAudioDevice(DirectSoundDeviceInfo device, FunstimParameters parameters) { Name = "Funstim - " + device.Description; _soundOut = new DirectSoundOut(device.Guid); try { List <int> frequencies = Array.ConvertAll(parameters.Frequencies.Split(','), int.Parse).Where(x => x != 0).ToList(); _provider = new FunstimSampleProvider(frequencies, (int)parameters.FadeMs.TotalMilliseconds, (int)parameters.RampPercent, parameters.FadeOnPause); _soundOut.Init(_provider); _soundOut.Play(); MinDelayBetweenCommands = TimeSpan.Zero; } catch (FormatException) { } }
public DirectSoundWaveOutDevice(DirectSoundDeviceInfo deviceInfo) { _device = deviceInfo; _sources = InitSources(deviceInfo); }
public DirectSoundDevice(DirectSoundDeviceInfo info) { this.info = info; Player = new WavePlayerConverter(new DirectSoundOut(info.Guid)); }
/// <summary> /// constructor /// </summary> /// <param name="deviceGuid"></param> public DirectSoundDevice(DirectSoundDeviceInfo deviceInfo) { this.Info = deviceInfo; }
public DeviceModel(DirectSoundDeviceInfo device) { DirectSoundDeviceInfo = device; Provider = DeviceProvider.DirectSound; }
public AudioDevice(DirectSoundDeviceInfo deviceInfo, string name) { this.DeviceInfo = deviceInfo; this.Name = name; }
public AudioDevice(DirectSoundDeviceInfo deviceInfo, string name) { DeviceInfo = deviceInfo; Name = name; }
public OutputDeviceModel(DirectSoundDeviceInfo device) : base(device) { }
public override IWavePlayer DeviceFactory() { DirectSoundDeviceInfo device = _GetDevice(m_Options.SoundCard); return(new DirectSoundOut(device.Guid, m_Options.DacLatency)); }
public DSDevice(DirectSoundDeviceInfo device) { this.device = device; }
private IEnumerable <IWaveOutSource> InitSources(DirectSoundDeviceInfo deviceInfo) { yield return(new DirectSoundWaveOutSource(this, deviceInfo.Guid)); }
public void Setup(AudioEncoderSettings inputPars, NetworkSettings networkPars) { logger.Debug("AudioReceiver::Setup(...)"); try { decoder = new AudioDecoder(); decoder.Open(inputPars); waveFormat = new WaveFormat(8000, 16, 1); var _deviceId = inputPars.DeviceId; Guid deviceId = Guid.Empty; if (!string.IsNullOrEmpty(_deviceId)) { Guid.TryParse(_deviceId, out deviceId); } DirectSoundDeviceInfo deviceInfo = null; var DSDevices = DirectSoundOut.Devices; if (DSDevices != null && DSDevices.Count() > 0) { //DirectSoundOut.DSDEVID_DefaultPlayback deviceInfo = DSDevices.FirstOrDefault(d => d.Guid == deviceId) ?? DSDevices.FirstOrDefault(); } if (deviceId == null) { throw new Exception("Audio device not found..."); } if (deviceInfo != null) { logger.Info(deviceInfo.Description + " " + deviceInfo.ModuleName + " " + deviceInfo.Guid); wavePlayer = new NAudio.Wave.DirectSoundOut(deviceInfo.Guid); //wavePlayer = new NAudio.Wave.WaveOut(); wavePlayer.PlaybackStopped += WavePlayer_PlaybackStopped; waveBuffer = new BufferedWaveProvider(waveFormat) { BufferDuration = TimeSpan.FromMilliseconds(300), //BufferDuration = TimeSpan.FromMilliseconds(300), DiscardOnBufferOverflow = true }; volumeProvider = new VolumeSampleProvider(waveBuffer.ToSampleProvider()); var meteringSampleProvider = new MeteringSampleProvider(volumeProvider); meteringSampleProvider.StreamVolume += PostVolumeMeter_StreamVolume; wavePlayer.Init(meteringSampleProvider); bufferLost = false; } else { throw new Exception("DirectSound devices is not available..."); } session = new PCMUSession(); if (networkPars.TransportMode == TransportMode.Tcp) { rtpReceiver = new RtpTcpReceiver(session); } else { rtpReceiver = new RtpUdpReceiver(session); } session.SSRC = networkPars.SSRC; rtpReceiver.Open(networkPars); rtpReceiver.RtpPacketReceived += RtpReceiver_RtpPacketReceived; } catch (Exception ex) { logger.Debug(ex); CleanUp(); throw; } }