// COMPLETE except hardcoded fields private static void WriteRocksmithSngLevelNotes(EndianBinaryWriter w, List<PhraseIterationInfo> iterationInfo, SongNote[] notes, SongChord[] chords, Single songLength, ArrangementType arrangementType) { List<TimeLinkedEntity> notesChords = new List<TimeLinkedEntity>(); // add notes to combined note/chord array if (notes != null && notes.Length != 0) { notesChords.AddRange(notes.Select(note => new TimeLinkedEntity { Time = note.Time, Entity = note })); } // add chords to combined note/chord array if (chords != null && chords.Length != 0) { notesChords.AddRange(chords.Select(chord => new TimeLinkedEntity { Time = chord.Time, Entity = chord })); } // sort the notes and chords by time notesChords.Sort((s1, s2) => s1.Time.CompareTo(s2.Time)); // write empty header if no notes or chords if (notesChords.Count == 0) { w.Write(new byte[4]); // empty header return; } // output notes and chords header count w.Write(notesChords.Count); // ouput notes and chords for (int i = 0; i < (notesChords.Count); i++) { // note time tag w.Write(notesChords[i].Time); // string tag w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).String : -1); // fret tag w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).Fret : -1); // chord id w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? -1 : ((SongChord)notesChords[i].Entity).ChordId); // unknown w.Write(Convert.ToInt32(-1)); // sustain time w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).Sustain : 0); // bend w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).Bend : 0); // slideTo w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).SlideTo : -1); // tremolo w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).Tremolo : new byte()); // harmonic w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).Harmonic : new byte()); // palm mute w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).PalmMute : new byte()); if (arrangementType == ArrangementType.Bass) { w.Write(new byte());//unknownB //Bass only - Slap w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).Slap : -1); //Bass only - Pluck w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).Pluck : -1); } // hopo w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).Hopo : new byte()); // hammerOn w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).HammerOn : new byte()); // pullOff w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).PullOff : new byte()); // ignore w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? ((SongNote)notesChords[i].Entity).Ignore : ((SongChord)notesChords[i].Entity).Ignore); // high density chord if (arrangementType == ArrangementType.Bass) { w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? new byte() : ((SongChord)notesChords[i].Entity).HighDensity); w.Write(new byte()); w.Write((byte)140); w.Write(new byte()); } else { w.Write(notesChords[i].Entity.GetType() == typeof(SongNote) ? new byte() : ((SongChord)notesChords[i].Entity).HighDensity); w.Write(new byte[4]); } //w.Write(Convert.ToInt16(246)); //w.Write(Convert.ToInt16(7472)); // phrase iteration start index and id ???? bool phraseStartIterationFound = false; foreach (var iteration in iterationInfo) { if (notesChords[i].Time >= iteration.StartTime && notesChords[i].Time < iteration.EndTime) { w.Write(iteration.IterationId); // phrase iteration w.Write(iteration.PhraseId); phraseStartIterationFound = true; break; } } if (!phraseStartIterationFound) { throw new Exception(string.Format("No phrase start iteration found with matching time for note {0}.", i.ToString())); } } }