feat: StartOffset

- 实现startOffset
- 修复EndOffset = 0 + 循环播放时,音乐会大量重复播放的错误。
- 增加数据校验和 BeatClock 联动。StartOffset不正确时停止bar+级 callback。
- BeatClock 现在会在每次重新播放时重启,以解决EndOffset配置错误被舍弃时,拍子对不上的问题。
This commit is contained in:
2026-05-12 15:47:04 +08:00
parent bb472da311
commit 8b6fabda12
10 changed files with 143 additions and 60 deletions
@@ -24,7 +24,7 @@ namespace OCES.Audio
/// 开始播放Container时触发 音乐回调系统
/// container本身,继承来的bpm,进入时刻的dspTime
/// </summary>
internal event Action<MusicContainer, float, double> OnContainerEntered;
internal event Action<MusicContainer, float, double> OnContainerEntered, OnContainerLooped;
internal event Action<MusicContainer> OnBlendError;
// Sequence Step 模式的全局游标,key = containerId
@@ -119,6 +119,7 @@ namespace OCES.Audio
if (handle.Cancelled) yield break;
loopsCompleted++;
OnContainerLooped?.Invoke(container, effectiveBpm, AudioSettings.dspTime);
// -1 = 无限循环,一直重复
if (container.LoopCount == -1)
@@ -352,6 +353,7 @@ namespace OCES.Audio
source.loop = false;
source.volume = volumeScale;
source.Play();
Debug.Log($"[LongAudioContainerPlayer] Playing {segment.Name} at {AudioSettings.dspTime}");
if (isLoop && segment.StartOffset > 0)
{