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); }
public FilePlayer(string FilePath, Resolution BufferKind = Resolution.Short) : base(BufferKind) { if (!File.Exists(FilePath)) { throw new FileNotFoundException(); } this.FilePath = FilePath; Handle = Bass.CreateStream(FilePath, 0, 0, BassFlags.Unicode | BassFlags.Prescan | BufferKind.ToBassFlag()); }
public NetworkDecoder(string Url, Resolution BufferKind = Resolution.Short, Action <BufferProvider> callback = null) : base(BufferKind) { this.Url = Url; if (callback != null) { call = callback; proc = new DownloadProcedure(Callback); } Down_Handler = new SyncProcedure(OnDownloadCompleted); Handle = Bass.CreateStream(Url, 0, BufferKind.ToBassFlag() | BassFlags.Decode | BassFlags.Unicode, (callback != null ? proc : null), IntPtr.Zero); Bass.ChannelSetSync(Handle, SyncFlags.Downloaded, 0, Down_Handler, IntPtr.Zero); }
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> /// Override this method for custom loading procedure. /// </summary> /// <param name="FileName">Path to the File to Load.</param> /// <returns><see langword="true"/> on Success, <see langword="false"/> on failure</returns> protected virtual int OnLoad(string FileName) => Bass.CreateStream(FileName);
/// <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); }
public PushStream(Resolution BufferKind = Resolution.Short) : base(BufferKind) { Handle = Bass.CreateStream(44100, 2, BufferKind.ToBassFlag(), StreamProcedureType.Push); }