Esempio n. 1
0
        public override void OnStarted()
        {
            if (Bass != null)
            {
                int channelBitwidth = base.ChannelBitwidth;
                switch (channelBitwidth)
                {
                case 0x20:
                    this._streamFlags &= ~BASSFlag.BASS_SAMPLE_8BITS;
                    this._streamFlags |= BASSFlag.BASS_SAMPLE_FLOAT;
                    channelBitwidth    = 4;
                    break;

                case 8:
                    this._streamFlags &= ~BASSFlag.BASS_SAMPLE_FLOAT;
                    this._streamFlags |= BASSFlag.BASS_SAMPLE_8BITS;
                    channelBitwidth    = 1;
                    break;

                default:
                    this._streamFlags &= ~BASSFlag.BASS_SAMPLE_FLOAT;
                    this._streamFlags &= ~BASSFlag.BASS_SAMPLE_8BITS;
                    channelBitwidth    = 2;
                    break;
                }
                this._streamBuffer = new BASSBuffer(2f, base.ChannelSampleRate, base.ChannelNumChans, channelBitwidth);
                this._stream       = Bass.StreamCreate(base.ChannelSampleRate, base.ChannelNumChans, this._streamFlags,
                                                       null, IntPtr.Zero);
                Bass.ChannelSetLink(base.ChannelHandle, this._stream);
                if (Bass.ChannelIsActive(base.ChannelHandle) == BASSActive.BASS_ACTIVE_PLAYING)
                {
                    Bass.ChannelPlay(this._stream, false);
                }
            }
        }
Esempio n. 2
0
        public int EnqueueSamples(int channels, int rate, byte[] samples, int frames)
        {
            int consumed = 0;

            if (basbuffer == null)
            {
                Bass.BASS_Init(-1, rate, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
                basbuffer     = new BASSBuffer(0.5f, rate, channels, 2);
                streamproc    = Reader;
                currentHandle = Bass.BASS_StreamCreate(rate, channels, BASSFlag.BASS_DEFAULT, streamproc, IntPtr.Zero);
                Bass.BASS_ChannelPlay(currentHandle, false);
            }

            if (basbuffer.Space(0) > samples.Length)
            {
                basbuffer.Write(samples, samples.Length);
                consumed = frames;
            }

            return(consumed);
        }
Esempio n. 3
0
    public int EnqueueSamples(int channels, int rate, byte[] samples, int frames)
    {
        int consumed = 0;
            if (basbuffer == null)
            {
                Bass.BASS_Init(-1, rate, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
                basbuffer = new BASSBuffer(2, rate, channels, 2);
                streamproc = new STREAMPROC(Reader);
                int bassId = Bass.BASS_StreamCreate(rate, channels, BASSFlag.BASS_DEFAULT, streamproc, IntPtr.Zero);
                Bass.BASS_ChannelPlay(bassId, false);
            }

            if (basbuffer.Space(0) > samples.Length)
            {
                basbuffer.Write(samples, samples.Length);
                consumed = frames;
            }

            return consumed;
    }