public void Play(int delay) { pattern.Play(timeMaster.GetTime() + delay); patternVisualizer.reset(); scoreCalculator.reset(); playing = true; paused = false; }
public AverageTimer(TimeMaster timeMaster, int reportInterval, string name) { this.timeMaster = timeMaster; this.reportInterval = reportInterval; this.name = name; this.lastReportTime = timeMaster.GetTime(); }
public void Play() { Debug.Log("Playing"); TimeMaster time = TimeMaster.Instance; int delay = 1; music.playFromBeginning(delay); calibrator.Play(delay * 1000 + time.GetTime()); }
// Update is called once per frame void Update() { for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); Vector2 pos = touch.position; float x = Camera.main.ScreenToWorldPoint(new Vector3(pos.x, pos.y, 0)).x; StandardKeyCodes key = KeyMappings.reverseMap [getControl(x)]; Debug.LogFormat("Key {0}", key); if (touch.phase == TouchPhase.Began) { downs [key] = timeMaster.GetTime(); Debug.LogFormat("X down {0}", x); } else if (touch.phase == TouchPhase.Ended) { ups [key] = timeMaster.GetTime(); Debug.LogFormat("X up {0}", x); } } }
// Update is called once per frame void Update() { long musicTime = mainMusic.timeMillis(); if (prevTime != musicTime) { prevTime = musicTime; long songTime = timeMaster.GetTime() - startTime; long error = songTime - musicTime; startTime += error / 2; debugPanel.log("Drift", error.ToString()); } }
void PollKeysMac() { while (UseRealTimeInput) { averageTimer.startRecording(); // UnityEngine.Debug.Log (timeMaster.GetTime()); // bool aPressed = CGEventSourceKeyState (1, 0); // UnityEngine.Debug.Log (CGEventSourceKeyState(1, 0)); // stopwatch.Reset(); // if (listener != null) { for (int i = 0; i < trackedKeys.Count; i++) { StandardKeyCodes keyCodeStandard = trackedKeys [i]; int keyCode = KeyConverter.ToMacNative(keyCodeStandard); bool keyPressed = CGEventSourceKeyState(1, keyCode); bool prevKeyStatus = keyStates [keyCode]; // UnityEngine.Debug.Log (keyPressed); if (keyPressed && !prevKeyStatus) //going from false to true // listener.onKeyDown (keyCode, timeMaster.GetTime()); { keyDowns[keyCodeStandard] = timeMaster.GetTime(); } else if (!keyPressed && prevKeyStatus) { // listener.onKeyUp (keyCode, timeMaster.GetTime()); keyUps[keyCodeStandard] = timeMaster.GetTime(); } keyStates [keyCode] = keyPressed; } long avg = averageTimer.stopRecording(); if (avg != -1) { // UnityEngine.Debug.Log(avg); if (debugPanel) { debugPanel.log("Input", avg.ToString()); } // debugPanel.log ("Input", avg.ToString()); } Thread.Sleep(sleepTime); } }
public void startRecording() { startTime = timeMaster.GetTime(); }