Ejemplo n.º 1
0
        protected virtual void OnInit(object sender, EventArgs e)
        {
            if (!this.Enabled || this.Drive == CdUtils.NO_DRIVE)
            {
                return;
            }
            var flags = BassFlags.Decode;

            if (this.Output.Float)
            {
                flags |= BassFlags.Float;
            }
            BassUtils.OK(BassGaplessCd.Init());
            BassUtils.OK(BassGaplessCd.Enable(this.Drive, flags));
            this.IsInitialized = true;
            Logger.Write(this, LogLevel.Debug, "BASS CD Initialized.");
        }
Ejemplo n.º 2
0
        public void Test003()
        {
            try
            {
                if (!BassGaplessCd.Init())
                {
                    Assert.Fail("Failed to initialize GAPLESS.");
                }

                BassGaplessCd.Enable(0, BassFlags.Default);
                BassGaplessCd.Disable();
            }
            finally
            {
                BassGaplessCd.Free();
            }
        }
Ejemplo n.º 3
0
        public void Test001()
        {
            if (!Bass.Init(Bass.DefaultDevice))
            {
                Assert.Fail(string.Format("Failed to initialize BASS: {0}", Enum.GetName(typeof(Errors), Bass.LastError)));
            }

            if (!BassGapless.Init() || !BassGaplessCd.Init() || !BassGaplessCd.Enable(0, BassFlags.Decode | BassFlags.Float))
            {
                Assert.Fail("Failed to initialize GAPLESS.");
            }

            BassGapless.SetConfig(BassGaplessAttriubute.RecycleStream, true);

            var sourceChannel = BassCd.CreateStream(0, 0, BassFlags.Decode | BassFlags.Float);

            if (sourceChannel == 0)
            {
                Assert.Fail(string.Format("Failed to create source stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)));
            }

            var channelInfo = default(ChannelInfo);

            if (!Bass.ChannelGetInfo(sourceChannel, out channelInfo))
            {
                Assert.Fail(string.Format("Failed to get channel info: {0}", Enum.GetName(typeof(Errors), Bass.LastError)));
            }

            if (!BassGapless.ChannelEnqueue(sourceChannel))
            {
                Assert.Fail("Failed to add stream to gapless queue.");
            }

            var playbackChannel = BassGapless.StreamCreate(channelInfo.Frequency, channelInfo.Channels, BassFlags.Float);

            if (playbackChannel == 0)
            {
                Assert.Fail(string.Format("Failed to create playback stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)));
            }

            if (!Bass.ChannelPlay(playbackChannel))
            {
                Assert.Fail(string.Format("Failed to play stream:  {0}", Enum.GetName(typeof(Errors), Bass.LastError)));
            }

            var channelLength        = Bass.ChannelGetLength(sourceChannel);
            var channelLengthSeconds = Bass.ChannelBytes2Seconds(sourceChannel, channelLength);

            Bass.ChannelSetPosition(sourceChannel, Bass.ChannelSeconds2Bytes(sourceChannel, channelLengthSeconds - 10));

            do
            {
                var channelActive = Bass.ChannelIsActive(playbackChannel);
                if (channelActive == PlaybackState.Stopped)
                {
                    break;
                }

                var channelPosition        = Bass.ChannelGetPosition(playbackChannel);
                var channelPositionSeconds = Bass.ChannelBytes2Seconds(playbackChannel, channelPosition);

                if (channelPositionSeconds >= 20)
                {
                    break;
                }

                Thread.Sleep(1000);
            } while (true);

            if (!BassGapless.ChannelRemove(sourceChannel))
            {
                Assert.Fail("Failed to remove queued gapless channel.");
            }

            BassGaplessCd.Disable();

            Bass.StreamFree(sourceChannel);
            Bass.StreamFree(playbackChannel);

            BassGapless.Free();
            BassGaplessCd.Free();
            Bass.Free();
        }