Ejemplo n.º 1
0
        /// <summary>
        /// Attach the various DSP Plugins and effects to the stream
        /// </summary>
        private void AttachDspToStream()
        {
            bool dspActive = Config.DSPActive;

            // BASS DSP/FX
            foreach (BassEffect basseffect in Player.DSP.Settings.Instance.BassEffects)
            {
                dspActive = true;
                foreach (BassEffectParm parameter in basseffect.Parameter)
                {
                    setBassDSP(basseffect.EffectName, parameter.Name, parameter.Value);
                }
            }

            // Attach active DSP effects to the Stream
            if (dspActive)
            {
                // BASS effects
                if (_gain != null)
                {
                    Log.Debug("BASS: Enabling Gain Effect.");
                    _gain.ChannelHandle = _stream;
                    _gain.Start();
                }
                if (_damp != null)
                {
                    Log.Debug("BASS: Enabling Dynamic Amplifier Effect.");
                    int dampHandle = Bass.BASS_ChannelSetFX(_stream, BASSFXType.BASS_FX_BFX_DAMP, _dampPrio);
                    Bass.BASS_FXSetParameters(dampHandle, _damp);
                }
                if (_comp != null)
                {
                    Log.Debug("BASS: Enabling Compressor Effect.");
                    int compHandle = Bass.BASS_ChannelSetFX(_stream, BASSFXType.BASS_FX_BFX_COMPRESSOR, _compPrio);
                    Bass.BASS_FXSetParameters(compHandle, _comp);
                }

                // VST Plugins
                foreach (string plugin in Config.VstPlugins)
                {
                    Log.Debug("BASS: Enabling VST Plugin: {0}", plugin);
                    int vstHandle = BassVst.BASS_VST_ChannelSetDSP(_stream, plugin, BASSVSTDsp.BASS_VST_DEFAULT, 1);
                    // Copy the parameters of the plugin as loaded on from the settings
                    int vstParm = Config.VstHandles[plugin];
                    BassVst.BASS_VST_SetParamCopyParams(vstParm, vstHandle);
                }

                // Init Winamp DSP only if we got a winamp plugin actiavtes
                int waDspPluginHandle = 0;
                if (Player.DSP.Settings.Instance.WinAmpPlugins.Count > 0)
                {
                    foreach (WinAmpPlugin plugins in Player.DSP.Settings.Instance.WinAmpPlugins)
                    {
                        Log.Debug("BASS: Enabling Winamp DSP Plugin: {0}", plugins.PluginDll);
                        waDspPluginHandle = BassWaDsp.BASS_WADSP_Load(plugins.PluginDll, 5, 5, 100, 100, null);
                        if (waDspPluginHandle > 0)
                        {
                            _waDspPlugins[plugins.PluginDll] = waDspPluginHandle;
                            BassWaDsp.BASS_WADSP_Start(waDspPluginHandle, 0, 0);
                        }
                        else
                        {
                            Log.Debug("Couldn't load WinAmp Plugin {0}. Error code: {1}", plugins.PluginDll,
                                      Enum.GetName(typeof(BASSError), Bass.BASS_ErrorGetCode()));
                        }
                    }
                }

                foreach (int waPluginHandle in _waDspPlugins.Values)
                {
                    BassWaDsp.BASS_WADSP_ChannelSetDSP(waPluginHandle, _stream, 1);
                }
            }
        }
Ejemplo n.º 2
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");
            }
        }
Ejemplo n.º 3
0
 void sf_SoundChannelChanged(AudioStream c)
 {
     ID = Bass.BASS_ChannelSetFX(c.StreamHandle, BASSFXType.BASS_FX_BFX_ECHO, 1);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Play the selected Music File
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btPlay_Click(object sender, EventArgs e)
        {
            if (File.Exists(textBoxMusicFile.Text))
            {
                // Init BASS
                BassAudioEngine bassEngine = BassMusicPlayer.Player;
                if (bassEngine.BassFreed)
                {
                    bassEngine.InitBass();
                }

                _stream = Bass.BASS_StreamCreateFile(textBoxMusicFile.Text, 0, 0,
                                                     BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_AUTOFREE |
                                                     BASSFlag.BASS_SAMPLE_SOFTWARE);
                if (_stream != 0)
                {
                    // Attach the BASS DSP Effects to the stream
                    if (_gain != null)
                    {
                        _gain.ChannelHandle = _stream;
                        _gain.Start();
                    }

                    if (checkBoxDAmp.Checked)
                    {
                        _dampHandle = Bass.BASS_ChannelSetFX(_stream, BASSFXType.BASS_FX_BFX_DAMP, _dampPrio);
                        Bass.BASS_FXSetParameters(_dampHandle, _damp);
                    }

                    if (checkBoxCompressor.Checked)
                    {
                        _compHandle = Bass.BASS_ChannelSetFX(_stream, BASSFXType.BASS_FX_BFX_COMPRESSOR, _compPrio);
                        Bass.BASS_FXSetParameters(_compHandle, _comp);
                    }

                    // Attach the plugins to the stream
                    foreach (DSPPluginInfo dsp in listBoxSelectedPlugins.Items)
                    {
                        if (dsp.DSPPluginType == DSPPluginInfo.PluginType.VST)
                        {
                            _vstHandle = BassVst.BASS_VST_ChannelSetDSP(_stream, dsp.FilePath, BASSVSTDsp.BASS_VST_DEFAULT, 1);
                            // Copy the parameters of the old handle
                            int vstold = _vstHandles[dsp.Name];
                            BassVst.BASS_VST_SetParamCopyParams(vstold, _vstHandle);
                            // Now find out to which stream the old handle was assigned and free it
                            BASS_VST_INFO bassvstinfo = new BASS_VST_INFO();
                            BassVst.BASS_VST_GetInfo(vstold, bassvstinfo);
                            BassVst.BASS_VST_ChannelRemoveDSP(bassvstinfo.channelHandle, vstold);
                            _vstHandles[dsp.Name] = _vstHandle;
                        }
                        else
                        {
                            _waDspPlugin = _waDspPlugins[dsp.FilePath];
                            BassWaDsp.BASS_WADSP_Start(_waDspPlugin, 0, 0);
                            BassWaDsp.BASS_WADSP_ChannelSetDSP(_waDspPlugin, _stream, 1);
                        }
                    }
                    btPlay.Enabled = false;
                    btStop.Enabled = true;
                    Bass.BASS_ChannelPlay(_stream, false);
                }
                else
                {
                    MessageBox.Show("Can't play file. Probably not a valid music file");
                }
            }
            else
            {
                MessageBox.Show("File specified does not exist");
            }
        }