List <MusicSymbol> AddClefChanges(List <MusicSymbol> symbols, ClefMeasures clefs, TimeSignature time) { List <MusicSymbol> result = new List <MusicSymbol>(symbols.Count); Clef prevclef = clefs.GetClef(0); foreach (MusicSymbol symbol in symbols) { /* A BarSymbol indicates a new measure */ if (symbol is BarSymbol) { Clef clef = clefs.GetClef(symbol.StartTime); if (clef != prevclef) { result.Add(new ClefSymbol(clef, symbol.StartTime - 1, true)); } prevclef = clef; } result.Add(symbol); } return(result); }
List <ChordSymbol> CreateChords(List <MidiNote> midinotes, KeySignature key, TimeSignature time, ClefMeasures clefs) { int i = 0; List <ChordSymbol> chords = new List <ChordSymbol>(); List <MidiNote> notegroup = new List <MidiNote>(12); int len = midinotes.Count; while (i < len) { int starttime = midinotes[i].StartTime; Clef clef = clefs.GetClef(starttime); /* Group all the midi notes with the same start time * into the notes list. */ notegroup.Clear(); notegroup.Add(midinotes[i]); i++; while (i < len && midinotes[i].StartTime == starttime) { notegroup.Add(midinotes[i]); i++; } /* Create a single chord from the group of midi notes with * the same start time. */ ChordSymbol chord = new ChordSymbol(notegroup, key, time, clef, this); chords.Add(chord); } return(chords); }