I don't think the parameter structure (lpf) needs to be global, so you could try moving that into the function and see if that makes any difference:
BASS_BFX_LPF lpf = new BASS_BFX_LPF(2f, 300f, BASSFXChan.BASS_BFX_CHANALL);
If the problem still happens, for comparison, what happens if you instead try using one of BASS's built-in effects, eg. BASS_FX_DX8_PARAMEQ?
HI Ian. I tried making the parameter structure local and then tried switching to a built-in effect as suggested. Similar issue, except now it's throwing the exception within BASS_FXGetParametersExt . Is there some kind of premarashling I can do for the object?
Cannot marshal type 'System.Object'. at Un4seen.Bass.Bass.BASS_FXGetParametersExt (System.Int32 handle, System.Object par) [0x00000] in <00000000000000000000000000000000>:0
at Un4seen.Bass.Bass.BASS_FXSetParameters (System.Int32 handle, System.Object par) [0x00000] in <00000000000000000000000000000000>:0
at Consortya.AudioTools.Effects.LowPassFilterEffect.AddEffect (System.Int32 stream) [0x00000] in <00000000000000000000000000000000>:0
at Consortya.AudioTools.IceListener.BufferStreamAndPlay () [0x00000] in <00000000000000000000000000000000>:0
at Consortya.AudioTools.IceListener.PlayThread () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ParameterizedThreadStart.Invoke (System.Object obj) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
Consortya.AudioTools.Effects.LowPassFilterEffect:AddEffect(Int32)
Consortya.AudioTools.IceListener:BufferStreamAndPlay()
Consortya.AudioTools.IceListener:PlayThread()
UnityEngine.Events.UnityAction:Invoke()
System.Threading.ParameterizedThreadStart:Invoke(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object)
UnityEngine.Events.UnityAction:Invoke()
public void AddEffect(int stream)
{
try
{
if (stream == 0)
{
Debug.Log("unable to apply filter to stream 0");
return;
}
RemoveEffect(stream);
var eq = new BASS_DX8_PARAMEQ();
filterHandle = Bass.BASS_ChannelSetFX(stream, BASSFXType.BASS_FX_DX8_PARAMEQ, 1);
if (filterHandle == 0)
{
Debug.LogError($"BASS_ChannelSetFX error code {Bass.BASS_ErrorGetCode()}");
return;
}
bool success = Bass.BASS_FXSetParameters(filterHandle, eq);
if(!success)
{
Debug.LogError($"BASS_FXSetParameters error code {Bass.BASS_ErrorGetCode()}");
}
}
catch(Exception ex)
{
Debug.LogError(ex.Message + ex.StackTrace);
}
}