From 1bff459be6a93317ce230084034a7d3e1566f068 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Tue, 12 Sep 2023 15:24:45 -0700 Subject: [PATCH] move default reverb params to a static var --- src/Audio/ReverbEffect.cs | 67 ++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/src/Audio/ReverbEffect.cs b/src/Audio/ReverbEffect.cs index fd3950c4..995c3c28 100644 --- a/src/Audio/ReverbEffect.cs +++ b/src/Audio/ReverbEffect.cs @@ -8,6 +8,33 @@ namespace MoonWorks.Audio /// public unsafe class ReverbEffect : SubmixVoice { + // Defaults based on FAUDIOFX_I3DL2_PRESET_GENERIC + public static FAudio.FAudioFXReverbParameters DefaultParams = new FAudio.FAudioFXReverbParameters + { + WetDryMix = 100.0f, + ReflectionsDelay = 7, + ReverbDelay = 11, + RearDelay = FAudio.FAUDIOFX_REVERB_DEFAULT_REAR_DELAY, + PositionLeft = FAudio.FAUDIOFX_REVERB_DEFAULT_POSITION, + PositionRight = FAudio.FAUDIOFX_REVERB_DEFAULT_POSITION, + PositionMatrixLeft = FAudio.FAUDIOFX_REVERB_DEFAULT_POSITION_MATRIX, + PositionMatrixRight = FAudio.FAUDIOFX_REVERB_DEFAULT_POSITION_MATRIX, + EarlyDiffusion = 15, + LateDiffusion = 15, + LowEQGain = 8, + LowEQCutoff = 4, + HighEQGain = 8, + HighEQCutoff = 6, + RoomFilterFreq = 5000f, + RoomFilterMain = -10f, + RoomFilterHF = -1f, + ReflectionsGain = -26.0200005f, + ReverbGain = 10.0f, + DecayTime = 1.49000001f, + Density = 100.0f, + RoomSize = FAudio.FAUDIOFX_REVERB_DEFAULT_ROOM_SIZE + }; + public ReverbEffect(AudioDevice audioDevice, uint processingStage) : base(audioDevice, 1, audioDevice.DeviceDetails.OutputFormat.Format.nSamplesPerSec, processingStage) { /* Init reverb */ @@ -15,11 +42,12 @@ namespace MoonWorks.Audio FAudio.FAudioCreateReverb(out reverb, 0); var chain = new FAudio.FAudioEffectChain(); - var descriptor = new FAudio.FAudioEffectDescriptor(); - - descriptor.InitialState = 1; - descriptor.OutputChannels = 1; - descriptor.pEffect = reverb; + var descriptor = new FAudio.FAudioEffectDescriptor + { + InitialState = 1, + OutputChannels = 1, + pEffect = reverb + }; chain.EffectCount = 1; chain.pEffectDescriptors = (nint) (&descriptor); @@ -31,34 +59,7 @@ namespace MoonWorks.Audio FAudio.FAPOBase_Release(reverb); - /* Init reverb params */ - // Defaults based on FAUDIOFX_I3DL2_PRESET_GENERIC - - FAudio.FAudioFXReverbParameters reverbParams; - reverbParams.WetDryMix = 100.0f; - reverbParams.ReflectionsDelay = 7; - reverbParams.ReverbDelay = 11; - reverbParams.RearDelay = FAudio.FAUDIOFX_REVERB_DEFAULT_REAR_DELAY; - reverbParams.PositionLeft = FAudio.FAUDIOFX_REVERB_DEFAULT_POSITION; - reverbParams.PositionRight = FAudio.FAUDIOFX_REVERB_DEFAULT_POSITION; - reverbParams.PositionMatrixLeft = FAudio.FAUDIOFX_REVERB_DEFAULT_POSITION_MATRIX; - reverbParams.PositionMatrixRight = FAudio.FAUDIOFX_REVERB_DEFAULT_POSITION_MATRIX; - reverbParams.EarlyDiffusion = 15; - reverbParams.LateDiffusion = 15; - reverbParams.LowEQGain = 8; - reverbParams.LowEQCutoff = 4; - reverbParams.HighEQGain = 8; - reverbParams.HighEQCutoff = 6; - reverbParams.RoomFilterFreq = 5000f; - reverbParams.RoomFilterMain = -10f; - reverbParams.RoomFilterHF = -1f; - reverbParams.ReflectionsGain = -26.0200005f; - reverbParams.ReverbGain = 10.0f; - reverbParams.DecayTime = 1.49000001f; - reverbParams.Density = 100.0f; - reverbParams.RoomSize = FAudio.FAUDIOFX_REVERB_DEFAULT_ROOM_SIZE; - - SetParams(reverbParams); + SetParams(DefaultParams); } public void SetParams(in FAudio.FAudioFXReverbParameters reverbParams)