private void OnOnset(OnsetType type, Onset onset) { if (onset.rank < 5 && onset.rank < 5) { //return; switch (type) { case OnsetType.Low: lines.Add(CreateLine(onset.index, Color.blue, onset.strength, -20)); break; case OnsetType.Mid: lines.Add(CreateLine(onset.index, Color.green, onset.strength, 0)); break; case OnsetType.High: lines.Add(CreateLine(onset.index, Color.yellow, onset.strength, 20)); break; case OnsetType.All: lines.Add(CreateLine(onset.index, Color.magenta, onset.strength, 40)); break; } } }
//this is where the magic happens private void OnOnset(OnsetType type, Onset onset) { if (type == OnsetType.All) { BeatPattern pattern = SelectPattern(Random.Range(0, patterns.Count)); //randomly select a supplied pattern object List <int> beatList = pattern.pattern; //copy the beat data from the pattern int indexModifier = 0; //number of frames between spawned beats and the onset which triggers spawning int indexIncrement = (bpm / beatList.Count); //fixed value between each beat float indexFloatFix = 0.0f; //a value that stores the remainder in case the bpm is not divisible into perfect frames foreach (int i in beatList) { //store the remaining part of the float because frames are ints, but bpm fractions are floats //if there is a remainder in excess of 1, decrement 1 from storage, and increment the index modifier by 1 indexFloatFix += Mathf.Repeat(((float)bpm / beatList.Count), 1.0f); if (indexFloatFix > 1.0f) { indexFloatFix -= 1.0f; indexModifier += 1; } //spawn the beat and increment the index modifier if (i == 1) { beats.Add(CreateBeat(onset.index + indexModifier)); indexModifier += indexIncrement; } // still increment the index modifer when there is no beat to be spawned else if (i == 0) { indexModifier += indexIncrement; } } } }
private void OnOnset(OnsetType type, Onset onset) { if (onset.rank < 4 && onset.strength < 5) { return; } if (onset.rank < 5) { return; } switch (type) { case OnsetType.Low: // lines.Add(CreateLine(onset.index, Color.blue, onset.strength, -20)); var random = Random.Range(0, 4); lines.Add(CreateLine(onset.index, Color.blue, onset.strength, -1.5f + (1 * random))); // lines.Add(CreateLine(onset.index, Color.blue, onset.strength, -5.5f + (1 * random))); // lines.Add(CreateLine(onset.index, Color.blue, onset.strength, 2.5f + (1 * random))); break; case OnsetType.Mid: // lines.Add(CreateLine(onset.index, Color.green, onset.strength, 0)); break; case OnsetType.High: // lines.Add(CreateLine(onset.index, Color.yellow, onset.strength, 20)); //lines.Add(CreateLine(onset.index, Color.blue, onset.strength, 0)); break; case OnsetType.All: // lines.Add(CreateLine(onset.index, Color.magenta, onset.strength, 40)); break; } }
private void OnOnset(OnsetType arg1, Onset arg2) { }