Example #1
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);
        }
Example #2
0
        /// <summary>
        /// Checks if any values has been changed.
        /// </summary>
        /// <param name="profile">The profile to compare to</param>
        /// <returns>True if any values has been changed, otherwise false</returns>
        private bool AnyChanged(EqualizerProfile profile = null)
        {
            if (profile == null)
                profile = SettingsManager.CurrentEqualizerProfile;

            float[] levels = new float[]
            {
                (float)F32.Value / 10f,
                (float)F64.Value / 10f,
                (float)F125.Value / 10f,
                (float)F250.Value / 10f,
                (float)F500.Value / 10f,
                (float)F1K.Value / 10f,
                (float)F2K.Value / 10f,
                (float)F4K.Value / 10f,
                (float)F8K.Value / 10f,
                (float)F16K.Value / 10f,
            };

            for (int i = 0; i < levels.Count(); i++)
            {
                float a = profile.Levels[i];
                float b = levels[i];
                if (Math.Round(a, 2) != Math.Round(b, 2)) return true;
            }

            return (Math.Round(profile.EchoLevel, 2) != Math.Round(Echo.Value, 2));
        }
Example #3
0
 /// <summary>
 /// Refreshes the effect on the currently active channel given an equalizer profile.
 /// </summary>
 /// <param name="profile">The equalizer profile to use (defaults to the current in SettingsManager)</param>
 public static void RefreshFX(EqualizerProfile profile = null)
 {
     if (profile == null)
         profile = SettingsManager.CurrentEqualizerProfile;
     SetEcho(profile.EchoLevel);
     for (int i = 0; i < profile.Levels.Count(); i++)
         SetEQ(i, profile.Levels[i]);
 }