Exemple #1
0
        /// <summary>
        /// Switch Equalizer On/Off
        /// </summary>
        /// <param name="state">
        /// true = On 
        /// false = Off
        /// </param>
        public void settoggleEQ(bool state)
        {
            _toggleEq = state;
            if (state)
            {

                for (int i = 0; i < 10; i++)
                {

                    var eq = new BASS_BFX_PEAKEQ {lBand = i};
                    // get values of the selected band
                    Bass.BASS_FXGetParameters(_fxEq, eq);
                    eq.fGain = _equalizerTmp[i]+Eqstart;
                    Bass.BASS_FXSetParameters(_fxEq, eq);

                }

            }
            else
            {

                for (int i = 0; i < 10; i++)
                {

                    var eq = new BASS_BFX_PEAKEQ {lBand = i};
                    // get values of the selected band
                    Bass.BASS_FXGetParameters(_fxEq, eq);
                    eq.fGain = Eqstart;
                    Bass.BASS_FXSetParameters(_fxEq, eq);

                }

            }
            Notify();
        }
Exemple #2
0
        /// <summary>
        /// This Method Sets the Equalizer Settings to a new Stream.
        /// </summary>
        private void EqualizerInit()
        {
            //############## BASSFX - Equalizer #######################
            // 60Hz, 170, 310, 600, 1K, 3K, 6K,12K,14K,16KHz
            // 10-band EQ
            // Set peaking equalizer effect with no bands
            bool loadbassfx = BassFx.LoadMe();
            var eq = new BASS_BFX_PEAKEQ();
            _fxEq = Bass.BASS_ChannelSetFX(_rawstream, BASSFXType.BASS_FX_BFX_PEAKEQ, 5);
               // _fxComp = Bass.BASS_ChannelSetFX(_rawstream, BASSFXType.BASS_FX_BFX_DAMP, 0);
            /*
            BASS_BFX_DAMP comp = new BASS_BFX_DAMP();
            if (Bass.BASS_FXGetParameters(_fxComp, comp))
            {
                //comp.Preset_Soft();
                /*
                comp.fTarget=0.92f;
                comp.fQuiet=0.02f;
                comp.fRate=0.01f;
                comp.fGain=1.0f;
                comp.fDelay = 0.5f;

                comp.fTarget = 1f;
                comp.fQuiet =0f;
                comp.fRate = 0.02f;
                comp.fGain = 1f;
                comp.fDelay = 0.2f;

                Bass.BASS_FXSetParameters(_fxComp, comp);
            }
            */
            _fxComp = Bass.BASS_ChannelSetFX(_rawstream, BASSFXType.BASS_FX_BFX_COMPRESSOR2, 0);
            //Add Compressor Effect
            var comp = new BASS_BFX_COMPRESSOR2();
            if (Bass.BASS_FXGetParameters(_fxComp, comp))
            {
                comp.fGain = 1f;
                comp.fAttack = 10f;
                comp.fRelease = 200f;
                comp.fThreshold = -10f;
                comp.fRatio = 3f;
                Bass.BASS_FXSetParameters(_fxComp, comp);
            }

            if (!loadbassfx)
            {
                //MessageBox.Show("Can't find bass_fx.dll");
            }
            // Setup the EQ bands

            //eq.fQ = 0f;
            eq.fBandwidth = 1f;
            eq.lChannel = BASSFXChan.BASS_BFX_CHANALL;
               // setEqualizerBand(eq.lBand, 0.0f);
            //Band 1
            eq.lBand = 0;
            eq.fCenter = 60f;
            Bass.BASS_FXSetParameters(_fxEq, eq);

            //setEqualizerBand(eq.lBand, 0.0f);

            //Band 2
            eq.lBand = 1;
            eq.fCenter = 170f;
            Bass.BASS_FXSetParameters(_fxEq, eq);

            //setEqualizerBand(eq.lBand, 0.0f);
            //Band 3
            eq.lBand = 2;
            eq.fCenter = 310f;
            Bass.BASS_FXSetParameters(_fxEq, eq);

            //setEqualizerBand(eq.lBand, 0.0f);

            //Band 4
            eq.lBand = 3;
            eq.fCenter = 600f;
            Bass.BASS_FXSetParameters(_fxEq, eq);

            //setEqualizerBand(eq.lBand, 0.0f);

            //Band 5
            eq.lBand = 4;
            eq.fCenter = 1000f;
            Bass.BASS_FXSetParameters(_fxEq, eq);

            //setEqualizerBand(eq.lBand, 0.0f);

            //Band 6
            eq.lBand = 5;
            eq.fCenter = 3000f;
            Bass.BASS_FXSetParameters(_fxEq, eq);

            //setEqualizerBand(eq.lBand, 0.0f);

            //Band 7
            eq.lBand = 6;
            eq.fCenter = 6000f;
            Bass.BASS_FXSetParameters(_fxEq, eq);

            //setEqualizerBand(eq.lBand, 0.0f);

            //Band 8
            eq.lBand = 7;
            eq.fCenter = 12000f;
            Bass.BASS_FXSetParameters(_fxEq, eq);

            //setEqualizerBand(eq.lBand, 0.0f);

            //Band 9
            eq.lBand = 8;
            eq.fCenter = 14000f;
            Bass.BASS_FXSetParameters(_fxEq, eq);

            //setEqualizerBand(eq.lBand, 0.0f);

            //Band 10
            eq.lBand = 9;
            eq.fCenter = 16000f;
            Bass.BASS_FXSetParameters(_fxEq, eq);

            //setEqualizerBand(eq.lBand, 0.0f);
        }
Exemple #3
0
        /// <summary>
        /// Set Equalizer Settings
        /// </summary>
        /// <param name="frequencyList">10 Band Float list</param>
        public void setEqualizer(float[] frequencyList)
        {
            if (frequencyList == null)
                return;

            for (int i = 0; i < 10; i++)
            {

                _equalizerTmp[i] = frequencyList[i];
                if (!_stopped &&_toggleEq)
                {
                    var eq = new BASS_BFX_PEAKEQ {lBand = i};
                    // get values of the selected band
                    Bass.BASS_FXGetParameters(_fxEq, eq);
                    eq.fGain = frequencyList[i]+Eqstart;
                    Bass.BASS_FXSetParameters(_fxEq, eq);

                }

            }
            _changeEq = true;
            Notify();
            _changeEq = false;

            if (Bass.BASS_ErrorGetCode() != BASSError.BASS_OK && Bass.BASS_ErrorGetCode() != BASSError.BASS_ERROR_HANDLE)
            {
                var e = new BassWrapperException(Bass.BASS_ErrorGetCode(),"Error in Bass.dll; Error Code: " + Bass.BASS_ErrorGetCode())
                            {Source = "BassWrapper"};
                throw e;

            }
        }
Exemple #4
0
        /// <summary>
        /// Sets Single Equalizer Band
        /// </summary>
        /// <param name="band">Band to set</param>
        /// <param name="freq">Gain to set</param>
        public void setEqualizerBand(int band, float freq)
        {
            _equalizerTmp[band] = freq;
            if (!_stopped && _toggleEq)
            {
                var eq = new BASS_BFX_PEAKEQ {lBand = band};
                // get values of the selected band
                Bass.BASS_FXGetParameters(_fxEq, eq);
                eq.fGain = freq+Eqstart;
                Bass.BASS_FXSetParameters(_fxEq, eq);

            }
            _changeEq = true;
            Notify();
            _changeEq = false;

            if (Bass.BASS_ErrorGetCode() != BASSError.BASS_OK && Bass.BASS_ErrorGetCode() != BASSError.BASS_ERROR_HANDLE)
            {
                var e = new BassWrapperException(Bass.BASS_ErrorGetCode(),"Error in Bass.dll; Error Code: " + Bass.BASS_ErrorGetCode())
                            {Source = "BassWrapper"};
                throw e;

            }
        }
Exemple #5
0
        /// <summary>
        /// Applies a preset on the 18-band equalizer. 
        /// The equalizer needs to be created using the AddEQ method.
        /// </summary>
        public void ApplyEQPreset(EQPreset preset)
        {
            //Console.WriteLine("Player - ApplyEQPreset name: {0}", preset.Name);
            BASS_BFX_PEAKEQ eq = new BASS_BFX_PEAKEQ();
            _currentEQPreset = preset;
            if (_isEQBypassed)
                return;

            if(!_isPlaying)
                return;

            //Console.WriteLine("Player - ApplyEQPreset - Removing BPM callbacks...");
            RemoveBPMCallbacks();

            //Console.WriteLine("Player - ApplyEQPreset - Looping through bands");
            for (int a = 0; a < _currentEQPreset.Bands.Count; a++)
            {
                //Console.WriteLine("Player - ApplyEQPreset name: {0} - Applying band {1}", preset.Name, a);
                EQPresetBand currentBand = _currentEQPreset.Bands[a];
                eq.lBand = a;
                eq.lChannel = BASSFXChan.BASS_BFX_CHANALL;
                eq.fCenter = currentBand.Center;
                eq.fGain = currentBand.Gain;
                eq.fQ = currentBand.Q;

                bool success = BassWrapper.BASS_FXSetParametersPeakEQ(_fxEQHandle, eq);
                if(!success)
                    Base.CheckForError();
            }

            //Console.WriteLine("Player - ApplyEQPreset - Readding BPM callbacks...");
            AddBPMCallbacks();
        }
Exemple #6
0
 /// <summary>
 /// Gets the parameters of an EQ band.
 /// </summary>
 /// <param name="band">Band index</param>
 /// <returns>EQ parameters</returns>
 private BASS_BFX_PEAKEQ GetEQParams(int band)
 {
     BASS_BFX_PEAKEQ eq = new BASS_BFX_PEAKEQ {lBand = band};
     BassWrapper.BASS_FXGetParametersPeakEQ(_fxEQHandle, eq);
     return eq;
 }
        /// <summary>
        /// This Method Sets the Equalizer Settings to a new Stream.
        /// </summary>
        private void EqualizerInit()
        {
            //############## BASSFX - Equalizer #######################
            // 60Hz, 170, 310, 600, 1K, 3K, 6K,12K,14K,16KHz
            // 10-band EQ
            // Set peaking equalizer effect with no bands
            bool loadbassfx = BassFx.LoadMe();
            BASS_BFX_PEAKEQ eq = new BASS_BFX_PEAKEQ();
            fxEQ = Bass.BASS_ChannelSetFX(streamID, BASSFXType.BASS_FX_BFX_PEAKEQ, 0);
            if (!loadbassfx)
            {
                MessageBox.Show("Can't find bass_fx.dll");
            }
            // Setup the EQ bands

            eq.fQ = 0f;
            eq.fBandwidth = 2.5f;
            eq.lChannel = BASSFXChan.BASS_BFX_CHANALL;
            setEqualizerBand(eq.lBand, equalizerTmp[eq.lBand]);
            //Band 1
            eq.lBand = 0;
            eq.fCenter = 60f;
            Bass.BASS_FXSetParameters(fxEQ, eq);
            setEqualizerBand(eq.lBand, equalizerTmp[eq.lBand]);

            //Band 2
            eq.lBand = 1;
            eq.fCenter = 170f;
            Bass.BASS_FXSetParameters(fxEQ, eq);

            setEqualizerBand(eq.lBand, equalizerTmp[eq.lBand]);
            //Band 3
            eq.lBand = 2;
            eq.fCenter = 310f;
            Bass.BASS_FXSetParameters(fxEQ, eq);
            setEqualizerBand(eq.lBand, equalizerTmp[eq.lBand]);

            //Band 4
            eq.lBand = 3;
            eq.fCenter = 600f;
            Bass.BASS_FXSetParameters(fxEQ, eq);
            setEqualizerBand(eq.lBand, equalizerTmp[eq.lBand]);

            //Band 5
            eq.lBand = 4;
            eq.fCenter = 1000f;
            Bass.BASS_FXSetParameters(fxEQ, eq);
            setEqualizerBand(eq.lBand, equalizerTmp[eq.lBand]);

            //Band 6
            eq.lBand = 5;
            eq.fCenter = 3000f;
            Bass.BASS_FXSetParameters(fxEQ, eq);
            setEqualizerBand(eq.lBand, equalizerTmp[eq.lBand]);

            //Band 7
            eq.lBand = 6;
            eq.fCenter = 6000f;
            Bass.BASS_FXSetParameters(fxEQ, eq);
            setEqualizerBand(eq.lBand, equalizerTmp[eq.lBand]);

            //Band 8
            eq.lBand = 7;
            eq.fCenter = 12000f;
            Bass.BASS_FXSetParameters(fxEQ, eq);
            setEqualizerBand(eq.lBand, equalizerTmp[eq.lBand]);

            //Band 9
            eq.lBand = 8;
            eq.fCenter = 14000f;
            Bass.BASS_FXSetParameters(fxEQ, eq);
            setEqualizerBand(eq.lBand, equalizerTmp[eq.lBand]);

            //Band 10
            eq.lBand = 9;
            eq.fCenter = 16000f;
            Bass.BASS_FXSetParameters(fxEQ, eq);
            setEqualizerBand(eq.lBand, equalizerTmp[eq.lBand]);
        }
 /// <summary>
 /// Sets Single Equalizer Band
 /// </summary>
 /// <param name="band">Band to set</param>
 /// <param name="freq">Gain to set</param>
 public void setEqualizerBand(int band, float freq)
 {
     equalizerTmp[band] = freq;
     BASS_BFX_PEAKEQ eq = new BASS_BFX_PEAKEQ();
     // get values of the selected band
     eq.lBand = band;
     Bass.BASS_FXGetParameters(fxEQ, eq);
     eq.fGain = freq;
     Bass.BASS_FXSetParameters(fxEQ, eq);
 }
 /// <summary>
 /// Set Equalizer Settings
 /// </summary>
 /// <param name="frequencyList">10 Band Float list</param>
 public void setEqualizer(float[] frequencyList)
 {
     for (int i = 0; i < 10; i++)
     {
         equalizerTmp[i] = frequencyList[i];
         BASS_BFX_PEAKEQ eq = new BASS_BFX_PEAKEQ();
         // get values of the selected band
         eq.lBand = i;
         Bass.BASS_FXGetParameters(fxEQ, eq);
         eq.fGain = frequencyList[i];
         Bass.BASS_FXSetParameters(fxEQ, eq);
     }
 }
Exemple #10
0
        /// <summary>
        /// Sets the effects (volume, equalizer, echo, etc) on the audio channels.
        /// </summary>
        /// <param name="profile">The equalizer profile to use (defaults to the current in SettingsManager)</param>
        /// <remarks>
        /// This should only be called once for each play of a given stream. Subsequent calls will add gain values, not replace it.
        /// Use RefreshFX() to change gain values while a stream is active.
        /// </remarks>
        public static void SetFX(EqualizerProfile profile = null)
        {
            if (profile == null)
                profile = SettingsManager.CurrentEqualizerProfile;

            Bass.BASS_ChannelSetAttribute(stream, BASSAttribute.BASS_ATTRIB_VOL, (float)SettingsManager.Volume / 100);

            fxEQHandle = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_BFX_PEAKEQ, 2);
            BASS_BFX_PEAKEQ eq = new BASS_BFX_PEAKEQ();
            eq.fQ = 0f;
            eq.fBandwidth = 2.5f;
            eq.lChannel = BASSFXChan.BASS_BFX_CHANALL;

            float[] bands = new float[10] { 32f, 63f, 125f, 250f, 500f, 1000f, 2000f, 4000f, 8000f, 16000f };
            for (int i = 0; i < bands.Count(); i++)
            {
                eq.lBand = i;
                eq.fCenter = bands[i];
                Bass.BASS_FXSetParameters(fxEQHandle, eq);
                SetEQ(i, profile.Levels[i]);
            }

            fxEchoHandle = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_ECHO, 1);
            SetEcho(profile.EchoLevel);

            fxCompHandle = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_BFX_COMPRESSOR2, 0);
            SetCompressor(1.0f, 10.0f, 0.3f);
        }
Exemple #11
0
 /// <summary>
 /// Sets a gain on an equalizer band.
 /// </summary>
 /// <param name="band">The band to apply gain to</param>
 /// <param name="gain">The gain to apply (in decibel)</param>
 public static void SetEQ(int band, float gain)
 {
     if (fxEQHandle == 0) return;
     BASS_BFX_PEAKEQ eq = new BASS_BFX_PEAKEQ();
     eq.lBand = band;
     if (Bass.BASS_FXGetParameters(fxEQHandle, eq))
     {
         eq.fGain = gain;
         Bass.BASS_FXSetParameters(fxEQHandle, eq);
     }
 }