internal void PlaySong(string PlayURL) { if (this.Channel != 0) { Bass.BASS_ChannelStop(this.Channel); } HttpWebRequest req = (HttpWebRequest)WebRequest.Create(PlayURL); req.Headers.Add("Cookie:" + Lala.API.Instance.Cookie); HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); _fs = resp.GetResponseStream(); _fsLength = resp.ContentLength; _myStreamCreateUser = new BASS_FILEPROCS( new FILECLOSEPROC(MyFileProcUserClose), new FILELENPROC(MyFileProcUserLength), new FILEREADPROC(MyFileProcUserRead), new FILESEEKPROC(MyFileProcUserSeek)); Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); this.Channel = Bass.BASS_StreamCreateFileUser(BASSStreamSystem.STREAMFILE_BUFFER, BASSFlag.BASS_STREAM_AUTOFREE, _myStreamCreateUser, IntPtr.Zero); if (this.Channel == 0) { throw new Exception(Bass.BASS_ErrorGetCode().ToString()); } Bass.BASS_ChannelPlay(this.Channel, false); this.Played(this, new EventArgs()); }
/// <summary> /// Creates a BASS stream that represents the song. /// </summary> /// <param name="flags">The flags to apply to the stream that is created.</param> /// <returns>The handle to the BASS stream that was created.</returns> public UInt32 CreateInstance(UInt32 flags) { var fileSystemService = FileSystemService.Create(); var instance = fileSystemService.OpenRead(file); var instanceID = this.nextInstanceID++; instances.Add(instanceID, instance); var stream = 0u; try { var procs = new BASS_FILEPROCS(fnClose, fnLength, fnRead, fnSeek); unsafe { stream = BASSNative.StreamCreateFileUser(1, BASSNative.BASS_STREAM_DECODE, &procs, new IntPtr((int)instanceID)); if (!BASSUtil.IsValidHandle(stream)) { throw new BASSException(); } } } catch { instance.Dispose(); instances.Remove(instanceID); throw; } return(stream); }
internal AudioPlayable(IAudio audio, IAudioStorage storage, IWebDownloader downloader, Uri url) { __Audio = audio; __Storage = storage; __Downloader = downloader; __Url = url; __BassFileProcs = new BASS_FILEPROCS(user => { }, user => __CacheStream.AudioSize, BassReadProc, (offset, user) => true); __EndStreamProc = (handle, channel, data, user) => { __RequestTasksStop = true; CleanActions(); OnAudioNaturallyEnded(); }; if (storage.CheckCached(audio)) { DownloadedFracion = 1.0; } }
public CoreDataProvider() { bassStreamingProc = new BASS_FILEPROCS( new FILECLOSEPROC(procUserClose), new FILELENPROC(procUserLength), new FILEREADPROC(procUserRead), new FILESEEKPROC(procUserSeek)); seekPosition = 0L; }
public MediaStreamer() { BassNet.Registration("*****@*****.**", "2X393121152222"); Bass.BASS_Init(-1, 44100, Un4seen.Bass.BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero); fileproc = new BASS_FILEPROCS(new FILECLOSEPROC(FileClose), new FILELENPROC(FileLength), new FILEREADPROC(FileRead), null); timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(20) }; timer.Tick += timer_Tick; }
public Player(String fileName, long fileLenght, FileStream fileStream) { // creo un handle per lo streaming dal file //streamHandle = Bass.BASS_StreamCreateFileUser(BASSStreamSystem.STREAMFILE_NOBUFFER, BASSFlag.BASS_DEFAULT | BASSFlag.BASS_MUSIC_PRESCAN, soundStream, IntPtr.Zero); _streamHandle = Bass.BASS_StreamCreateFile(fileName, 0, fileLenght, BASSFlag.BASS_DEFAULT); this.fileStream = fileStream; soundStream = new BASS_FILEPROCS( new FILECLOSEPROC(closeFile), new FILELENPROC(getFileLen), new FILEREADPROC(readFile), new FILESEEKPROC(setSeekCur) ); }
private void PlayFileForm_Load(object sender, EventArgs e) { if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Handle)) { fileName = String.Empty; streamHandle = 0; waveStreamHandle = 0; fileStream = null; waveForm = null; soundStream = new BASS_FILEPROCS( new FILECLOSEPROC(closeFile), new FILELENPROC(getFileLen), new FILEREADPROC(readFile), new FILESEEKPROC(setSeekCur) ); } }
internal AudioTrackBass(Stream data, bool quick = false, bool loop = false) { procs = new BASS_FILEPROCS(ac_Close, ac_Length, ac_Read, ac_Seek); Preview = quick; Looping = loop; BASSFlag flags = Preview ? 0 : (BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_STREAM_PRESCAN); if (data == null) { throw new AudioNotLoadedException(); } else { //encapsulate incoming stream with async buffer if it isn't already. DataStream = data as AsyncBufferStream; if (DataStream == null) { DataStream = new AsyncBufferStream(data, quick ? 8 : -1); } audioStreamPrefilter = Bass.BASS_StreamCreateFileUser(BASSStreamSystem.STREAMFILE_NOBUFFER, flags, procs, IntPtr.Zero); } if (Preview) { audioStream = audioStreamForwards = audioStreamPrefilter; } else { audioStream = audioStreamForwards = BassFx.BASS_FX_TempoCreate(audioStreamPrefilter, loop ? BASSFlag.BASS_MUSIC_LOOP : BASSFlag.BASS_DEFAULT); audioStreamBackwards = BassFx.BASS_FX_ReverseCreate(audioStreamPrefilter, 5f, BASSFlag.BASS_DEFAULT); Bass.BASS_ChannelSetAttribute(audioStream, BASSAttribute.BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO, Bass.TRUE); Bass.BASS_ChannelSetAttribute(audioStream, BASSAttribute.BASS_ATTRIB_TEMPO_OPTION_OVERLAP_MS, 4); Bass.BASS_ChannelSetAttribute(audioStream, BASSAttribute.BASS_ATTRIB_TEMPO_OPTION_SEQUENCE_MS, 30); } Length = (Bass.BASS_ChannelBytes2Seconds(audioStream, Bass.BASS_ChannelGetLength(audioStream)) * 1000); Bass.BASS_ChannelGetAttribute(audioStream, BASSAttribute.BASS_ATTRIB_FREQ, ref initialAudioFrequency); currentAudioFrequency = initialAudioFrequency; AudioEngine.RegisterTrack(this); }
private void CreateFileUser_Load(object sender, System.EventArgs e) { //BassNet.Registration("your email", "your regkey"); if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, this.Handle)) { // all fine // we alraedy create the user callback methods... _myStreamCreate = new STREAMPROC(MyFileProc); _myStreamCreateUser = new BASS_FILEPROCS( new FILECLOSEPROC(MyFileProcUserClose), new FILELENPROC(MyFileProcUserLength), new FILEREADPROC(MyFileProcUserRead), new FILESEEKPROC(MyFileProcUserSeek)); } else { MessageBox.Show(this, "Bass_Init error!"); } }
public void InitializeSound() { if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, Program.playerWindow.Handle)) { initialized = true; Thread t = new Thread(new ThreadStart(FillMemoryStream)); t.Start(); playFromMemoryStream = new MemoryStream(); //playFromMemoryStream.Seek(0, SeekOrigin.Begin); myStreamCreateUser = new BASS_FILEPROCS( new FILECLOSEPROC(MyFileProcUserClose), new FILELENPROC(MyFileProcUserLength), new FILEREADPROC(MyFileProcUserRead), new FILESEEKPROC(MyFileProcUserSeek)); } else { throw new Exception("Cannot initialize sound"); } }
private void Window_Loaded(object sender, System.Windows.RoutedEventArgs e) { System.IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle; BassNet.Registration("*****@*****.**", "2X3931422312422"); if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, hwnd)) { _myStreamCreate = new STREAMPROC(MyFileProc); _myStreamCreateUser = new BASS_FILEPROCS( new FILECLOSEPROC(MyFileProcUserClose), new FILELENPROC(MyFileProcUserLength), new FILEREADPROC(MyFileProcUserRead), new FILESEEKPROC(MyFileProcUserSeek)); MainVolume.Value = Bass.BASS_GetVolume() * 100; if (Bass.BASS_GetVolume() >= 80) { packicon_volumestate.Kind = MaterialDesignThemes.Wpf.PackIconKind.VolumeHigh; } _maintimer = new System.Windows.Threading.DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(500) }; _maintimer.Tick += new EventHandler(update_elapsedtime); _lyrictimer = new System.Windows.Threading.DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(500) }; _lyrictimer.Tick += new EventHandler(_lyrictimer_Tick); lyricShow = new LyricShow(CanvasLyric, StackPanelCommonLyric, CanvasFocusLyric, TBFocusLyricBack, CanvasFocusLyricFore, TBFocusLyricFore); getLT = new GetLyricAndLyricTime(); } else { System.Windows.MessageBox.Show(this, "Bass_Init error!"); } }
/// <summary> /// Initialize the bass library /// </summary> /// <returns></returns> protected bool BassNetInitialize() { gcHandle = GCHandle.Alloc(this, GCHandleType.Normal); // Keep Bass.Net from putting a popup on the screen lifetimeManager = new AudioFingerprint.Audio.BassLifetimeManager(false); bassFileProcs = new BASS_FILEPROCS( new FILECLOSEPROC(_BassCallback_FileProcUserClose), new FILELENPROC(_BassCallback_FileProcUserLength), new FILEREADPROC(_BassCallback_FileProcUserRead), new FILESEEKPROC(_BassCallback_FileProcUserSeek)); bassStalledSync = new SYNCPROC(_BassCallback_StalledSync); bassEndSync = new SYNCPROC(_BassCallback_EndSync); bassFileProcsOut = new BASS_FILEPROCS( new FILECLOSEPROC(_BassCallback_FileProcUserClose), new FILELENPROC(_BassCallback_FileProcUserLength), new FILEREADPROC(_BassCallback_FileProcUserReadOut), new FILESEEKPROC(_BassCallback_FileProcUserSeek)); Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_NET_BUFFER, 1000 * 4); // 2 seconds buffer (the default of bass also) return(true); }
public static extern int BASS_MIDI_FontInitUser(BASS_FILEPROCS procs, IntPtr user, BASSFlag flags);
/// <summary> /// Creates a sample stream from an MP3, MP2, MP1, OGG, WAV, AIFF or plugin supported file via user callback functions. /// </summary> /// <param name="system">File system to use, one of the following. </param> /// <param name="flags">A combination of these flags.</param> /// <param name="procs">The user defined file functions. </param> /// <param name="user">User instance data to pass to the callback functions. </param> /// <returns>If successful, the new stream's handle is returned, else throw WavException.</returns> public static int StreamCreateFileUser(BASSStreamSystem system, BASSFlag flags, BASS_FILEPROCS procs, IntPtr user) { int handle = NativeMethods.BASS_StreamCreateFileUser(system, flags, procs, user); if (handle == 0) { throw new WavException(BassErrorCode.GetErrorInfo()); } return(handle); }
public static extern int BASS_StreamCreateFileUser(BASSStreamSystem system, BASSFlag flags, BASS_FILEPROCS procs, IntPtr user);