Exemple #1
0
        private Player()
        {
            var enginedir = AppDomain.CurrentDomain.BaseDirectory;

            if (Is64Bit)
            {
                enginedir = Path.Combine(enginedir, @"Engine\x64");
            }
            else
            {
                enginedir = Path.Combine(enginedir, @"Engine\x86");
            }
            Bass.Load(enginedir);
            BassMix.Load(enginedir);
            BassCd.Load(enginedir);
            BassFx.Load(enginedir);
            Bass.PluginLoad(enginedir + "\\bass_aac.dll");
            Bass.PluginLoad(enginedir + "\\bass_ac3.dll");
            Bass.PluginLoad(enginedir + "\\bass_ape.dll");
            Bass.PluginLoad(enginedir + "\\bass_mpc.dll");
            Bass.PluginLoad(enginedir + "\\bass_spx.dll");
            Bass.PluginLoad(enginedir + "\\bass_tta.dll");
            Bass.PluginLoad(enginedir + "\\bassalac.dll");
            Bass.PluginLoad(enginedir + "\\bassdsd.dll");
            Bass.PluginLoad(enginedir + "\\bassflac.dll");
            Bass.PluginLoad(enginedir + "\\bassopus.dll");
            Bass.PluginLoad(enginedir + "\\basswma.dll");
            Bass.PluginLoad(enginedir + "\\basswv.dll");
            Bass.PluginLoad(enginedir + "\\bassmidi.dll");
            _callback = MyDownloadProc;
            _maxfft   = (int)(DataFlags.Available | DataFlags.FFT2048);
            _eq       = new PeakEQParameters();
            _handle   = GCHandle.Alloc(_eq, GCHandleType.Pinned);
        }
Exemple #2
0
 void InitializeEqualizerBands(PeakEQParameters eq)
 {
     for (int i = 0; i < 10; i++)
     {
         eq.lBand   = i;
         eq.fCenter = DefaultCenterFrequencyList[i];
         Bass.FXSetParameters(fxEQ, eq);
     }
 }
Exemple #3
0
        /// <summary>
        /// Sets Single Equalizer Band
        /// </summary>
        /// <param name="band">Band to set</param>
        /// <param name="freq">Gain to set</param>
        public void UpdateEQBand(int band, float freq)
        {
            PeakEQParameters eq = new PeakEQParameters();

            // get values of the selected band
            eq.lBand = band;
            Bass.FXGetParameters(fxEQ, eq);
            eq.fGain = freq;
            Bass.FXSetParameters(fxEQ, eq);
        }
Exemple #4
0
 public Engine(IEngineConfiguration configuration)
 {
     _configuration = configuration;
     foreach (string plugin in _plugins)
     {
         Bass.PluginLoad(plugin);
     }
     _eq       = new PeakEQParameters();
     _eqHandle = GCHandle.Alloc(_eq, GCHandleType.Pinned);
     _maxfft   = (int)(DataFlags.Available | DataFlags.FFT2048);
 }
Exemple #5
0
        void InitializeEqualizer()
        {
            // Set peaking equalizer effect with no bands
            PeakEQParameters eq = new PeakEQParameters();

            fxEQ          = Bass.ChannelSetFX(handle, EffectType.PeakEQ, 0);
            eq.fQ         = 0f;
            eq.fBandwidth = 2.5f;
            eq.lChannel   = FXChannelFlags.All;
            //init equalizer bands
            InitializeEqualizerBands(eq);
        }
Exemple #6
0
 void InitializeEqualizerBands(PeakEQParameters eq)
 {
     for (int i = 0; i < 10; i++)
     {
         eq.lBand   = i;
         eq.fCenter = DefaultCenterFrequencyList[i];
         Bass.FXSetParameters(fxEQ, eq);
         EqualizerBand band = new EqualizerBand();
         band.Center           = eq.fCenter;
         band.Gain             = eq.fGain;
         band.PropertyChanged += Band_PropertyChanged;
         EqualizerBands.Add(band);
     }
 }
Exemple #7
0
        /// <summary>
        /// Creates a new instance of <see cref="PeakEQ"/>.
        /// </summary>
        public PeakEQ(int Channel, double Q = 0, double Bandwith = 2.5)
        {
            _channel = Channel;
            _handle = Bass.ChannelSetFX(Channel, EffectType.PeakEQ, 0);

            _parameters = new PeakEQParameters
            {
                lBand = -1,
                fQ = (float)Q,
                fBandwidth = (float)Bandwith
            };

            _gch = GCHandle.Alloc(_parameters, GCHandleType.Pinned);
        }
Exemple #8
0
 public BassEqualizerBand(ref int fxEqHandle, ref PeakEQParameters peakEQ, float centerValue, float gainValue, bool active)
 {
     _fxEq = fxEqHandle;
     _eq   = peakEQ;
     if (centerValue >= 1000)
     {
         BandCaption = string.Format("{0}KHz", (centerValue / 1000));
     }
     else
     {
         BandCaption = centerValue + "Hz";
     }
     _gain    = gainValue;
     IsActive = active;
 }
Exemple #9
0
 public BassEqualizerBand(int fxEqHandle, int bandNo, float centerValue, float gainValue, bool active)
 {
     _fxEq = fxEqHandle;
     _eq   = new PeakEQParameters()
     {
         lBand = bandNo,
     };
     if (centerValue >= 1000)
     {
         BandCaption = string.Format("{0}KHz", (centerValue / 1000));
     }
     else
     {
         BandCaption = centerValue + "Hz";
     }
     _gain    = gainValue;
     IsActive = active;
 }
Exemple #10
0
        public override void Init(bool setToDefaultValues = false)
        {
            // Set peaking equalizer effect with no bands
            _eq            = new PeakEQParameters();
            _fxEq          = Bass.ChannelSetFX(_handle, EffectType.PeakEQ, 0);
            _eq.fQ         = 0f;
            _eq.fBandwidth = 2.5f;
            _eq.lChannel   = FXChannelFlags.All;

            //init equalizer bands
            Bands.Clear();

            var gainValues = !setToDefaultValues && EqualizerSettings != null ? EqualizerSettings.GainValues : null;

            for (int i = 0; i < EqDefaultValues.Length; i++)
            {
                _eq.lBand   = i;
                _eq.fCenter = EqDefaultValues[i][0];
                var res  = Bass.FXSetParameters(_fxEq, _eq);
                var band = new BassEqualizerBand(_fxEq, i, EqDefaultValues[i][0], EqDefaultValues[i][1], IsEnabled);

                if (band == null)
                {
                    continue;
                }
                band.PropertyChanged += (sender, e) =>
                {
                    if (e.PropertyName == "Gain")
                    {
                        SaveEqualizerSettings();
                    }
                };

                if (gainValues != null && gainValues.TryGetValue(band.BandCaption, out float savedValue))
                {
                    band.Gain = savedValue;
                }
                Bands.Add(band);
            }
        }