expose sound Format property + improve property setter ranges
parent
4591920bf6
commit
771e6c234b
|
@ -7,7 +7,9 @@ namespace MoonWorks.Audio
|
|||
public abstract class SoundInstance : AudioResource
|
||||
{
|
||||
internal IntPtr Voice;
|
||||
internal FAudio.FAudioWaveFormatEx Format;
|
||||
|
||||
private FAudio.FAudioWaveFormatEx format;
|
||||
public FAudio.FAudioWaveFormatEx Format => format;
|
||||
|
||||
protected FAudio.F3DAUDIO_DSP_SETTINGS dspSettings;
|
||||
|
||||
|
@ -24,6 +26,7 @@ namespace MoonWorks.Audio
|
|||
get => pan;
|
||||
internal set
|
||||
{
|
||||
value = Math.MathHelper.Clamp(value, -1f, 1f);
|
||||
if (pan != value)
|
||||
{
|
||||
pan = value;
|
||||
|
@ -58,9 +61,10 @@ namespace MoonWorks.Audio
|
|||
get => pitch;
|
||||
internal set
|
||||
{
|
||||
value = Math.MathHelper.Clamp(value, -1f, 1f);
|
||||
if (pitch != value)
|
||||
{
|
||||
pitch = Math.MathHelper.Clamp(value, -1f, 1f);
|
||||
pitch = value;
|
||||
UpdatePitch();
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +76,7 @@ namespace MoonWorks.Audio
|
|||
get => volume;
|
||||
internal set
|
||||
{
|
||||
value = Math.MathHelper.Max(0, value);
|
||||
if (volume != value)
|
||||
{
|
||||
volume = value;
|
||||
|
@ -95,9 +100,9 @@ namespace MoonWorks.Audio
|
|||
get => filterParameters.Frequency;
|
||||
internal set
|
||||
{
|
||||
value = System.Math.Clamp(value, 0.01f, MAX_FILTER_FREQUENCY);
|
||||
if (filterParameters.Frequency != value)
|
||||
{
|
||||
value = System.Math.Clamp(value, 0.01f, MAX_FILTER_FREQUENCY);
|
||||
filterParameters.Frequency = value;
|
||||
|
||||
FAudio.FAudioVoice_SetFilterParameters(
|
||||
|
@ -114,9 +119,9 @@ namespace MoonWorks.Audio
|
|||
get => filterParameters.OneOverQ;
|
||||
internal set
|
||||
{
|
||||
value = System.Math.Clamp(value, 0.01f, MAX_FILTER_ONEOVERQ);
|
||||
if (filterParameters.OneOverQ != value)
|
||||
{
|
||||
value = System.Math.Clamp(value, 0.01f, MAX_FILTER_ONEOVERQ);
|
||||
filterParameters.OneOverQ = value;
|
||||
|
||||
FAudio.FAudioVoice_SetFilterParameters(
|
||||
|
@ -181,6 +186,7 @@ namespace MoonWorks.Audio
|
|||
{
|
||||
if (ReverbEffect != null)
|
||||
{
|
||||
value = MathF.Max(0, value);
|
||||
if (reverb != value)
|
||||
{
|
||||
reverb = value;
|
||||
|
@ -221,7 +227,7 @@ namespace MoonWorks.Audio
|
|||
uint samplesPerSecond
|
||||
) : base(device)
|
||||
{
|
||||
var format = new FAudio.FAudioWaveFormatEx
|
||||
format = new FAudio.FAudioWaveFormatEx
|
||||
{
|
||||
wFormatTag = formatTag,
|
||||
wBitsPerSample = bitsPerSample,
|
||||
|
@ -231,12 +237,10 @@ namespace MoonWorks.Audio
|
|||
nAvgBytesPerSec = blockAlign * samplesPerSecond
|
||||
};
|
||||
|
||||
Format = format;
|
||||
|
||||
FAudio.FAudio_CreateSourceVoice(
|
||||
Device.Handle,
|
||||
out Voice,
|
||||
ref Format,
|
||||
ref format,
|
||||
FAudio.FAUDIO_VOICE_USEFILTER,
|
||||
FAudio.FAUDIO_DEFAULT_FREQ_RATIO,
|
||||
IntPtr.Zero,
|
||||
|
|
Loading…
Reference in New Issue