// Update is called once per frame
    void Update()
    {
        if (playing)
        {
            int audioReportedTime = rhythm.timeMillis();

            if (lastReportedTime != 0 && audioReportedTime == 0)              //song has ended
            {
                Messenger.Invoke(MessengerKeys.EVENT_PATTERN_FINISHED);
            }

            if (audioReportedTime != lastReportedTime)
            {
                long error = currentSongTime() - audioReportedTime;
//				Debug.Log (error);
                deltaLp.input((double)error);
                if (Math.Abs(error) > errorSynchThreshold && currentSongTime() > 0)                   //want to make sure pattern has already started
                {
                    pattern.startTime += error;
                    Debug.LogFormat("Adjusted time by {0}", error);
                }
            }


            debugPanel.log("MS", audioReportedTime.ToString());
//			Debug.Log (timeMaster.GetTime());

            if (deltaLp.updateReady())
            {
                debugPanel.log("Delta", deltaLp.output().ToString());
            }

//			Debug.LogFormat ("Delta: {0}", delta);
            //in case things go out of since
//			startTime = timeMaster.GetTime () - time;

            pattern.Process(timeMaster.GetTime(), processEvent);


            lastReportedTime = audioReportedTime;
        }
    }