feat: StartOffset
- 实现startOffset - 修复EndOffset = 0 + 循环播放时,音乐会大量重复播放的错误。 - 增加数据校验和 BeatClock 联动。StartOffset不正确时停止bar+级 callback。 - BeatClock 现在会在每次重新播放时重启,以解决EndOffset配置错误被舍弃时,拍子对不上的问题。
This commit is contained in:
@@ -44,12 +44,12 @@ namespace OCES.Audio
|
||||
CurrentContainerId = containerId;
|
||||
CurrentVolume = startVolume;
|
||||
CurrentHandle = this.m_player.Play(containerId);
|
||||
Debug.Log($"[ChannelFader] StartNew: containerId={containerId}, CurrentHandle={CurrentHandle}");
|
||||
//Debug.Log($"[ChannelFader] StartNew: containerId={containerId}, CurrentHandle={CurrentHandle}");
|
||||
}
|
||||
|
||||
public void StopCurrent()
|
||||
{
|
||||
Debug.Log($"[ChannelFader] StopCurrent called! CurrentHandle={CurrentHandle}, stack=\n{Environment.StackTrace}");
|
||||
//Debug.Log($"[ChannelFader] StopCurrent called! CurrentHandle={CurrentHandle}, stack=\n{Environment.StackTrace}");
|
||||
StopHandle(CurrentHandle);
|
||||
CurrentHandle = null;
|
||||
CurrentContainerId = 0;
|
||||
@@ -79,10 +79,14 @@ namespace OCES.Audio
|
||||
}
|
||||
|
||||
if (transition?.FadeOutTime > 0f )
|
||||
{
|
||||
yield return this.m_coroutineHost.StartCoroutine(
|
||||
FadeOut(outgoingHandle, outgoingVolume, transition.FadeOutTime));
|
||||
}
|
||||
else
|
||||
{
|
||||
StopHandle(outgoingHandle);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -167,7 +171,7 @@ namespace OCES.Audio
|
||||
|
||||
IEnumerator FadeOut(ContainerPlayHandle handle, float fromVolume, float duration)
|
||||
{
|
||||
//Debug.Log($"Fading out in {duration} seconds.");
|
||||
// Debug.Log($"Fading out in {duration} seconds.");
|
||||
if (handle == null || handle.Cancelled) yield break;
|
||||
|
||||
float elapsed = 0f;
|
||||
@@ -202,10 +206,13 @@ namespace OCES.Audio
|
||||
if (src) src.volume = 0f;
|
||||
|
||||
StopHandle(handle);
|
||||
|
||||
// Debug.Log($"[ChannelFader] Faded out in {duration} seconds.");
|
||||
}
|
||||
|
||||
IEnumerator FadeIn(ContainerPlayHandle handle, float duration)
|
||||
{
|
||||
// Debug.Log($"Fading in in {duration} seconds.");
|
||||
if (handle == null || handle.Cancelled) yield break;
|
||||
|
||||
List<AudioSource> sources = new();
|
||||
@@ -242,8 +249,8 @@ namespace OCES.Audio
|
||||
if (src) src.volume = 1f;
|
||||
|
||||
CurrentVolume = 1f;
|
||||
|
||||
// Debug.Log($"[ChannelFader] Faded in in {duration} seconds.");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user