Bass Playback Device.
Inheritance: IDisposable
示例#1
0
        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);
                }
            };
        }
示例#2
0
 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);
 }
示例#3
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);
            }
        }
示例#5
0
        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);
        }
示例#6
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);
        }
示例#7
0
 /// <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);
 }
示例#8
0
 /// <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);
 }