Nanook.TheGhost.ProjectSong.adjustNotes C# (CSharp) Method

adjustNotes() private method

private adjustNotes ( int notes ) : int[]
notes int
return int[]
        private int[] adjustNotes(int[] notes)
        {
            if (notes.Length == 0)
                return notes;

            List<int> n = new List<int>();

            for (int i = 0; i < notes.Length; i += 3)
            {
                if (n.Count > 3 && notes[i] - n[n.Count - 3] <= 6)
                {
                    //if the notes are very close together then it could be an editor issue, combine them
                    n[n.Count - 2] = notes[i + 1];  //the first note will have most likely been truncated if sustained
                    n[n.Count - 1] |= notes[i + 2]; //OR notes together
                }
                else if (n.Count > 3 && (notes[i] - n[n.Count - 3] < n[n.Count - 2]))
                {
                    //if the length of the last note is longer then distance between them, then shorten the length
                    //this is only for non sustained notes (they are fixed in another area)
                    n[n.Count - 2] = (notes[i] - n[n.Count - 3]);

                    n.Add(notes[i]);
                    n.Add(notes[i + 1]);
                    n.Add(notes[i + 2]);
                }
                else
                {
                    n.Add(notes[i]);
                    n.Add(notes[i + 1]);
                    n.Add(notes[i + 2]);
                }
            }
            return n.ToArray();
        }