feature: change playing sound property
This commit is contained in:
@@ -99,6 +99,62 @@ namespace OCES.Audio
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetVolume(uint audioId, float targetVolume)
|
||||
{
|
||||
List<ActiveSound> targets = this.m_activeSounds.FindAll(activeSound => activeSound.AudioObject.Id == audioId);
|
||||
foreach (ActiveSound target in targets)
|
||||
{
|
||||
target.Volume = targetVolume;
|
||||
if (target.Source)
|
||||
{
|
||||
target.Source.volume = targetVolume;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetPitch(uint audioId, float targetPitch)
|
||||
{
|
||||
List<ActiveSound> targets = this.m_activeSounds.FindAll(activeSound => activeSound.AudioObject.Id == audioId);
|
||||
foreach (ActiveSound target in targets)
|
||||
{
|
||||
target.Pitch = targetPitch;
|
||||
if (target.Source)
|
||||
{
|
||||
target.Source.pitch = targetPitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void ResetVolume(uint audioId)
|
||||
{
|
||||
double now = Time.realtimeSinceStartupAsDouble * 1000.0;
|
||||
List<ActiveSound> targets = this.m_activeSounds.FindAll(activeSound => activeSound.AudioObject.Id == audioId);
|
||||
foreach (ActiveSound target in targets)
|
||||
{
|
||||
float defaultVolume = this.m_volumeStepResolver.ResolveVolume(target.AudioObject, now);
|
||||
target.Volume = defaultVolume;
|
||||
if (target.Source)
|
||||
{
|
||||
target.Source.volume = defaultVolume;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal void ResetPitch(uint audioId)
|
||||
{
|
||||
double now = Time.realtimeSinceStartupAsDouble * 1000.0;
|
||||
List<ActiveSound> targets = this.m_activeSounds.FindAll(activeSound => activeSound.AudioObject.Id == audioId);
|
||||
foreach (ActiveSound target in targets)
|
||||
{
|
||||
float defaultPitch = this.m_pitchStepResolver.ResolvePitch(target.AudioObject, now);
|
||||
target.Pitch = defaultPitch;
|
||||
if (target.Source != null)
|
||||
{
|
||||
target.Source.pitch = defaultPitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// 节流 & 调度入口
|
||||
// ─────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user