/// <summary> /// Checks whether the given device exists, is available or not. /// </summary> /// <param name="device">Device to be checked.</param> public bool DeviceExists(IAudioDevice device) { if (device == null) { return(false); } MMDeviceCollection mmDeviceCollection; if (device is WaveOutDevice) { mmDeviceCollection = _enumerator.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active); } else if (device is WaveInDevice) { mmDeviceCollection = _enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active); } else { return(false); } foreach (var mmDevice in mmDeviceCollection) { if (device.FriendlyName.StartsWith(mmDevice.FriendlyName)) { return(true); } } return(false); }
/// <summary> /// Registers the device with the service so it's aware /// of events and they're handled properly. /// </summary> /// <param name="device"></param> private void RegisterDevice(IAudioDevice device) { if (_devices.ContainsKey(device.Id)) { device.Dispose(); return; } _devices.Add(device.Id, device); device.DeviceDefaultChanged += OnDefaultDeviceChanged; device.DeviceVolumeChanged += OnDeviceVolumeChanged; var sessionManager = AudioSessionManager2.FromMMDevice(device.Device); sessionManager.SessionCreated += OnSessionCreated; _sessionManagers.Add(device.Id, sessionManager); RaiseDeviceCreated(device.Id, device.DisplayName, device.Volume, device.IsMuted); foreach (var session in sessionManager.GetSessionEnumerator()) { if (ValidateSession(session)) { OnSessionCreated(session); } } }
private void RefreshRecordingDevices() { if (InvokeRequired) { BeginInvoke(new EmptyDelegate(RefreshRecordingDevices)); return; } if (_recordingDevice != null) { _recordingDevice.VolumeChanged -= RecordingDevice_VolumeChanged; _recordingDevice.MuteChanged -= RecordingDevice_MuteChanged; } if (_core.Audio.RecordingDevice != null) { _recordingDevice = _core.Audio.RecordingDevice; _recordingDevice.VolumeChanged += RecordingDevice_VolumeChanged; _recordingDevice.MuteChanged += RecordingDevice_MuteChanged; sldMic.Value = _recordingDevice.Volume; sldMic.Enabled = true; btnMute.Enabled = true; btnMute.Checked = _core.Audio.RecordingDevice.Mute; } else { _recordingDevice = null; sldMic.Enabled = false; btnMute.Enabled = false; } }
public void NotifyDefaultChanged(IAudioDevice audioDevice) { var toastData = new BannerData { Image = AudioDeviceIconExtractor.ExtractIconFromAudioDevice(audioDevice, true).ToBitmap(), Text = audioDevice.FriendlyName }; if (Configuration.CustomSound != null && File.Exists(Configuration.CustomSound.FilePath)) { toastData.SoundFilePath = Configuration.CustomSound.FilePath; } switch (audioDevice.Type) { case AudioDeviceType.Playback: toastData.Title = SettingsStrings.tooltipOnHoverOptionPlaybackDevice; break; case AudioDeviceType.Recording: toastData.Title = SettingsStrings.tooltipOnHoverOptionRecordingDevice; break; default: throw new ArgumentOutOfRangeException(nameof(audioDevice.Type), audioDevice.Type, null); } new BannerManager().ShowNotification(toastData); }
/// <summary> /// Registers the device with the service so it's aware /// of events and they're handled properly. /// </summary> /// <param name="device"></param> private void RegisterDevice(IAudioDevice device) { m_Logger.Debug(string.Join("\t", nameof(RegisterDevice), device.DeviceId, device.DisplayName, device.Device.DataFlow)); if (_devices.ContainsKey(device.Id)) { device.Dispose(); return; } _devices.Add(device.Id, device); device.DeviceDefaultChanged += OnDefaultDeviceChanged; device.DeviceVolumeChanged += OnDeviceVolumeChanged; device.DeviceRemoved += OnDeviceRemoved; RaiseDeviceCreated(device.Id, device.DisplayName, device.Volume, device.IsMuted, device.Flow); if (device.Flow == DeviceFlow.Output) { var sessionManager = device.Device.AudioSessionManager; sessionManager.OnSessionCreated += OnSessionCreated; _sessionManagers.Add(device.Id, sessionManager); var sessions = sessionManager.Sessions; for (int i = 0; i < sessions.Count; i++) { OnSessionCreated(sessions[i]); } } }
public void Remove(IAudioDevice device) { if (_devices.TryRemove(device.Id, out var foundDevice)) { CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, foundDevice)); } }
/// <summary> /// Registers the device with the service so it's aware /// of events and they're handled properly. /// </summary> /// <param name="device"></param> private void RegisterDevice(IAudioDevice device) { AppLogging.DebugLog(nameof(RegisterDevice), device.DeviceId, device.DisplayName, device.Device.DataFlow.ToString()); if (_devices.ContainsKey(device.Id)) { device.Dispose(); return; } _devices.Add(device.Id, device); device.DeviceDefaultChanged += OnDefaultDeviceChanged; device.DeviceVolumeChanged += OnDeviceVolumeChanged; device.DeviceRemoved += OnDeviceRemoved; RaiseDeviceCreated(device.Id, device.DisplayName, device.Volume, device.IsMuted, device.Flow); if (device.Flow == DeviceFlow.Output) { var sessionManager = AudioSessionManager2.FromMMDevice(device.Device); sessionManager.SessionCreated += OnSessionCreated; _sessionManagers.Add(device.Id, sessionManager); foreach (var session in sessionManager.GetSessionEnumerator()) { OnSessionCreated(session); } } }
void InitializeDevices(bool wait = false) { var recordingDevice = GetDeviceByName(Core.SettingsManager.GetValueOrSetDefault <string>("RecordingDevice", _internalAudio.DefaultRecordingDevice != null ? _internalAudio.DefaultRecordingDevice.Name : String.Empty)); var playbackDevice = GetDeviceByName(Core.SettingsManager.GetValueOrSetDefault <string>("PlaybackDevice", _internalAudio.DefaultPlaybackDevice != null ? _internalAudio.DefaultPlaybackDevice.Name : String.Empty)); if (recordingDevice == null || playbackDevice == null) { if (wait && _initWaitHandle.WaitOne(TimeSpan.FromSeconds(5))) { InitializeDevices(); } return; } PlaybackDevice = playbackDevice; RecordingDevice = recordingDevice; _initWaitHandle.Set(); if (RecordingDevice != null) { RecordingDevice.Volume = Core.SettingsManager.GetValueOrSetDefault("RecordingDeviceVolume", 50); } if (PlaybackDevice != null) { PlaybackDevice.Volume = Core.SettingsManager.GetValueOrSetDefault("PlaybackDeviceVolume", 50); } }
public static string DumpAudioDevice(IAudioDevice audioDevice) { AudioDevice device = audioDevice as AudioDevice; if (device == null) { return("Device is not supported\r\n"); } return(String.Format(@" Device: {0} DeviceId: {1} Playback: {2} Recording: {3} DefaultLine: --- {4} --- Handle: {5} Lines: +++ {6} +++ ", device.Name, device.DeviceId, device.PlaybackSupport, device.RecordingSupport, DumpAudioLine(device.DefaultLine), device.Handle, DumpCollection <AudioLine>(device.Lines, new DumpDelegate <AudioLine>(DumpAudioLine)))); }
public void NotifyDefaultChanged(IAudioDevice audioDevice) { var toastData = new ToastData { ImagePath = "file:///" + ApplicationPath.DefaultImagePath, Title = audioDevice.FriendlyName }; if (Configuration.CustomSound != null && File.Exists(Configuration.CustomSound.FilePath)) { toastData.Silent = false; toastData.SoundFilePath = Configuration.CustomSound.FilePath; } switch (audioDevice.Type) { case AudioDeviceType.Playback: toastData.Line0 = SettingsStrings.tooltipOnHoverOptionPlaybackDevice; break; case AudioDeviceType.Recording: toastData.Line0 = SettingsStrings.tooltipOnHoverOptionRecordingDevice; break; default: throw new ArgumentOutOfRangeException(nameof(audioDevice.Type), audioDevice.Type, null); } new ToastManager().ShowNotification(toastData); }
/// <summary> /// Initializes a new instance of the <see cref="AudioRecorder" /> class. /// </summary> /// <param name="deviceId">The device.</param> /// <param name="logger">The logger.</param> public AudioRecorder(IAudioDevice device, ILogger <AudioRecorder> logger) { device.IdChanged += (_, __) => this.OnCaptureDeviceChanged(); this.Device = device; this.Logger = logger; }
public void LauncherFinalize( IWindow window, IGraphicsDevice graphicsDevice, IAudioDevice audioDevice ) { if ( audioDevice != null ) audioDevice.Dispose (); graphicsDevice.Dispose (); window.Dispose (); }
public void NotifyDefaultChanged(IAudioDevice audioDevice) { if (audioDevice.Type != AudioDeviceType.Playback) { return; } var task = new Task(() => { using (var memoryStreamedSound = GetStreamCopy()) { var device = _deviceEnumerator.GetDevice(audioDevice.Id); using (var output = new WasapiOut(device, AudioClientShareMode.Shared, true, 10)) { output.Init(new WaveFileReader(memoryStreamedSound)); output.Play(); while (output.PlaybackState == PlaybackState.Playing) { Thread.Sleep(500); } } } }); task.Start(); }
/// <summary> /// Remove a device from the Set. /// </summary> /// <param name="device"></param> /// <returns> /// true if the element is successfully found and removed; otherwise, false. This method returns false if /// <paramref name="deviceName" /> is not found in the <see cref="T:System.Collections.Generic.HashSet`1" /> object. /// </returns> public bool UnselectDevice(IAudioDevice device) { var result = false; DeviceListChanged eventChanged = null; switch (device.Type) { case AudioDeviceType.Playback: result = SelectedPlaybackDevicesList.Remove(device.FriendlyName); eventChanged = new DeviceListChanged(SelectedPlaybackDevicesList, device.Type); break; case AudioDeviceType.Recording: result = SelectedRecordingDevicesList.Remove(device.FriendlyName); eventChanged = new DeviceListChanged(SelectedRecordingDevicesList, device.Type); break; default: throw new ArgumentOutOfRangeException(); } if (result) { SelectedDeviceChanged?.Invoke(this, eventChanged); AppConfigs.Configuration.Save(); } return(result); }
private void RefreshPlaybackDevices() { if (InvokeRequired) { BeginInvoke(new EmptyDelegate(RefreshPlaybackDevices)); return; } if (_playbackDevice != null) { _playbackDevice.VolumeChanged -= PlaybackDevice_VolumeChanged; } if (_core.Audio.PlaybackDevice != null) { _playbackDevice = _core.Audio.PlaybackDevice; _playbackDevice.VolumeChanged += PlaybackDevice_VolumeChanged; sldVol.Value = _playbackDevice.Volume; sldVol.Enabled = true; } else { _playbackDevice = null; sldVol.Enabled = false; } }
public APU(NES NesEmu, IAudioDevice SoundDevice) { _Nes = NesEmu; //_Control = SoundDevice.SoundDevice; STEREO = SoundDevice.Stereo; InitDirectSound(/*SoundDevice.SoundDevice*/); }
private void playerProc() { int errors = 0; while (!exit) { try { var item = CurrentPlayListItem = selector.SelectNextFile(StreamID); if (item != null && item.File.ID > 0) { PlayFile(item); errors = 0; } else { Thread.Sleep(1000); } continue; } catch (Exception ex) { this.LogError(ex, "Unhandled exception in player proc."); Thread.Sleep(1000); if (++errors > 10) { device?.Dispose(); device = null; } } } }
public AudioDeviceSessionCollection(IAudioDevice parent, IMMDevice device) { Trace.WriteLine($"AudioDeviceSessionCollection Create dev={device.GetId()}"); _parent = new WeakReference <IAudioDevice>(parent); _dispatcher = App.Current.Dispatcher; Task.Factory.StartNew(() => { try { _sessionManager = device.Activate <IAudioSessionManager2>(); _sessionManager.RegisterSessionNotification(this); var enumerator = _sessionManager.GetSessionEnumerator(); int count = enumerator.GetCount(); for (int i = 0; i < count; i++) { CreateAndAddSession(enumerator.GetSession(i)); } } catch (Exception ex) { Trace.TraceError($"{ex}"); } }); }
private void AudioDeviceChanged(IAudioDevice device) { if (!_cancelAudioEvents) { ReloadAudioDevices(); } }
public IAsyncResult BeginSetActiveDevice(IAudioDevice device, AsyncCallback callback) { if (device == null) { throw new ArgumentNullException(); } AsyncNoResult result = new AsyncNoResult(callback); var request = new vx_req_aux_set_render_device_t(); request.render_device_specifier = device.Key; return(_client.BeginIssueRequest(request, ar => { try { _client.EndIssueRequest(ar); // When trying to set the active device to what is already the active device, return. if (_activeDevice.Key == device.Key) { return; } _activeDevice = (AudioDevice)device; if (_activeDevice == AvailableDevices["Default System Device"]) { _effectiveDevice = new AudioDevice { Key = _systemDevice.Key, Name = _systemDevice.Name }; } else if (_activeDevice == AvailableDevices["Default Communication Device"]) { _effectiveDevice = new AudioDevice { Key = _communicationDevice.Key, Name = _communicationDevice.Name }; } else { _effectiveDevice = new AudioDevice { Key = device.Key, Name = device.Name }; } PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(EffectiveDevice))); result.SetComplete(); } catch (Exception e) { VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}"); result.SetComplete(e); } })); }
public Nes(IGraphicsDevice graphicsDevice, IInputDevice inputDevice, IAudioDevice audioDevice) { _graphicsDevice = graphicsDevice; _inputDevice = inputDevice; _audioDevice = audioDevice; Initialization(); }
/// <summary> /// Using the DeviceClassIconPath, get the Icon /// </summary> /// <param name="device"></param> /// <param name="listView"></param> private void AddDeviceIconSmallImage(IAudioDevice device, ListView listView) { if (!listView.SmallImageList.Images.ContainsKey(device.DeviceClassIconPath)) { listView.SmallImageList.Images.Add(device.DeviceClassIconPath, AudioDeviceIconExtractor.ExtractIconFromAudioDevice(device, true)); } }
/// <inheritdoc/> public bool Equals(IAudioDevice other) { if (other is AudioDevice) { return(deviceHandle == ((AudioDevice)other).deviceHandle); } return(false); }
public AudioBuffer( IAudioDevice audioDevice, AudioInfo audioInfo ) { sourceId = AL.GenSource (); this.audioInfo = audioInfo; alFormat = ( ( audioInfo.AudioChannel == 2 ) ? ( ( audioInfo.BitsPerSample == 16 ) ? ALFormat.Stereo16 : ALFormat.Stereo8 ) : ( ( audioInfo.BitsPerSample == 16 ) ? ALFormat.Mono16 : ALFormat.Mono8 ) ); }
/// <summary>Plays the specified device.</summary> /// <param name="device">The device.</param> /// <param name="volume">The volume.</param> public void Play(IAudioDevice device, float volume = 1) { using (var audioOut = device.CreateAudioOut(Config)) { audioOut.Volume = volume; Play(audioOut); } }
public void LauncherInitialize( out IWindow window, out IGraphicsDevice graphicsDevice, out IAudioDevice audioDevice ) { window = new Window ( frame ); graphicsDevice = new GraphicsDevice ( window ); audioDevice = new AudioDevice ( window ); IsInitialized = true; }
private void MicrophonPlayBtn_Click(object sender, RoutedEventArgs e) { MicrophonPlayBtn.Visibility = Visibility.Hidden; MicrophonCloseBtn.Visibility = Visibility.Visible; _debugAudioDevice = _settingsViewModel.AduioDeviceList.First(item => item.ID == _settingsViewModel.DebugAduioDevice.ID); _debugAudioDevice.PushingData += AudioDevice_PushingData; }
public override void ProcessAudio(IAudioDevice audioPlayer) { if (trgAppleConsumeSound.TryHandle()) { audioPlayer.Beep(); trgAppleConsumeSound = ManualSetTrigger.NotReady; } }
/// <summary> /// /// </summary> /// <param name="device"></param> /// <returns></returns> public static int GetID(IAudioDevice device) { if (device == null) { return(-1); } return(Devices.IndexOf(device)); }
private static DataModel.Audio.Mocks.AudioDeviceSession MakeMockApp(IAudioDevice mockDevice, string displayName, string appId, string iconPath) { return(new DataModel.Audio.Mocks.AudioDeviceSession( mockDevice, Guid.NewGuid().ToString(), displayName, appId, Environment.ExpandEnvironmentVariables(iconPath))); }
private void OnDevicePropertyChanged(IAudioDevice device, string propertyName) { if (propertyName == nameof(device.Volume) || propertyName == nameof(device.IsMuted)) { // Trace.WriteLine($"{device.DisplayName}: {device.Volume} {device.IsMuted}"); TriggerOSDForDevice(device.Id); } }
/// <summary> /// 31 is the max length of sound device name in PjSIP /// </summary> /// <param name="device">Device</param> /// <returns></returns> string GetPjSipDeviceName(IAudioDevice device) { if (device.Name.Length > 31) { return(device.Name.Substring(0, 31)); } return(device.Name); }
public bool SetAudioDevice(IAudioDevice audioDevice) { if (_useAudioDevice == audioDevice) { return(true); } _useAudioDevice = audioDevice; return(_aacEncoder.SetAudioDataSource(_useAudioDevice)); }
public void LauncherFinalize( IWindow window, IGraphicsDevice graphicsDevice, IAudioDevice audioDevice ) { if ( updateThread != null ) updateThread.Abort (); updateThread = null; if ( audioDevice != null ) audioDevice.Dispose (); graphicsDevice.Dispose (); window.Dispose (); }
public void LauncherInitialize( out IWindow window, out IGraphicsDevice graphicsDevice, out IAudioDevice audioDevice ) { window = new Window ( context ); graphicsDevice = new GraphicsDevice ( window ); audioDevice = new AudioDevice ( window ); ( context as Android.App.Activity ).SetContentView ( window.Handle as Android.Views.View ); IsInitialized = true; }
public DeviceViewModel(IAudioDeviceProvider provider, IAudioDevice device) { if (provider == null) throw new ArgumentNullException ("provider"); if (device == null) throw new ArgumentNullException ("device"); this.provider = provider; this.device = device; }
public Audio( IAudioDevice audioDevice, AudioInfo audioInfo ) { this.audioDevice = new WeakReference ( audioDevice ); this.audioInfo = audioInfo; bufferIds = new List<int> (); sourceId = AL.GenSource (); alFormat = ( ( audioInfo.AudioChannel == AudioChannel.Stereo ) ? ( ( audioInfo.BitPerSample == 2 ) ? ALFormat.Stereo16 : ALFormat.Stereo8 ) : ( ( audioInfo.BitPerSample == 2 ) ? ALFormat.Mono16 : ALFormat.Mono8 ) ); ( audioDevice as AudioDevice ).audioList.Add ( this ); }
/// <summary> /// /// </summary> /// <param name="data"></param> /// <param name="device"></param> public static void DeserializeBank(byte[] data, IAudioDevice device) { var programs = DeserializeBank(data); var max = device.DeviceInfo.ProgramCount; for(int i=0; i<programs.Length; i++) { if (i >= max) // safety, don't overfill the device break; device.SetProgramData(programs[i], i); } }
public AudioBuffer( IAudioDevice audioDevice, AudioInfo audioInfo ) { this.audioInfo = audioInfo; SharpDX.DirectSound.SoundBufferDescription bufferDesc = new SharpDX.DirectSound.SoundBufferDescription () { Flags = SharpDX.DirectSound.BufferFlags.ControlVolume | SharpDX.DirectSound.BufferFlags.ControlPan | SharpDX.DirectSound.BufferFlags.ControlPositionNotify | SharpDX.DirectSound.BufferFlags.StickyFocus | SharpDX.DirectSound.BufferFlags.Software | SharpDX.DirectSound.BufferFlags.GetCurrentPosition2 | SharpDX.DirectSound.BufferFlags.ControlFrequency | SharpDX.DirectSound.BufferFlags.GlobalFocus, Format = new SharpDX.Multimedia.WaveFormat ( audioInfo.SampleRate, audioInfo.BitsPerSample, audioInfo.AudioChannel ), BufferBytes = audioInfo.SampleRate }; soundBuffer = new SharpDX.DirectSound.SecondarySoundBuffer ( audioDevice.Handle as SharpDX.DirectSound.DirectSound, bufferDesc ); }
public void NotifyDefaultChanged(IAudioDevice audioDevice) { switch (audioDevice.Type) { case AudioDeviceType.Playback: _notifyIcon.ShowBalloonTip(500, string.Format(TrayIconStrings.playbackChanged, Application.ProductName), audioDevice.FriendlyName, ToolTipIcon.Info); break; case AudioDeviceType.Recording: _notifyIcon.ShowBalloonTip(500, string.Format(TrayIconStrings.recordingChanged, Application.ProductName), audioDevice.FriendlyName, ToolTipIcon.Info); break; default: throw new ArgumentOutOfRangeException(nameof(audioDevice.Type), audioDevice.Type, null); } }
public void NotifyDefaultChanged(IAudioDevice audioDevice) { if (audioDevice.Type != AudioDeviceType.Playback) return; var task = new Task(() => { var device = _deviceEnumerator.GetDevice(audioDevice.Id); using (var output = new WasapiOut(device, AudioClientShareMode.Shared, true, 10)) { output.Init(new WaveFileReader(Resources.NotificationSound)); output.Play(); while (output.PlaybackState == PlaybackState.Playing) { Thread.Sleep(500); } } }); task.Start(); }
/// <summary> /// Extract the Icon out of an AudioDevice /// </summary> /// <param name="audioDevice"></param> /// <param name="largeIcon"></param> /// <returns></returns> public static Icon ExtractIconFromAudioDevice(IAudioDevice audioDevice, bool largeIcon) { Icon ico; if (IconCache.TryGetValue(audioDevice.DeviceClassIconPath, out ico)) { return ico; } try { if (audioDevice.DeviceClassIconPath.EndsWith(".ico")) { ico = Icon.ExtractAssociatedIcon(audioDevice.DeviceClassIconPath); } else { var iconInfo = audioDevice.DeviceClassIconPath.Split(','); var dllPath = iconInfo[0]; var iconIndex = int.Parse(iconInfo[1]); ico = IconExtractor.Extract(dllPath, iconIndex, largeIcon); } } catch (Exception e) { AppLogger.Log.Error($"Can't extract icon from {audioDevice.DeviceClassIconPath}\n Ex: ", e); switch (audioDevice.Type) { case AudioDeviceType.Playback: ico = Resources.defaultSpeakers; break; case AudioDeviceType.Recording: ico = Resources.defaultMicrophone; break; default: throw new ArgumentOutOfRangeException(); } } IconCache.Add(audioDevice.DeviceClassIconPath, ico); return ico; }
public Audio( IAudioDevice audioDevice, AudioInfo audioInfo ) { this.audioDevice = new WeakReference ( audioDevice ); this.audioInfo = audioInfo; SharpDX.DirectSound.SoundBufferDescription bufferDesc = new SharpDX.DirectSound.SoundBufferDescription () { Flags = SharpDX.DirectSound.BufferFlags.ControlVolume | SharpDX.DirectSound.BufferFlags.ControlPan | SharpDX.DirectSound.BufferFlags.ControlPositionNotify | SharpDX.DirectSound.BufferFlags.StickyFocus | SharpDX.DirectSound.BufferFlags.Software | SharpDX.DirectSound.BufferFlags.GetCurrentPosition2 | SharpDX.DirectSound.BufferFlags.ControlFrequency, Format = new SharpDX.Multimedia.WaveFormat ( audioInfo.SampleRate, audioInfo.BitPerSample * 8, ( int ) audioInfo.AudioChannel ), BufferBytes = totalLength = ( int ) ( audioInfo.Duration.TotalSeconds * ( ( int ) audioInfo.AudioChannel * audioInfo.BitPerSample * audioInfo.SampleRate ) ), }; soundBuffer = new SharpDX.DirectSound.SecondarySoundBuffer ( audioDevice.Handle as SharpDX.DirectSound.DirectSound, bufferDesc ); ( audioDevice as AudioDevice ).audioList.Add ( this ); offset = 0; }
public ToolStripDeviceItem(EventHandler onClick, IAudioDevice audioDevice) : base(audioDevice.FriendlyName, audioDevice.IsDefault(Role.Console) ? Resources.Check : null, onClick) { AudioDevice = audioDevice; }
/// <summary> /// /// </summary> /// <param name="device"></param> /// <returns></returns> public static int GetID(IAudioDevice device) { if (device == null) return -1; return Devices.IndexOf(device); }
/// <summary> /// Opens the provider with <paramref name="device"/>. /// </summary> /// <param name="device">The device to play audio on.</param> /// <exception cref="ArgumentNullException"><paramref name="device"/> is <c>null</c>.</exception> public static void Open(this IAudioPlaybackProvider self, IAudioDevice device) { if (self == null) throw new ArgumentNullException ("self"); if (device == null) throw new ArgumentNullException ("device"); self.Device = device; self.Open(); }
/// <summary> /// Attempts to set active device to the specified name /// </summary> /// <param name="device"></param> public bool SetActiveDevice(IAudioDevice device) { using (AppLogger.Log.InfoCall()) { try { AppLogger.Log.Info("Set Default device", device); device.SetAsDefault(Role.Console); if (SetCommunications) { AppLogger.Log.Info("Set Default Communication device", device); device.SetAsDefault(Role.Communications); } switch (device.Type) { case AudioDeviceType.Playback: AppConfigs.Configuration.LastPlaybackActive = device.FriendlyName; break; case AudioDeviceType.Recording: AppConfigs.Configuration.LastRecordingActive = device.FriendlyName; break; default: throw new ArgumentOutOfRangeException(); } AppConfigs.Configuration.Save(); return true; } catch (Exception ex) { ErrorTriggered?.Invoke(this, new ExceptionEvent(ex)); } return false; } }
public void NotifyDefaultChanged(IAudioDevice audioDevice) { }
/// <summary> /// Attempts to set active device to the specified name /// </summary> /// <param name="device"></param> public bool SetActiveDevice(IAudioDevice device) { using (AppLogger.Log.InfoCall()) { try { return _deviceCyclerManager.SetAsDefault(device); } catch (Exception ex) { ErrorTriggered?.Invoke(this, new ExceptionEvent(ex)); } return false; } }
public static void SetAudioDevice( IAudioDevice audioDevice ) { AudioDevice = audioDevice; }
public void SetupOutput(IGraphicDevice videoDevice, IAudioDevice audioDevice) { Ppu.OutputDevice = videoDevice; Apu = new Apu(this, audioDevice); }
/// <summary> /// Using the information of the AudioDeviceWrapper, generate a ListViewItem /// </summary> /// <param name="device"></param> /// <param name="selected"></param> /// <param name="listView"></param> /// <returns></returns> private ListViewItem GenerateListViewItem(IAudioDevice device, ICollection<string> selected, ListView listView) { var listViewItem = new ListViewItem { Text = device.FriendlyName, ImageKey = device.DeviceClassIconPath, Tag = device }; if (selected.Contains(device.FriendlyName)) { listViewItem.Checked = true; listViewItem.Group = listView.Groups["selectedGroup"]; } else { listViewItem.Checked = false; listViewItem.Group = GetGroup(device.DeviceState, listView); } return listViewItem; }
public Apu(NesEngine NesEmu, IAudioDevice SoundDevice) { _engine = NesEmu; STEREO = SoundDevice.Stereo; InitDirectSound(SoundDevice.SoundDevice); }
/// <summary> /// /// </summary> /// <param name="device"></param> /// <returns></returns> public static byte[] SerializeBank(IAudioDevice device) { var programs = new Program[device.DeviceInfo.ProgramCount]; for (int i = 0; i < programs.Length; i++) programs[i] = device.GetProgramData(i); return SerializeBank(programs); }
/// <summary> /// /// </summary> /// <param name="device"></param> /// <param name="e"></param> public static void LogDeviceException(IAudioDevice device, Exception e) { LogDeviceException(Interop.GetID(device), e); }
/// <summary> /// Remove a device from the Set. /// </summary> /// <param name="device"></param> /// <returns> /// true if the element is successfully found and removed; otherwise, false. This method returns false if /// <paramref name="deviceName" /> is not found in the <see cref="T:System.Collections.Generic.HashSet`1" /> object. /// </returns> public bool UnselectDevice(IAudioDevice device) { var result = false; DeviceListChanged eventChanged = null; switch (device.Type) { case AudioDeviceType.Playback: result = SelectedPlaybackDevicesList.Remove(device.FriendlyName); eventChanged = new DeviceListChanged(SelectedPlaybackDevicesList, device.Type); break; case AudioDeviceType.Recording: result = SelectedRecordingDevicesList.Remove(device.FriendlyName); eventChanged = new DeviceListChanged(SelectedRecordingDevicesList, device.Type); break; default: throw new ArgumentOutOfRangeException(); } if (result) { SelectedDeviceChanged?.Invoke(this, eventChanged); AppConfigs.Configuration.Save(); } return result; }