diff --git a/Assets/Scripts/OCES/Audio/HandWritten/AudioSystem.cs b/Assets/Scripts/OCES/Audio/HandWritten/AudioSystem.cs index 536ebae..fc0312f 100644 --- a/Assets/Scripts/OCES/Audio/HandWritten/AudioSystem.cs +++ b/Assets/Scripts/OCES/Audio/HandWritten/AudioSystem.cs @@ -29,7 +29,6 @@ namespace OCES.Audio // ───────────────────────────────────────────── public event Action OnBeat; - public event Action OnBar; public event Action OnGrid; @@ -196,10 +195,13 @@ namespace OCES.Audio EnumIds.RegisterAllGameState(); ActiveStates = new Dictionary(); - + } + + void Start() + { // ── 启动默认音乐与环境音 ── // 触发一次初始状态,让音乐系统从默认状态开始匹配 - //SetState(GameState.Home); + SetState(GameState.Home); } AudioObject ResolveSwitchContainer(AudioObject switchContainer) diff --git a/Assets/Scripts/OCES/Audio/HandWritten/LongAudio/BeatClock.cs b/Assets/Scripts/OCES/Audio/HandWritten/LongAudio/BeatClock.cs index f3155d3..af0f2e0 100644 --- a/Assets/Scripts/OCES/Audio/HandWritten/LongAudio/BeatClock.cs +++ b/Assets/Scripts/OCES/Audio/HandWritten/LongAudio/BeatClock.cs @@ -28,7 +28,7 @@ namespace OCES.Audio public void Restart(MusicContainer container, float inheritedBpm, double dspTime) { - Debug.Log($"[BeatClock] Restart called, container={container.Id}, bpm={container.Bpm}, inherited={inheritedBpm}"); + //Debug.Log($"[BeatClock] Restart called, container={container.Id}, bpm={container.Bpm}, inherited={inheritedBpm}"); StopAll(); this.m_blendError = this.m_stopped = false; @@ -69,21 +69,15 @@ namespace OCES.Audio while (true) { double nextTime = this.m_startDspTime + index * this.m_secondsPerBeat; - if (index == 0) - { - Debug.Log($"[BeatClock] BeatCoroutine waiting, nextTime={nextTime}, now={AudioSettings.dspTime}"); - } yield return new WaitUntil(() => AudioSettings.dspTime >= nextTime - 0.02); while (AudioSettings.dspTime < nextTime) yield return null; if (this.m_blendError || this.m_stopped){ - Debug.Log($"[BeatClock] Coroutine exiting early, blendError={m_blendError}, stopped={m_stopped}"); yield break; } this.m_onBeat?.Invoke(this.m_containerId); - Debug.Log($"[Beat] index={index}, nextTime={nextTime:F4}, actualDspTime={AudioSettings.dspTime:F4}, diff={(AudioSettings.dspTime - nextTime)*1000:F1}ms"); index++; } } @@ -99,7 +93,6 @@ namespace OCES.Audio while (AudioSettings.dspTime < nextTime) yield return null; if (this.m_blendError || this.m_stopped){ - Debug.Log($"[BeatClock] Coroutine exiting early, blendError={m_blendError}, stopped={m_stopped}"); yield break; } this.m_onBar?.Invoke(this.m_containerId); @@ -118,7 +111,6 @@ namespace OCES.Audio while (AudioSettings.dspTime < nextTime) yield return null; if (this.m_blendError || this.m_stopped){ - Debug.Log($"[BeatClock] Coroutine exiting early, blendError={m_blendError}, stopped={m_stopped}"); yield break; } this.m_onGrid?.Invoke(this.m_containerId); diff --git a/Assets/Scripts/OCES/Audio/HandWritten/LongAudio/MusicContainerPlayer.cs b/Assets/Scripts/OCES/Audio/HandWritten/LongAudio/MusicContainerPlayer.cs index cf2d4fb..2949311 100644 --- a/Assets/Scripts/OCES/Audio/HandWritten/LongAudio/MusicContainerPlayer.cs +++ b/Assets/Scripts/OCES/Audio/HandWritten/LongAudio/MusicContainerPlayer.cs @@ -105,7 +105,7 @@ namespace OCES.Audio Action onFinished) { float effectiveBpm = container.Bpm > 0f ? container.Bpm : inheritedBpm; - Debug.Log($"[MusicContainerPlayer] OnContainerEntered firing, container={container.Id}, subscribers={OnContainerEntered != null}"); + //Debug.Log($"[MusicContainerPlayer] OnContainerEntered firing, container={container.Id}, subscribers={OnContainerEntered != null}"); OnContainerEntered?.Invoke(container, effectiveBpm, AudioSettings.dspTime); int loopsCompleted = 0; diff --git a/Assets/Scripts/OCES/CallBackTest.cs b/Assets/Scripts/OCES/Metronome.cs similarity index 93% rename from Assets/Scripts/OCES/CallBackTest.cs rename to Assets/Scripts/OCES/Metronome.cs index 4f25a5b..b495ae9 100644 --- a/Assets/Scripts/OCES/CallBackTest.cs +++ b/Assets/Scripts/OCES/Metronome.cs @@ -3,7 +3,7 @@ using UnityEngine; namespace OCES { - public class CallBackTest : MonoBehaviour + public class Metronome : MonoBehaviour { void Start() { diff --git a/Assets/Scripts/OCES/CallBackTest.cs.meta b/Assets/Scripts/OCES/Metronome.cs.meta similarity index 100% rename from Assets/Scripts/OCES/CallBackTest.cs.meta rename to Assets/Scripts/OCES/Metronome.cs.meta