avoid calling into FAudio if property did not change
parent
d69f62d2ce
commit
4d41d230af
|
@ -24,28 +24,31 @@ namespace MoonWorks.Audio
|
|||
get => pan;
|
||||
internal set
|
||||
{
|
||||
pan = value;
|
||||
|
||||
if (pan < -1f)
|
||||
if (pan != value)
|
||||
{
|
||||
pan = -1f;
|
||||
}
|
||||
if (pan > 1f)
|
||||
{
|
||||
pan = 1f;
|
||||
}
|
||||
pan = value;
|
||||
|
||||
if (Is3D) { return; }
|
||||
if (pan < -1f)
|
||||
{
|
||||
pan = -1f;
|
||||
}
|
||||
if (pan > 1f)
|
||||
{
|
||||
pan = 1f;
|
||||
}
|
||||
|
||||
SetPanMatrixCoefficients();
|
||||
FAudio.FAudioVoice_SetOutputMatrix(
|
||||
Voice,
|
||||
Device.MasteringVoice,
|
||||
dspSettings.SrcChannelCount,
|
||||
dspSettings.DstChannelCount,
|
||||
dspSettings.pMatrixCoefficients,
|
||||
0
|
||||
);
|
||||
if (Is3D) { return; }
|
||||
|
||||
SetPanMatrixCoefficients();
|
||||
FAudio.FAudioVoice_SetOutputMatrix(
|
||||
Voice,
|
||||
Device.MasteringVoice,
|
||||
dspSettings.SrcChannelCount,
|
||||
dspSettings.DstChannelCount,
|
||||
dspSettings.pMatrixCoefficients,
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,8 +58,11 @@ namespace MoonWorks.Audio
|
|||
get => pitch;
|
||||
internal set
|
||||
{
|
||||
pitch = Math.MathHelper.Clamp(value, -1f, 1f);
|
||||
UpdatePitch();
|
||||
if (pitch != value)
|
||||
{
|
||||
pitch = Math.MathHelper.Clamp(value, -1f, 1f);
|
||||
UpdatePitch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,8 +72,11 @@ namespace MoonWorks.Audio
|
|||
get => volume;
|
||||
internal set
|
||||
{
|
||||
volume = value;
|
||||
FAudio.FAudioVoice_SetVolume(Voice, volume, 0);
|
||||
if (volume != value)
|
||||
{
|
||||
volume = value;
|
||||
FAudio.FAudioVoice_SetVolume(Voice, volume, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,14 +95,17 @@ namespace MoonWorks.Audio
|
|||
get => filterParameters.Frequency;
|
||||
internal set
|
||||
{
|
||||
value = System.Math.Clamp(value, 0.01f, MAX_FILTER_FREQUENCY);
|
||||
filterParameters.Frequency = value;
|
||||
if (filterParameters.Frequency != value)
|
||||
{
|
||||
value = System.Math.Clamp(value, 0.01f, MAX_FILTER_FREQUENCY);
|
||||
filterParameters.Frequency = value;
|
||||
|
||||
FAudio.FAudioVoice_SetFilterParameters(
|
||||
Voice,
|
||||
ref filterParameters,
|
||||
0
|
||||
);
|
||||
FAudio.FAudioVoice_SetFilterParameters(
|
||||
Voice,
|
||||
ref filterParameters,
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,37 +131,40 @@ namespace MoonWorks.Audio
|
|||
get => filterType;
|
||||
set
|
||||
{
|
||||
filterType = value;
|
||||
|
||||
switch (filterType)
|
||||
if (filterType != value)
|
||||
{
|
||||
case FilterType.None:
|
||||
filterParameters = new FAudio.FAudioFilterParameters
|
||||
{
|
||||
Type = FAudio.FAudioFilterType.FAudioLowPassFilter,
|
||||
Frequency = 1f,
|
||||
OneOverQ = 1f
|
||||
};
|
||||
break;
|
||||
filterType = value;
|
||||
|
||||
case FilterType.LowPass:
|
||||
filterParameters.Type = FAudio.FAudioFilterType.FAudioLowPassFilter;
|
||||
break;
|
||||
switch (filterType)
|
||||
{
|
||||
case FilterType.None:
|
||||
filterParameters = new FAudio.FAudioFilterParameters
|
||||
{
|
||||
Type = FAudio.FAudioFilterType.FAudioLowPassFilter,
|
||||
Frequency = 1f,
|
||||
OneOverQ = 1f
|
||||
};
|
||||
break;
|
||||
|
||||
case FilterType.BandPass:
|
||||
filterParameters.Type = FAudio.FAudioFilterType.FAudioBandPassFilter;
|
||||
break;
|
||||
case FilterType.LowPass:
|
||||
filterParameters.Type = FAudio.FAudioFilterType.FAudioLowPassFilter;
|
||||
break;
|
||||
|
||||
case FilterType.HighPass:
|
||||
filterParameters.Type = FAudio.FAudioFilterType.FAudioHighPassFilter;
|
||||
break;
|
||||
case FilterType.BandPass:
|
||||
filterParameters.Type = FAudio.FAudioFilterType.FAudioBandPassFilter;
|
||||
break;
|
||||
|
||||
case FilterType.HighPass:
|
||||
filterParameters.Type = FAudio.FAudioFilterType.FAudioHighPassFilter;
|
||||
break;
|
||||
}
|
||||
|
||||
FAudio.FAudioVoice_SetFilterParameters(
|
||||
Voice,
|
||||
ref filterParameters,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
FAudio.FAudioVoice_SetFilterParameters(
|
||||
Voice,
|
||||
ref filterParameters,
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,23 +176,26 @@ namespace MoonWorks.Audio
|
|||
{
|
||||
if (ReverbEffect != null)
|
||||
{
|
||||
reverb = value;
|
||||
|
||||
float* outputMatrix = (float*) dspSettings.pMatrixCoefficients;
|
||||
outputMatrix[0] = reverb;
|
||||
if (dspSettings.SrcChannelCount == 2)
|
||||
if (reverb != value)
|
||||
{
|
||||
outputMatrix[1] = reverb;
|
||||
}
|
||||
reverb = value;
|
||||
|
||||
FAudio.FAudioVoice_SetOutputMatrix(
|
||||
Voice,
|
||||
ReverbEffect.Voice,
|
||||
dspSettings.SrcChannelCount,
|
||||
1,
|
||||
dspSettings.pMatrixCoefficients,
|
||||
0
|
||||
);
|
||||
float* outputMatrix = (float*) dspSettings.pMatrixCoefficients;
|
||||
outputMatrix[0] = reverb;
|
||||
if (dspSettings.SrcChannelCount == 2)
|
||||
{
|
||||
outputMatrix[1] = reverb;
|
||||
}
|
||||
|
||||
FAudio.FAudioVoice_SetOutputMatrix(
|
||||
Voice,
|
||||
ReverbEffect.Voice,
|
||||
dspSettings.SrcChannelCount,
|
||||
1,
|
||||
dspSettings.pMatrixCoefficients,
|
||||
0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
|
|
Loading…
Reference in New Issue