clear tweens on property hard set

pull/47/head
cosmonaut 2023-03-07 10:51:59 -08:00
parent 7014400d12
commit d17fb55810
3 changed files with 20 additions and 2 deletions

View File

@ -193,6 +193,16 @@ namespace MoonWorks.Audio
} }
} }
internal void ClearTweens(
WeakReference soundReference,
AudioTweenProperty property
) {
lock (StateLock)
{
AudioTweenManager.ClearTweens(soundReference, property);
}
}
internal void WakeThread() internal void WakeThread()
{ {
WakeSignal.Set(); WakeSignal.Set();

View File

@ -102,6 +102,11 @@ namespace MoonWorks.Audio
} }
} }
public void ClearTweens(WeakReference soundReference, AudioTweenProperty property)
{
AudioTweens.Remove((soundReference, property));
}
private void AddTween( private void AddTween(
AudioTween audioTween AudioTween audioTween
) { ) {

View File

@ -301,11 +301,10 @@ namespace MoonWorks.Audio
ReverbEffect = reverbEffect; ReverbEffect = reverbEffect;
} }
// TODO: since we're using setters now, could just get rid of the property setters
public void SetPan(float targetValue) public void SetPan(float targetValue)
{ {
Pan = targetValue; Pan = targetValue;
Device.ClearTweens(weakReference, AudioTweenProperty.Pan);
} }
public void SetPan(float targetValue, float duration, EasingFunction easingFunction) public void SetPan(float targetValue, float duration, EasingFunction easingFunction)
@ -321,6 +320,7 @@ namespace MoonWorks.Audio
public void SetPitch(float targetValue) public void SetPitch(float targetValue)
{ {
Pitch = targetValue; Pitch = targetValue;
Device.ClearTweens(weakReference, AudioTweenProperty.Pitch);
} }
public void SetPitch(float targetValue, float duration, EasingFunction easingFunction) public void SetPitch(float targetValue, float duration, EasingFunction easingFunction)
@ -336,6 +336,7 @@ namespace MoonWorks.Audio
public void SetVolume(float targetValue) public void SetVolume(float targetValue)
{ {
Volume = targetValue; Volume = targetValue;
Device.ClearTweens(weakReference, AudioTweenProperty.Volume);
} }
public void SetVolume(float targetValue, float duration, EasingFunction easingFunction) public void SetVolume(float targetValue, float duration, EasingFunction easingFunction)
@ -351,6 +352,7 @@ namespace MoonWorks.Audio
public void SetFilterFrequency(float targetValue) public void SetFilterFrequency(float targetValue)
{ {
FilterFrequency = targetValue; FilterFrequency = targetValue;
Device.ClearTweens(weakReference, AudioTweenProperty.FilterFrequency);
} }
public void SetFilterFrequency(float targetValue, float duration, EasingFunction easingFunction) public void SetFilterFrequency(float targetValue, float duration, EasingFunction easingFunction)
@ -371,6 +373,7 @@ namespace MoonWorks.Audio
public void SetReverb(float targetValue) public void SetReverb(float targetValue)
{ {
Reverb = targetValue; Reverb = targetValue;
Device.ClearTweens(weakReference, AudioTweenProperty.Reverb);
} }
public void SetReverb(float targetValue, float duration, EasingFunction easingFunction) public void SetReverb(float targetValue, float duration, EasingFunction easingFunction)