public SongPart(Strum[] strum_pattern, int[] chord_prog) { StrumPattern = strum_pattern; ChordProgression = chord_prog; }
Strum[] GenerateStrumPattern(int beats) { Debug.Log(m_name + " GenerateStrumPattern()"); int strums = beats * m_StrumsPerBeat; Strum[] pattern = new Strum[strums]; float strumLength = 1f / strums; for (int i = 0; i < strums; i++) { pattern[i].play = true; pattern[i].time = i * strumLength; if (0 == i) { pattern[i].volume = 1.0f; pattern[i].Segment = 0; } else { pattern[i].volume = m_OffBeatVolume; if( i % 2 == 0) { pattern[i].Segment = 0; pattern[i].play = !(Random.value < m_MissDownStrumChance); } else { pattern[i].Segment = 1; pattern[i].time += m_UpStrumOffset * strumLength; pattern[i].play = !(Random.value < m_MissUpStrumChance);// || !pattern[i-1].play; //the commented out bit prevents no upstrum after no downstrum. Wanted? } } } return pattern; }
public void GenerateSongParts(SongPartSpec[] specs) { m_songParts.Clear(); foreach(SongPartSpec sps in specs) { Strum[] strumPattern; int[] chordPattern; if(sps.Name != "silence") { strumPattern = GenerateStrumPattern(m_BeatsPerMeasure); chordPattern = GenerateChordPattern(sps.MinChords, sps.MaxChords); } else { strumPattern = new Strum[1]; strumPattern[0].time = 2f; strumPattern[0].play = false; chordPattern = new int[]{ 0}; } m_songParts.Add(sps.Name, new SongPart(strumPattern, chordPattern)); } }