// Use this for initialization
 void Start()
 {
     filter             = this.gameObject.GetComponent <AudioReverbFilter>();
     target             = this.GetComponentInChildren <AudioListener>();
     averagedVerbParams = this.GetComponent <ReverbParameters> ();
     SetUp();
 }
Beispiel #2
0
        //private void LoadReverb(BASS_DX8_REVERB reverb) {
        //  trkGain.Value = FXToTrk(reverb.fInGain, ReverbMinMax.GainMin, ReverbMinMax.GainMax);
        //  trkMix.Value = FXToTrk(reverb.fReverbMix, ReverbMinMax.MixMin, ReverbMinMax.MixMax);
        //  trkTime.Value = FXToTrk(reverb.fReverbTime, ReverbMinMax.TimeMin, ReverbMinMax.TimeMax);
        //  trkHFRT.Value = FXToTrk(reverb.fHighFreqRTRatio, ReverbMinMax.HFRTMin, ReverbMinMax.HFRTMax);
        //}

        private void LoadFreeverb(ReverbParameters freeverb)
        {
            trkDryMix.Value   = FXToTrk(freeverb.fDryMix, FreeverbMinMax.DryMixMin, FreeverbMinMax.DryMixMax);
            trkWetMix.Value   = FXToTrk(freeverb.fWetMix, FreeverbMinMax.WetMixMin, FreeverbMinMax.WetMixMax);
            trkRoomSize.Value = FXToTrk(freeverb.fRoomSize, FreeverbMinMax.RoomSizeMin, FreeverbMinMax.RoomSizeMax);
            trkDamp.Value     = FXToTrk(freeverb.fDamp, FreeverbMinMax.DampMin, FreeverbMinMax.DampMax);
            trkWidth.Value    = FXToTrk(freeverb.fWidth, FreeverbMinMax.WidthMin, FreeverbMinMax.WidthMax);
        }
Beispiel #3
0
        /// <summary>
        /// Sets the Reverb effect parameters.
        /// </summary>
        /// <param name="parameters">The reverb effect parameters.</param>
        /// /// <exception cref="ObjectDisposedException">Is thrown when this instance was already disposed.</exception>
        public void SetReverbEffectParameters(ReverbParameters parameters)
        {
            DisposeGuard();

            reverbParameters = parameters;

            if (ReverbVoice != null && reverb != null)
            {
                ReverbVoice.SetEffectParameters(0, parameters);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AudioManager" /> class.
        /// </summary>
        /// <param name="game">The game.</param>
        public AudioManager(Game game)
            : base(game)
        {
            Services.AddService(this);
            masterVolume = 1.0f;
            Speakers     = Speakers.None;
            masteringLimiterParameters = new MasteringLimiterParameters {
                Loudness = MasteringLimiter.DefaultLoudness, Release = MasteringLimiter.DefaultRelease
            };
            reverbParameters = (ReverbParameters)ReverbI3DL2Parameters.Presets.Default;

            InstancePool = new SoundEffectInstancePool(this);

            // register the audio manager as game system
            game.GameSystems.Add(this);
        }
Beispiel #5
0
    public static ReverbParameters ReverbConvertI3DL2ToNative(ReverbI3DL2Parameters I3DL2Parameters, bool sevenDotOneReverb = true)
    {
        ReverbParameters result = new ReverbParameters();

        float reflectionsDelay;
        float reverbDelay;

        // RoomRolloffFactor is ignored

        // These parameters have no equivalent in I3DL2
        if (sevenDotOneReverb)
        {
            result.RearDelay = ReverbDefault7Point1RearDelay; // 20
        }
        else
        {
            result.RearDelay = ReverbDefaultRearDelay; // 5
        }

        result.SideDelay           = ReverbDefault7Point1SideDelay; // 5
        result.PositionLeft        = ReverbDefaultPosition;         // 6
        result.PositionRight       = ReverbDefaultPosition;         // 6
        result.PositionMatrixLeft  = ReverbDefaultPositionMatrix;   // 27
        result.PositionMatrixRight = ReverbDefaultPositionMatrix;   // 27
        result.RoomSize            = ReverbDefaultRoomSize;         // 100
        result.LowEQCutoff         = 4;
        result.HighEQCutoff        = 6;

        // The rest of the I3DL2 parameters map to the native property set
        result.RoomFilterMain = (float)I3DL2Parameters.Room / 100.0f;
        result.RoomFilterHF   = (float)I3DL2Parameters.RoomHF / 100.0f;

        if (I3DL2Parameters.DecayHFRatio >= 1.0f)
        {
            int index = (int)(-4.0 * Math.Log10(I3DL2Parameters.DecayHFRatio));
            if (index < -8)
            {
                index = -8;
            }
            result.LowEQGain  = (byte)((index < 0) ? index + 8 : 8);
            result.HighEQGain = 8;
            result.DecayTime  = I3DL2Parameters.DecayTime * I3DL2Parameters.DecayHFRatio;
        }
        else
        {
            int index = (int)(4.0 * Math.Log10(I3DL2Parameters.DecayHFRatio));
            if (index < -8)
            {
                index = -8;
            }
            result.LowEQGain  = 8;
            result.HighEQGain = (byte)((index < 0) ? index + 8 : 8);
            result.DecayTime  = I3DL2Parameters.DecayTime;
        }

        reflectionsDelay = I3DL2Parameters.ReflectionsDelay * 1000.0f;
        if (reflectionsDelay >= ReverbMaxReflectionsDelay) // 300
        {
            reflectionsDelay = (float)(ReverbMaxReflectionsDelay - 1);
        }
        else if (reflectionsDelay <= 1)
        {
            reflectionsDelay = 1;
        }
        result.ReflectionsDelay = (int)reflectionsDelay;

        reverbDelay = I3DL2Parameters.ReverbDelay * 1000.0f;
        if (reverbDelay >= ReverbMaxReverbDelay) // 85
        {
            reverbDelay = (float)(ReverbMaxReverbDelay - 1);
        }
        result.ReverbDelay = (byte)reverbDelay;

        result.ReflectionsGain  = I3DL2Parameters.Reflections / 100.0f;
        result.ReverbGain       = I3DL2Parameters.Reverb / 100.0f;
        result.EarlyDiffusion   = (byte)(15.0f * I3DL2Parameters.Diffusion / 100.0f);
        result.LateDiffusion    = result.EarlyDiffusion;
        result.Density          = I3DL2Parameters.Density;
        result.RoomFilterFreq   = I3DL2Parameters.HFReference;
        result.WetDryMix        = I3DL2Parameters.WetDryMix;
        result.DisableLateField = false;

        return(result);
    }
Beispiel #6
0
 public unsafe Result SetEffectParameters(int effectIndex, ReverbI3DL2Parameters reverbParameters, bool sevenDotOneReverb = true, int operationSet = 0)
 {
     ReverbParameters reverbParametersNative = Fx.Fx.ReverbConvertI3DL2ToNative(reverbParameters, sevenDotOneReverb);
     return SetEffectParameters(effectIndex, new IntPtr(&reverbParametersNative), sizeof(ReverbParameters), operationSet);
 }
Beispiel #7
0
 public unsafe Result SetEffectParameters(int effectIndex, ReverbParameters reverbParameters, int operationSet = 0)
 {
     return SetEffectParameters(effectIndex, new IntPtr(&reverbParameters), sizeof(ReverbParameters), operationSet);
 }