Ejemplo n.º 1
0
 void Awake()
 {
     singleton = this;
     SetGlobalBpm();
     Reset();
     Native.Pause(globalPause);
 }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            AudioHelmClock clock = target as AudioHelmClock;

            serialized.Update();
            clock.bpm = EditorGUILayout.Slider("BPM", clock.bpm, kMinBpm, kMaxBpm);
            serialized.ApplyModifiedProperties();
        }
Ejemplo n.º 3
0
        protected virtual void OnDisable()
        {
            AudioHelmClock clock = AudioHelmClock.GetInstance();

            if (clock)
            {
                clock.OnReset -= AllNotesOff;
            }
        }
Ejemplo n.º 4
0
        void DoUpdate()
        {
            double updateStartTime = AudioSettings.dspTime;

            UpdatePosition();

            if (AudioHelmClock.GetGlobalPause())
            {
                return;
            }

            double position      = GetSequencerTime();
            float  sixteenthTime = GetSixteenthTime();
            double currentTime   = GetSequencerPosition() * sixteenthTime;
            double sequencerTime = length * sixteenthTime;

            double windowMax = position + lookaheadTime / sixteenthTime;

            if (windowMax <= lastWindowTime)
            {
                lastWindowTime = windowMax;
                return;
            }

            if (WaitingForNextCycle())
            {
                lastWindowTime = windowMax;
                return;
            }

            double internalLastWindowMax = Mathf.Repeat((float)lastWindowTime, length);
            double internalWindowMax     = Mathf.Repeat((float)windowMax, length);

            float       startSearch = (float)internalLastWindowMax;
            float       endSearch   = (float)internalWindowMax;
            List <Note> notes       = GetAllNoteOnsInRange(startSearch, endSearch);

            foreach (Note note in notes)
            {
                double startTime = sixteenthTime * note.start;

                // Check if we wrapped around.
                if (startTime < currentTime)
                {
                    startTime += sequencerTime;
                }

                double endTime = startTime + sixteenthTime * (note.end - note.start);

                double timeToStart = startTime - currentTime + updateStartTime;
                double timeToEnd   = endTime - currentTime + updateStartTime;
                GetComponent <Sampler>().NoteOnScheduled(note.note, note.velocity, timeToStart, timeToEnd);
            }

            lastWindowTime = windowMax;
        }
Ejemplo n.º 5
0
        protected void UpdateBeatTime()
        {
            double globalBeatTime = AudioHelmClock.GetGlobalBeatTime();
            double bpm            = AudioHelmClock.GetGlobalBpm();
            double lastUpdate     = AudioHelmClock.GetLastSampledTime();

            double time = AudioSettings.dspTime;

            beatTime = globalBeatTime + bpm * (time - lastUpdate) / Utils.kSecondsPerMinute;
        }
Ejemplo n.º 6
0
        protected virtual void OnDisable()
        {
            AudioHelmClock clock = AudioHelmClock.GetInstance();

            if (clock)
            {
                clock.OnReset -= AllNotesOff;
            }
            waitTillNextCycle = false;
        }
Ejemplo n.º 7
0
        protected virtual void OnEnable()
        {
            AudioHelmClock clock = AudioHelmClock.GetInstance();

            if (clock)
            {
                clock.OnReset += AllNotesOff;
            }

            UpdateBeatTime();
            UpdateIndex();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Update the position of the sequencer and fire any events that have occurred.
        /// </summary>
        protected void UpdatePosition()
        {
            if (AudioHelmClock.GetGlobalPause())
            {
                if (!paused)
                {
                    AllNotesOff();
                }
                paused = true;
                return;
            }
            paused = false;

            UpdateBeatTime();
            UpdateIndex();
            float nextPosition = (float)GetSequencerPosition();

            if (nextPosition < 0.0f || nextPosition < lastSequencerPosition)
            {
                lastSequencerPosition = nextPosition;
                return;
            }

            List <Note> noteOns  = GetAllNoteOnsInRange(lastSequencerPosition, nextPosition);
            List <Note> noteOffs = GetAllNoteOffsInRange(lastSequencerPosition, nextPosition);

            int noteOnIndex  = 0;
            int noteOffIndex = 0;

            while (noteOnIndex < noteOns.Count && noteOffIndex < noteOffs.Count)
            {
                if (noteOns[noteOnIndex].start < noteOffs[noteOffIndex].end)
                {
                    SendNoteOn(noteOns[noteOnIndex++]);
                }
                else
                {
                    SendNoteOff(noteOffs[noteOffIndex++]);
                }
            }

            for (; noteOnIndex < noteOns.Count; ++noteOnIndex)
            {
                SendNoteOn(noteOns[noteOnIndex]);
            }

            for (; noteOffIndex < noteOffs.Count; ++noteOffIndex)
            {
                SendNoteOff(noteOffs[noteOffIndex]);
            }

            lastSequencerPosition = nextPosition;
        }
Ejemplo n.º 9
0
        protected virtual void OnEnable()
        {
            AudioHelmClock clock = AudioHelmClock.GetInstance();

            if (clock)
            {
                clock.OnReset += AllNotesOff;
            }

            UpdatePosition(false);
            AllNotesOff();
            activeNotes.Clear();
        }
Ejemplo n.º 10
0
 public override void Start()
 {
     clock = GameObject.Find("clock").GetComponent <AudioHelm.AudioHelmClock> ();
     base.Start();
     fpc            = _player.GetComponent <FirstPersonController>();
     cml            = Camera.main.GetComponent <camMouseLook>();
     fpc.isAwake    = true;
     interactable   = true;
     sleepCounter   = sleepLength;
     sun            = GameObject.FindGameObjectWithTag("Sun");
     sunScript      = sun.GetComponent <Sun>();
     sunStartPos    = sun.transform.position;
     wond           = GameObject.Find("windParticles").GetComponent <ParticleSystem> ();
     windBlast      = GameObject.Find("windBlast").GetComponent <ParticleSystem> ();
     originalPSpeed = fpc.speed;
 }
Ejemplo n.º 11
0
 void Start()
 {
     clock = FindObjectOfType <AudioHelmClock>();
     UpdateMoveSpeed(0.0f);
 }
Ejemplo n.º 12
0
 void Awake()
 {
     singleton = this;
     SetGlobalBpm();
     Reset();
 }
Ejemplo n.º 13
0
 protected double GetSequencerTime()
 {
     return((Utils.kBpmToSixteenths * AudioHelmClock.GetGlobalBpm()) * (AudioSettings.dspTime - syncTime));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Gets the time in seconds of a single sixteenth note in the sequencer.
 /// </summary>
 /// <returns>The time in seconds of a sixteenth note.</returns>
 public float GetSixteenthTime()
 {
     return(1.0f / (Utils.kBpmToSixteenths * AudioHelmClock.GetGlobalBpm()));
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Update the position of the sequencer and fire any events that have occurred.
        /// </summary>
        protected void UpdatePosition(bool sendEvents = true)
        {
            if (AudioHelmClock.GetGlobalPause())
            {
                if (!paused)
                {
                    AllNotesOff();
                }
                paused = true;
                return;
            }
            paused = false;

            UpdateBeatTime();
            UpdateIndex();
            float nextPosition = (float)GetSequencerPosition();

            int cycles = Mathf.FloorToInt((float)GetSequencerTime() / length);

            if (nextPosition < 0.0f || cycles < numCycles)
            {
                lastSequencerPosition = nextPosition;
                numCycles             = cycles;
                return;
            }

            if (cycles > numCycles)
            {
                numCycles         = cycles;
                waitTillNextCycle = false;
            }

            if (waitTillNextCycle || !sendEvents)
            {
                lastSequencerPosition = nextPosition;
                return;
            }

            List <Note> noteOns  = GetAllNoteOnsInRange(lastSequencerPosition, nextPosition);
            List <Note> noteOffs = GetAllNoteOffsInRange(lastSequencerPosition, nextPosition);

            int noteOnIndex  = 0;
            int noteOffIndex = 0;

            while (noteOnIndex < noteOns.Count && noteOffIndex < noteOffs.Count)
            {
                if (noteOns[noteOnIndex].start < noteOffs[noteOffIndex].end)
                {
                    SendNoteOn(noteOns[noteOnIndex++]);
                }
                else
                {
                    SendNoteOff(noteOffs[noteOffIndex++]);
                }
            }

            for (; noteOnIndex < noteOns.Count; ++noteOnIndex)
            {
                SendNoteOn(noteOns[noteOnIndex]);
            }

            for (; noteOffIndex < noteOffs.Count; ++noteOffIndex)
            {
                SendNoteOff(noteOffs[noteOffIndex]);
            }

            lastSequencerPosition = nextPosition;
        }