GeneticMIDI.Generators.GeneticGenerator.FixMelodySequence C# (CSharp) Method

FixMelodySequence() private method

private FixMelodySequence ( GeneticMIDI.Representation.MelodySequence seq ) : GeneticMIDI.Representation.MelodySequence
seq GeneticMIDI.Representation.MelodySequence
return GeneticMIDI.Representation.MelodySequence
        private MelodySequence FixMelodySequence(MelodySequence seq)
        {
            var newNotes = new List<Note>();
            var notes = seq.ToArray();
            if (notes.Length > 1)
                newNotes.Add(notes[0]);
            for(int i = 1; i < notes.Length; i++)
            {
                bool add = true;

                var note = notes[i];
                var prevNote = notes[i - 1];

                if (!note.IsRest())
                {

                    if (Math.Abs(note.Pitch - prevNote.Pitch) > 24)
                    {
                        add = false;
                    }
                }

                if (add)
                    newNotes.Add(note);
            }
            return new MelodySequence(newNotes.ToArray());
        }