//开始 public void Start() { if (_fileName != String.Empty) { if (_stream != 0) { playPause = false; // used in RMS _30mslength = (int)Bass.BASS_ChannelSeconds2Bytes(_stream, 0.03); // 30ms window // latency from milliseconds to bytes _deviceLatencyBytes = (int)Bass.BASS_ChannelSeconds2Bytes(_stream, _deviceLatencyMS / 1000.0); if (WF2 != null && WF2.IsRendered) { // make sure playback and wave form are in sync, since // we rended with 16-bit but play here with 32-bit WF2.SyncPlayback(_stream); //long cuein = WF2.GetMarker("CUE"); long cueout = WF2.GetMarker("END"); //int cueinFrame = WF2.Position2Frames(cuein); //int cueoutFrame = WF2.Position2Frames(cueout); //Console.WriteLine("CueIn at {0}sec.; CueOut at {1}sec.", WF2.Frame2Seconds(cueinFrame), WF2.Frame2Seconds(cueoutFrame)); //if (cuein >= 0) //{ // Bass.BASS_ChannelSetPosition(_stream, cuein); //} if (cueout >= 0) { Bass.BASS_ChannelRemoveSync(_stream, _syncer); _syncer = Bass.BASS_ChannelSetSync(_stream, BASSSync.BASS_SYNC_POS, cueout, _sync, IntPtr.Zero); } } if (_stream != 0 && Bass.BASS_ChannelPlay(_stream, false)) { _updateTimer.Start(); } else { Console.WriteLine("Error={0}", Bass.BASS_ErrorGetCode()); } } } }
private void btnPlay_Click(object sender, EventArgs e) { updateTimer.Stop(); Bass.BASS_StreamFree(stream); if (filename != string.Empty) { stream = Bass.BASS_StreamCreateFile(filename, 0, 0, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN); if (stream != 0) { mslength = (int)Bass.BASS_ChannelSeconds2Bytes(stream, 0.03); deviceLatencyBytes = (int)Bass.BASS_ChannelSeconds2Bytes(stream, deviceLatencyMS / 1000.0); myDSPAddr = new DSPPROC(MyDSPGain); Bass.BASS_ChannelSetDSP(stream, myDSPAddr, IntPtr.Zero, 2); if (WF2 != null && WF2.IsRendered) { WF2.SyncPlayback(stream); long cuein = WF2.GetMarker("CUE"); long cueout = WF2.GetMarker("END"); int cueinFrame = WF2.Position2Frames(cuein); int cueoutFrame = WF2.Position2Frames(cueout); if (cuein >= 0) { Bass.BASS_ChannelSetPosition(stream, cuein); } if (cueout >= 0) { Bass.BASS_ChannelRemoveSync(stream, syncer); syncer = Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_POS, cueout, sync, IntPtr.Zero); } } } if (stream != 0 && Bass.BASS_ChannelPlay(stream, false)) { textBox1.Text = ""; updateTimer.Start(); BASS_CHANNELINFO info = new BASS_CHANNELINFO(); Bass.BASS_ChannelGetInfo(stream, info); textBox1.Text += "Info: " + info.ToString() + Environment.NewLine; TAG_INFO tagInfo = new TAG_INFO(); if (BassTags.BASS_TAG_GetFromFile(stream, tagInfo)) { textBoxAlbum.Text = tagInfo.album; textBoxArtist.Text = tagInfo.artist; textBoxTitle.Text = tagInfo.title; textBoxComment.Text = tagInfo.comment; textBoxGenre.Text = tagInfo.genre; textBoxYear.Text = tagInfo.year; textBoxTrack.Text = tagInfo.track; } btnStop.Enabled = true; btnPlay.Enabled = false; } } }
public AudioEngine() { Path = @"http://psv4.vk.me/c613621/u23628424/audios/45049760ad7c.mp3?extra=xy8j8Fwc0OnSqJcxvITYLiX-D4akkd_Rkl8cvuVgLlLvD9G133yv-_MAqCspCcmxxUdw9OMZGdrq702KUJ2PdO1oGDkTRvw&/Scratch%20Bandits%20Crew%20-%20Surround%20Me.mp3"; //Path = @"D:\Documents and Settings\Admin\Рабочий стол\C#\Music Primer\6ddb8171688e23.mp3"; // Path = @"http://www.sky.fm/mp3/the80s.pls"; //Path = @"http://download.wavetlan.com/SVV/Media/HTTP/WMA/WMALossless/Coldplay_StrawberrySwing_WMALossless.wma"; //Path = @"http://yp.shoutcast.com/sbin/tunein-station.pls?id=193174"; //+Path = @"http://yp.shoutcast.com/sbin/tunein-station.pls?id=193174"; //Path = @"http://radiocaroline259.nl/winamp_rc259_320.pls"; //Path = @"http://yp.shoutcast.com/sbin/tunein-station.pls?id=94181"; //Path = @"http://yp.shoutcast.com/sbin/tunein-station.pls?id=256410"; //Path = @"http://flacradio.esy.es/playlist/AI-Radio.m3u"; //Path = @"http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/llnw/bbc_1xtra.m3u8"; ListSongs = new List<string>( Directory.GetFiles(@"D:\Documents and Settings\Admin\Рабочий стол\C#\Music Primer")); /* ListSongs = new List<string>(); ListSongs.Add(@"http://cs1-34v4.vk-cdn.net/p6/d1483bd42febd1.mp3?extra=vi0VwGa9y_QGmZqu8zXS2NNAuPHuBuHM-yChSaH3-vezjVEJMN7tvO6WDQq3CRsOk0SJw9apaTVSamib5nHTPROhCr8kCz3n&/CunninLynguists%20-%20Darkness%20(Dream%20On)%20(Instrumental).mp3"); ListSongs.Add(@"http://psv4.vk.me/c613231/u23628424/audios/bca9f0bb9989.mp3?extra=c7lN4T5gQC3FOQPpHCgWnmtCTk2F89a-HjouOB5qAPoKePRg_0OSR7nbm8tsFqS1ypEXhrV5khECX449brMq9qzqtiYNOfq1&/Mr.%20Moods%20-%20Rainbow.mp3"); ListSongs.Add(@"http://psv4.vk.me/c613924/u64887148/audios/73b365664dbb.mp3?extra=qbIEMne5L7HEkwI8l57HvsJbjpHEap8WEapQ5BVETzm-bo_6lpu3UPJ4gDnGJyc-G4-7cWHb_gqO9fDT9Ly87XQPYfwcEcaO&/PhybaOptikz%20-%20Chronicles.mp3"); ListSongs.Add(@"http://psv4.vk.me/c521100/u4594424/audios/0277415e656d.mp3?extra=tUmU_lLbAdXrMsDon27ayCWW3l6soR7fHTiQ0-6Qj6xuim7tQLXcEBXS0lq9uJ1TxuFkG-4xyQyWR004b_BL7nkaLcKZqMbd&/Roger%20Molls%20-%20You.mp3"); ListSongs.Add(@"http://psv4.vk.me/c613126/u247179947/audios/5b4259f1d5c3.mp3?extra=Fo_qX0TC-RHoozxSTQQZBedY9vxIlLk1VcPyRMziMarqYxCBZqIhX7cCPCPfB4XvYy2Gbnz9Zdl34KXdNtXu0ovlSeG_B86E&/Keizan%20-%20Keizan%20-%20Damn%20feat%20Dj%20Meloman.mp3"); ListSongs.Add(@"http://psv4.vk.me/c611427/u221922242/audios/d196c39b7b28.mp3?extra=OgcU7H3jJrRB94KkUdGFxqXRlGwh7ttN3sIB0LGRqYUIxFpXfm48v6FQWyHWHge3DDI5U02KBoSRHOJTQX9Pdwj31aeoWBFw&/Billa%20Qause%20-%20Slow%20Down.mp3"); ListSongs.Add(@"http://psv4.vk.me/c611324/u1444216/audios/36a640799476.mp3?extra=sr0Y8gulc4N5Wr4wEPavdJ98vK3FRAFX6pQbCC6JeDypyPoT8RGLsR4618C8CpZE1YaLlUfGmFMAyJCsXsnjSo4sg-lH87qq&/GRiZ%20-%20Love%20Will%20Follow%20You%20(feat.%20Russ%20Liquid).mp3"); ListSongs.Add(@"http://psv4.vk.me/c613327/u23628424/audios/fb86d3ceae8f.mp3?extra=q7-2v9Jh_Cq0V4QlhgEz7E4pvf3NxS9yPCE5MIdu_0NQsdQ13572JElzEgZt9Kj7VafbWfxb-vq2IP1BvLLqCE6MSD7MZRA6&/Kinack%20-%20Shine.mp3"); ListSongs.Add(@"http://cs1-42v4.vk-cdn.net/p23/7ffb834f38273a.mp3?extra=-mJYId08Rdph4HddpqC6noOAFcs6jvCw0hauKmXWQkREoEUclM-MMSstShqEYPguWrAemIoc5zA57nx89XmbnkHGh-E_5WgD&/Frameworks%20-%20Music%20Box.mp3"); ListSongs.Add(@"http://psv4.vk.me/c613121/u23628424/audios/659402091c6c.mp3?extra=ZfCP0UugdWy6oapnqKBTnvwtC2vXa_WQXZsE648_vkKMgn2e-3nP1E1fREEgJnUsSka0pMvOHvOlBwU6oyjird1po-WO0J8W&/Travelers%20Of%20Tyme%20-%20Raining%20Castanets%20(The%20Rains%20of%20Castamere).mp3"); */ WahWahEffect = new WahWahService(); PitchShiftEffect = new PitchShiftService(); PhaserEffect = new PhaserService(); ChorusEffect = new ChorusService(); DistortionEffect = new DistortionService(); DynamicAmplificationEffect = new DynamicAmplificationService(); ReverberationEffect = new ReverberationService(); EchoEffect = new EchoService(); CompressorEffect = new CompressorService(); BiQuadFilterEffect = new BiQuadFilterService(); DSPEffect = new DSP(); WaveFormClass = new WaveFormService(); Spectrum = new Spectrum(); MemoryPlay = true; _timer = new BASSTimer(); _timer.Tick += MusicTrackTick; _timer.Start(); CurrentVolume = 1; Crossfade = new CrossfadeService(CurrentVolume); EqualizerEffect = new EqualizerService(); CrossfadeActive = true; SoundOutProvider = new SoundOutProviderBASS(); _myUserAgentPtr = Marshal.StringToHGlobalAnsi(_myUserAgent); _positionEventAggregator = new EventAggregator(); _waveFormEventAggregator = new EventAggregator(); DownloadMode = DownloadTypes.NoDownload; _syncProcPos = SyncMethodPos; Bass.BASS_SetConfigPtr(BASSConfig.BASS_CONFIG_NET_AGENT, _myUserAgentPtr); SoundOutProvider.SetConfig(BASSConfig.BASS_CONFIG_FLOATDSP, true); SoundOutProvider.SetConfig(BASSConfig.BASS_CONFIG_NET_TIMEOUT, 5000); SoundOutProvider.SetConfig(BASSConfig.BASS_CONFIG_WMA_PREBUF, 0); SoundOutProvider.SetConfig(BASSConfig.BASS_CONFIG_NET_PREBUF, 0); SoundOutProvider.SetConfig(BASSConfig.BASS_CONFIG_NET_PLAYLIST, 2); }
/// <summary> /// Starts the ticker which calls the Tick method. /// </summary> private static void StartTicker() { stopTicker = false; if (ticker == null) { ticker = new BASSTimer(tickInterval); ticker.Tick += new EventHandler(Tick); ticker.Start(); } }