private void MyWaveFormCallback(int framesDone, int framesTotal, TimeSpan elapsedTime, bool finished) { if (finished) { _WF.SyncPlayback(_currentTrack.Channel); // and do pre-calculate the next track position // in this example we will only use the end-position long startPos = 0L; long endPos = 0L; if (_WF.GetCuePoints(ref startPos, ref endPos, -24.0, -12.0, true)) { _currentTrack.NextTrackPos = endPos; // if there is already a sync set, remove it first if (_currentTrack.NextTrackSync != 0) { BassMix.BASS_Mixer_ChannelRemoveSync(_currentTrack.Channel, _currentTrack.NextTrackSync); } // set the next track sync automatically _currentTrack.NextTrackSync = BassMix.BASS_Mixer_ChannelSetSync(_currentTrack.Channel, BASSSync.BASS_SYNC_POS | BASSSync.BASS_SYNC_MIXTIME, _currentTrack.NextTrackPos, _currentTrack.TrackSync, new IntPtr(1)); _WF.AddMarker("Next", _currentTrack.NextTrackPos); } } // will be called during rendering... DrawWave(); }
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; } } }