Esempio n. 1
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);
 }
Esempio n. 2
0
        public void LoadFile(string soundPath)
        {
            if (string.IsNullOrEmpty(soundPath) || !File.Exists(soundPath))
            {
                FreeStream();
                return;
            }

            // Free Stream
            FreeStream();

            // File Stream
            var fileMemory = File.ReadAllBytes(soundPath);

            // _handle = Bass.CreateStream(soundfile, 0, 0, BassFlags.Default | BassFlags.Float | BassFlags.AutoFree);

            // _handle = Bass.CreateStream(soundfile);

            _handle = Bass.CreateStream(fileMemory, 0, fileMemory.Length, BassFlags.Default);

            // Free
            try
            {
                fileMemory = null;
                File.Delete(soundPath);
                GC.Collect();
            }
            catch { }

            if (_handle == 0)
            {
                Console.WriteLine("Player: Error Creating stream for {0} {1:G}", soundPath, Bass.LastError);
                return;
            }

            _Length = Bass.ChannelBytes2Seconds(_handle, Bass.ChannelGetLength(_handle));

            // Bass.FloatingPointDSP = true;

            if (Bass.ChannelSetDevice(_handle, 1))
            {
                Console.WriteLine("Player: Error Set Device {0:G}", Bass.LastError);
                return;
            }

            // Set Volume
            Volume = _VolumeTrack.Value / 100.0;

            // Set Balance
            Balance = _PanTrack.Value / 100.0f;

            // Play
            Play(true);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
 }