public CompressorService()
 {
     _effect = new BASS_BFX_COMPRESSOR2();
     Band Gain = new Band(0, +60.0f, -60.0f, 1.0f, "Gain");
     Band Threshold = new Band(-15f, +0.0f, -60.0f, 0.5f, "Threshold");
     Band Ratio = new Band(3f, +10.0f, +1.0f, 0.1f, "Ratio");
     Band Attack = new Band(10f, +1000.0f, 0.01f, 0.01f, "Attack");
     Band Release = new Band(200f, 5000.0f, 0.01f, 0.01f, "Release");
     Bands = new List<Band>() { Gain, Threshold, Ratio, Attack, Release };
     Settings = new SettingsService<Band>("CompressorEffect");
     CurrentSettings = Settings.GetCurrentSettings();
     CurrentSettings.SetPreset(Bands, "CurrentPreset");
     IsActive = CurrentSettings.IsActive;
     BandChanged += ((object sender, ChangedEventArgs e) => { SetEffectToBand(e.Value, e.BandIndex); });
     PresetNames = new List<string>(CurrentSettings.Presets.Keys);
     EffectName = "Compressor";
     PresetName = "CurrentPreset";
 }
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>
 /// Sets the compressor on the currently active stream.
 /// </summary>
 public static void SetCompressor(float attack, float release, float threshold, float gain = 0f, float ratio = 0f)
 {
     if (fxCompHandle == 0) return;
     BASS_BFX_COMPRESSOR2 comp = new BASS_BFX_COMPRESSOR2();
     if (Bass.BASS_FXGetParameters(fxCompHandle, comp))
     {
         //comp.fGain = gain;
         comp.fAttack = attack;
         comp.fRelease = release;
         comp.fThreshold = threshold;
         //comp.fRatio = ratio;
         Bass.BASS_FXSetParameters(fxCompHandle, comp);
     }
 }
Exemple #4
0
        public void Init(int handle)
        {
            try
            {
                m_handle = handle;

                if (m_isEnabled)
                {
                    if (handle != -1)
                    {
                        BASS_BFX_PEAKEQ      eq     = new BASS_BFX_PEAKEQ();
                        BASS_BFX_COMPRESSOR2 comp   = new BASS_BFX_COMPRESSOR2();
                        BASS_BFX_VOLUME      preamp = new BASS_BFX_VOLUME();


                        m_bandValue = new BandValue();

                        // int compVal = Bass.BASS_ChannelSetFX(handle, BASSFXType.BASS_FX_BFX_COMPRESSOR2, 0);

                        // comp.lChannel = BASSFXChan.BASS_BFX_CHANALL;
                        //comp.fGain = 7.0f;
                        //comp.fAttack = 24.9f;
                        //comp.fRelease = 99.9f;
                        //comp.fThreshold = -11.0f;
                        //comp.fRatio = 4f;
                        // Bass.BASS_FXSetParameters(compVal, comp);

                        m_bandValue.Handle = Bass.BASS_ChannelSetFX(handle, BASSFXType.BASS_FX_BFX_PEAKEQ, 5);

                        if (m_dsp_gain != null)
                        {
                            m_dsp_gain.Dispose();
                        }
                        m_dsp_gain          = new DSP_Gain(handle, 6);
                        m_dsp_gain.Gain_dBV = ArrBandValue[10].PreAmp / 10;
                        //  m_preampHandle = Bass.BASS_ChannelSetFX(handle, BASSFXType.BASS_FX_BFX_VOLUME, 6);
                        //  preamp.lChannel = BASSFXChan.BASS_BFX_CHANNONE;
                        //  preamp.fVolume = (float)Math.Pow(10, (ArrBandValue[10].PreAmp / 10) / 20); //ArrBandValue[10].PreAmp;
                        //   Bass.BASS_FXSetParameters(m_preampHandle, preamp);

                        // m_handle = handle;

                        eq.fQ         = 0f;
                        eq.fBandwidth = 0.6f;
                        eq.lChannel   = BASSFXChan.BASS_BFX_CHANALL;

                        for (int i = 0; i < m_centers.Length; i++)
                        {
                            eq.lBand   = i;
                            eq.fCenter = m_centers[i];
                            Bass.BASS_FXSetParameters(m_bandValue.Handle, eq);
                            float gain = ArrBandValue[i].Gain;
                            UpdateEQBass(i, gain);
                            Console.WriteLine(m_bandValue.Handle + " : " + gain + " : " + i);
                        }
                    }
                    else
                    {
                        if (m_equalizer != null)
                        {
                            m_equalizer.Dispose();
                        }

                        m_equalizer = new Implementation.Equalizer();
                        // m_equalizer.Preamp = ArrBandValue[10].PreAmp / 10;

                        for (int i = 0; i < m_centers.Length; i++)
                        {
                            float gain = ArrBandValue[i].Gain;
                            UpdateEQVlc(i, gain);
                        }

                        // m_handle = handle;
                        m_bandValue.Handle = -1;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogFile(ex.Message, "", "Init", ex.LineNumber(), "Equalizer Class");
            }
        }