public Loopback(WasapiLoopbackDevice Device, bool IncludeSilence) { this.Device = Device; if (IncludeSilence) { PlaybackDevice playbackDevice = PlaybackDevice.DefaultDevice; foreach (var dev in PlaybackDevice.Devices) { if (dev.DeviceInfo.Driver == Device.DeviceInfo.ID) { playbackDevice = dev; } } SilencePlayer = new Silence(playbackDevice); } Device.Init(); Device.Callback += (b) => { if (DataAvailable != null) { DataAvailable(b); } }; }
public Silence(PlaybackDevice Device) : base(Resolution.Byte) { Handle = Bass.CreateStream(44100, 1, BassFlags.Byte, Procedure, IntPtr.Zero); Bass.ChannelSetDevice(Handle, Device.DeviceIndex); Bass.SetChannelAttribute(Handle, ChannelAttribute.Volume, 0); }
/// <summary> /// Get Device by Index. /// </summary> public static PlaybackDevice GetByIndex(int Device) { if (Singleton.ContainsKey(Device)) return Singleton[Device]; DeviceInfo info; if (!Bass.GetDeviceInfo(Device, out info)) throw new ArgumentOutOfRangeException(nameof(Device), "Invalid PlaybackDevice Index"); var dev = new PlaybackDevice(Device); Singleton.Add(Device, dev); return dev; }
internal static PlaybackDevice Get(int Device) { if (Singleton.ContainsKey(Device)) { return(Singleton[Device]); } else { var Dev = new PlaybackDevice() { DeviceIndex = Device }; Singleton.Add(Device, Dev); return(Dev); } }
public UserStream(UserStreamCallback callback, PlaybackDevice Device, Resolution BufferKind = Resolution.Short, bool IsMono = false) : base(BufferKind) { call = callback; Procedure = new StreamProcedure(Callback); // Stream Flags BassFlags Flags = BufferKind.ToBassFlag(); // Set Mono if (IsMono) { Flags |= BassFlags.Mono; } Handle = Bass.CreateStream(44100, 2, Flags, Procedure, IntPtr.Zero); Bass.ChannelSetDevice(Handle, Device.DeviceIndex); }
/// <summary> /// Get Device by Index. /// </summary> public static PlaybackDevice GetByIndex(int Device) { if (Singleton.ContainsKey(Device)) { return(Singleton[Device]); } DeviceInfo info; if (!Bass.GetDeviceInfo(Device, out info)) { throw new ArgumentOutOfRangeException(nameof(Device), "Invalid PlaybackDevice Index"); } var dev = new PlaybackDevice(Device); Singleton.Add(Device, dev); return(dev); }
/// <summary> /// Creates a new instance of <see cref="Silence"/>. /// </summary> /// <param name="Device">The <see cref="PlaybackDevice"/> to use.</param> public Silence(PlaybackDevice Device) { _handle = Bass.CreateStream(44100, 1, BassFlags.Byte, (h, b, l, u) => l, IntPtr.Zero); Bass.ChannelSetDevice(_handle, Device.Index); Bass.ChannelSetAttribute(_handle, ChannelAttribute.Volume, 0); }