void Awake() { singleton = this; SetGlobalBpm(); Reset(); Native.Pause(globalPause); }
public override void OnInspectorGUI() { AudioHelmClock clock = target as AudioHelmClock; serialized.Update(); clock.bpm = EditorGUILayout.Slider("BPM", clock.bpm, kMinBpm, kMaxBpm); serialized.ApplyModifiedProperties(); }
protected virtual void OnDisable() { AudioHelmClock clock = AudioHelmClock.GetInstance(); if (clock) { clock.OnReset -= AllNotesOff; } }
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; }
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; }
protected virtual void OnDisable() { AudioHelmClock clock = AudioHelmClock.GetInstance(); if (clock) { clock.OnReset -= AllNotesOff; } waitTillNextCycle = false; }
protected virtual void OnEnable() { AudioHelmClock clock = AudioHelmClock.GetInstance(); if (clock) { clock.OnReset += AllNotesOff; } UpdateBeatTime(); UpdateIndex(); }
/// <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; }
protected virtual void OnEnable() { AudioHelmClock clock = AudioHelmClock.GetInstance(); if (clock) { clock.OnReset += AllNotesOff; } UpdatePosition(false); AllNotesOff(); activeNotes.Clear(); }
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; }
void Start() { clock = FindObjectOfType <AudioHelmClock>(); UpdateMoveSpeed(0.0f); }
void Awake() { singleton = this; SetGlobalBpm(); Reset(); }
protected double GetSequencerTime() { return((Utils.kBpmToSixteenths * AudioHelmClock.GetGlobalBpm()) * (AudioSettings.dspTime - syncTime)); }
/// <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())); }
/// <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; }