Ejemplo n.º 1
0
        //停止
        public void Stop()
        {
            _updateTimer.Stop();
            //Bass.BASS_ChannelStop(_stream);

            if (WF2 != null && WF2.IsRenderingInProgress)
                WF2.RenderStop();

            Bass.BASS_StreamFree(_stream);
            _stream = 0;
        }
Ejemplo n.º 2
0
        //开始
        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());
                    }

                }

            }
        }