Ejemplo n.º 1
0
        private void UpdateMatrix(int index)
        {
            double dhandle;

            this.FPinHandles[index].GetValue(0, out dhandle);

            ChannelInfo info = this.manager.GetChannel(Convert.ToInt32(dhandle));

            if (info != null)
            {
                int mixerhandle = 0;

                if (info.BassHandle.HasValue)
                {
                    mixerhandle = BassMix.BASS_Mixer_ChannelGetMixer(info.BassHandle.Value);
                }

                if (mixerhandle != 0)
                {
                    BASS_CHANNELINFO MIXER   = Bass.BASS_ChannelGetInfo(mixerhandle);
                    BASS_CHANNELINFO CHANNEL = Bass.BASS_ChannelGetInfo(info.BassHandle.Value);
                    float[,] matrix = new float[MIXER.chans, CHANNEL.chans];
                    BassMix.BASS_Mixer_ChannelGetMatrix(info.BassHandle.Value, matrix);
                    int idx = 0;



                    for (int i = 0; i < MIXER.chans; i++)
                    {
                        for (int j = 0; j < CHANNEL.chans; j++)
                        {
                            double level;
                            this.FPinLevels[index].GetValue(idx, out level);
                            matrix[i, j] = (float)level;

                            idx++;
                            if (idx == this.FPinLevels[index].SliceCount)
                            {
                                idx = 0;
                            }
                        }
                    }

                    BassMix.BASS_Mixer_ChannelSetMatrix(info.BassHandle.Value, matrix);
                }
            }
        }
Ejemplo n.º 2
0
        private void buttonPlaySource_Click(object sender, System.EventArgs e)
        {
            Bass.BASS_StreamFree(_streamA);
            Bass.BASS_StreamFree(_streamB);
            Bass.BASS_StreamFree(_mixerStream);
            // mixer setup
            // now we need some channels to plug them in...create two decoding sources
            _streamA = Bass.BASS_StreamCreateFile(_fileName, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
            _streamB = Bass.BASS_StreamCreateFile(_fileNameOutput, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
            BASS_CHANNELINFO i = new BASS_CHANNELINFO();

            Bass.BASS_ChannelGetInfo(_streamA, i);
            // this will be the final mixer output stream being played
            _mixerStream = BassMix.BASS_Mixer_StreamCreate(i.freq, 4, BASSFlag.BASS_DEFAULT);
            // finally we plug them into the mixer (and upmix it to 4 channels - we assume the source to be stereo)
            bool okA = BassMix.BASS_Mixer_StreamAddChannel(_mixerStream, _streamA, BASSFlag.BASS_MIXER_MATRIX | BASSFlag.BASS_STREAM_AUTOFREE);
            bool okB = BassMix.BASS_Mixer_StreamAddChannel(_mixerStream, _streamB, BASSFlag.BASS_STREAM_AUTOFREE);

            // a matrix for A!
            float[,] matrixA = new float[4, 2] {            // stereo to quad matrix
                { 1, 0 },                                   // left front out = left in
                { 0, 1 },                                   // right front out = right in
                { 1, 0 },                                   // left rear out = left in
                { 0, 1 }                                    // right rear out = right in
            };
            // apply the matrix to stream A only
            BassMix.BASS_Mixer_ChannelSetMatrix(_streamA, matrixA);
            // just so show how to get it back...
            float[,] matrixGet = new float[4, 2];
            BassMix.BASS_Mixer_ChannelGetMatrix(_streamA, matrixGet);
            // mute streamB at the beginning
            this.trackBarCrossFader.Value = -100;
            Bass.BASS_ChannelSetAttribute(_streamB, BASSAttribute.BASS_ATTRIB_VOL, 0f);

            // and play it...
            if (Bass.BASS_ChannelPlay(_mixerStream, false))
            {
                this.label1.Text = "Playing! Use the crossfader...";
            }
        }