public double ReturnAtNext(BeatValue next) { switch (next) { case (BeatValue.Measure): return(AtNextMeasure()); case (BeatValue.Whole): return(AtNextWhole()); case (BeatValue.Half): return(AtNextHalf()); case (BeatValue.Quarter): return(AtNextQuarter()); case (BeatValue.Eighth): return(AtNextEighth()); case (BeatValue.Sixteenth): return(AtNextSixteenth()); case (BeatValue.ThirtySecond): return(AtNextThirtySecond()); } return(0.0d); }
void Start() { beatValue = BeatValue.EighthBeat; beatInSamples = TempoUtils.instance.GetBeatInSamples(beatValue); beatInSequence = 0; //Debug.Log(beatInSamples); }
IEnumerator YieldForSync(System.Action callback, BeatValue beatValue) { int startCount = _thirtySecondCount % 32; bool isStartNote = true; bool waiting = true; while (waiting) { isStartNote = (isStartNote && startCount == (_thirtySecondCount % 32)); if (isStartNote) { yield return(false); } isStartNote = false; if (beatValue == BeatValue.ThirtySecond || (_thirtySecondCount % 32) % (int)beatValue == 1) { waiting = false; } else { yield return(false); } } callback(); }
public void SetObjectsReferences() { offset = 60f / (MusicController.bpm * BeatDecimalValues.values[(int)beatOffset]); patternController.SetOffsetTolerance(); Player.PatternSynchNumber = (int)LineSync; playerSpeed = Player.attackSpeed; }
public T this[BeatValue i] { get { return(_beatMaskArr[(int)i]); } set { _beatMaskArr[(int)i] = value; } }
public BeatArgs(BeatValue beatVal, int beatCount, double beatTime, double nextBeatTime, bool[] beatMask) { BeatVal = beatVal; BeatCount = beatCount; BeatTime = beatTime; NextBeatTime = nextBeatTime; BeatMask = beatMask; }
public void Stop(BeatValue beat) { if (AssertExpired()) { audioSource.ShallowStop(beat); Expire(); } }
internal void Start(BeatValue beat = ShallowMusic.DEFAULT_BEAT) { if (AssertExpired()) { if (!audioSource.isPlaying) { audioSource.ShallowPlay(beat); } } }
void OnTriggerEnter2D(Collider2D collider) { ExplosionEmitter.Emit(transform.position); Destroy(gameObject); BeatValue.AddScore(1); var bullet = collider.gameObject.GetComponent <Bullet>(); if (bullet != null) { bullet.GetPlayer().AddReward(); } }
private void SetNoteValues(List <Note> nl, PatternSynch ps) { bool[] restNotes = new bool[nl.Count]; BeatValue[] beatValues = new BeatValue[nl.Count]; BeatValue[] leggatoValues = new BeatValue[nl.Count]; BeatValue[] secondLeggatoValues = new BeatValue[nl.Count]; for (int i = 0; i < nl.Count; i++) { if (nl[i].GetColor() == NoteColor.NONE) { restNotes[i] = true; } else { restNotes[i] = false; } beatValues[i] = nl[i].GetBeatValue(); leggatoValues[i] = nl[i].GetLegatto(); secondLeggatoValues[i] = nl[i].GetSecondLegatto(); } samplePeriods = new double[beatValues.Length]; // Calculate number of samples between each beat in the sequence. for (int i = 0; i < beatValues.Length; ++i) { if (leggatoValues[i] == BeatValue.None) { samplePeriods[i] = 60f / (bpm * BeatDecimalValues.values[(int)beatValues[i]]); } else if (secondLeggatoValues[i] == BeatValue.None) { samplePeriods[i] = 60f / (bpm * BeatDecimalValues.values[(int)beatValues[i]]) + 60f / (bpm * BeatDecimalValues.values[(int)leggatoValues[i]]); } else { samplePeriods[i] = 60f / (bpm * BeatDecimalValues.values[(int)beatValues[i]]) + 60f / (bpm * BeatDecimalValues.values[(int)leggatoValues[i]]) + 60f / (bpm * BeatDecimalValues.values[(int)secondLeggatoValues[i]]); } } ps.SetSamplePeriods(samplePeriods, restNotes); //ps.gameObject.GetComponent<NotePooler>().SetBullets(nl, ps); }
//Helper functions for cueing things to play (usually audio) at the next available interval //For playing audio, use AudioSource.PlayScheduled(AtNextThirtySecond()); public double AtNext(BeatValue beat) { switch (beat) { case BeatValue.Measure: default: return(AtNextMeasure()); case BeatValue.Half: return(AtNextHalf()); case BeatValue.Quarter: return(AtNextQuarter()); case BeatValue.Eighth: return(AtNextEighth()); case BeatValue.Sixteenth: return(AtNextSixteenth()); case BeatValue.ThirtySecond: return(AtNextThirtySecond()); } }
public float GetBeatInSamples(BeatValue beatValue) { return((60f / (bpm * BeatDecimalValues.values[(int)beatValue])) * audioSource.clip.frequency); }
public WaitForBeatSync(BeatValue wtBeatValue) { this._waitBeatValue = wtBeatValue; this.currentThirtySecond = Clock.Instance._thirtySecondCount; //print("Starting Tick: " + currentTick); }
public void SetTimeSignature(int beatsPerMeasure, BeatValue unitOfTempo) { _beatsPerMeasure = beatsPerMeasure; _unitOfTempo = unitOfTempo; _InitializeBPM(BPM); }
ShallowAudioSource MemberPlay(Notes note, BeatValue beat = DEFAULT_BEAT, float volume = 1.0f) { return(MemberPlay(note, Vector2.zero, beat, volume)); }
public WaitForBeat(BeatValue beatValue) { waitUntil = Clock.Instance.AtNext(beatValue); this.beatValue = beatValue; }
/// <summary> /// This overloaded method is called by each PatternCounter this object is observing. Since pattern counters contain a sequence of /// different beat types, keeping track of the beat type isn't necessary. To test for a beat from the pattern counter, the beat mask /// should be checked for the BeatType.OnBeat flag. /// </summary> public void BeatNotify(BeatValue value) { beatValue = value; beatMask |= BeatType.OnBeat; StartCoroutine(WaitOnBeat(BeatType.OnBeat)); }
void Start() { beatMask = BeatType.None; beatValue = BeatValue.None; }
ShallowAudioSource MemberPlay(string clip, int index, BeatValue beat = DEFAULT_BEAT, float volume = 1.0f) { return(MemberPlay(clip, index, Vector2.zero, beat, volume)); }
void MemberStop(AudioSource source, BeatValue beat = DEFAULT_BEAT) { source.SetScheduledEndTime(Clock.Instance.AtNext(beat)); }
void MemberPlay(AudioSource source, BeatValue beat = DEFAULT_BEAT) { source.PlayScheduled(Clock.Instance.AtNext(beat)); }
ShallowAudioSource MemberPlay(AudioClip clip, Vector2 location, bool loop = false, BeatValue beat = DEFAULT_BEAT, float volume = 1.0f) { ShallowAudioSource source = GetShallowAudioSource(clip); source.loop = loop; source.position = location; source.volume = volume; source.Start(beat); return(source); }
ShallowAudioSource MemberPlay(AudioClip clip, bool loop = false, BeatValue beat = DEFAULT_BEAT, float volume = 1.0f) { return(MemberPlay(clip, Vector2.zero, loop, beat, volume)); }
ShallowAudioSource MemberPlay(Notes note, Vector2 location, BeatValue beat = DEFAULT_BEAT, float volume = 1.0f) { return(MemberPlay(notes[(int)note].randomClip, location, false, beat, volume)); }
public static ShallowAudioSource Play(Notes note, Vector2 location, BeatValue beat = DEFAULT_BEAT, float volume = 1.0f) { return(Instance.MemberPlay(note, location, beat, volume)); }
//CoRoutine to sync the execution of a particular callback to the next relevant beat of a particular value //Usage: Clock.Instance.SyncFunction(FunctionToCallback, BeatValue.Quarter) public void SyncFunction(System.Action callback, BeatValue beatValue = BeatValue.Measure) { StartCoroutine(YieldForSync(callback, beatValue)); }
public static ShallowAudioSource Play(AudioClip clip, Vector2 location, bool loop, BeatValue beat = DEFAULT_BEAT, float volume = 1.0f) { return(Instance.MemberPlay(clip, location, loop, beat, volume)); }
public static void Stop(AudioSource source, BeatValue beat = DEFAULT_BEAT) { Instance.MemberStop(source, beat); }
public static void ShallowStop(this AudioSource source, BeatValue beat = ShallowMusic.DEFAULT_BEAT) { ShallowMusic.Stop(source, beat); }
public static ShallowAudioSource Play(string clip, int index, Vector2 location, BeatValue beat = DEFAULT_BEAT, float volume = 1.0f) { return(Instance.MemberPlay(clip, index, location, beat, volume)); }
ShallowAudioSource MemberPlay(string clip, int index, Vector2 location, BeatValue beat = DEFAULT_BEAT, float volume = 1.0f) { return(MemberPlay(sfxClips[clip].clips[index], location, false, beat, volume)); }