// COMPLETE private static void WriteRocksmithSngLevelAnchors(EndianBinaryWriter w, SongAnchor[] anchors, Xml.SongLevel level, List <PhraseIterationInfo> iterationInfo, Single songLength) { if (anchors == null || anchors.Length == 0) { w.Write(new byte[4]); // empty header return; } // output anchors header count w.Write(anchors.Length); // output anchors for (int i = 0; i < anchors.Length; i++) { // anchor start time var startTime = anchors[i].Time; w.Write(startTime); // anchor end time var endTime = i == anchors.Length - 1 ? songLength : anchors[i + 1].Time; w.Write(endTime); float?lastNote = null, lastChord = null; var notes = (level.Notes == null) ? null : level.Notes.Where(note => note.Time >= startTime && note.Time < endTime); if (notes != null && notes.Any()) { var note = notes.OrderByDescending(n => n.Time).First(); lastNote = note.Time + note.Sustain + .1f; } var chords = (level.Chords == null) ? null : level.Chords.Where(chord => chord.Time >= startTime && chord.Time < endTime); if (chords != null && chords.Any()) { lastChord = chords.Max(chord => chord.Time) + .1f; } float lastTime = lastNote == null && lastChord == null ? endTime : Math.Max(lastNote ?? startTime, lastChord ?? startTime); w.Write(Math.Min(lastTime, endTime)); // fret w.Write(anchors[i].Fret); // phrase iteration index bool phraseIterationFound = false; foreach (var iteration in iterationInfo) { if (anchors[i].Time >= iteration.StartTime && anchors[i].Time < iteration.EndTime) { w.Write(iteration.IterationId); phraseIterationFound = true; break; } } if (!phraseIterationFound) { w.Write(iterationInfo.Count - 1); } } }
// INCOMPLETE private static void WriteRocksmithSngLevelHandShapes(EndianBinaryWriter w, SongHandShape[] handShapes, Xml.SongLevel level, float songLength) { // sample section begins @ 328,356 in NumberThirteen_Combo.sng // sample section begins @ 4,300 in TCPowerChords_Lead.sng if (handShapes == null || handShapes.Length == 0) { w.Write(new byte[4]); // empty header return; } // output notes header count w.Write(handShapes.Length); // ouput handshapes for (int i = 0; i < handShapes.Length; i++) { SongHandShape handShape = handShapes[i]; // hand shape start time w.Write(handShape.StartTime); // hand shape end time w.Write(handShape.EndTime); // unknown w.Write(Convert.ToSingle(-1)); // unknown w.Write(Convert.ToSingle(-1)); // chord id w.Write(handShape.ChordId); // chord start time again ??? // Probably the first chord in the shape. w.Write(handShape.StartTime); var endTime = handShape.EndTime; //var endTime = i == handShapes.Length - 1 // ? songLength // : handShapes[i + 1].StartTime; // This should actually be the time of the last chord before the end time. float?lastChord = null; var chords = level.Chords == null ? null : level.Chords.Where(chord => chord.Time >= handShape.StartTime && chord.Time < endTime); var note = level.Notes == null ? null : level.Notes.FirstOrDefault(n => n.Time == endTime); if (note != null) { lastChord = endTime; } else if (chords != null && chords.Count() > 0) { lastChord = chords.Max(chord => chord.Time); } w.Write(lastChord ?? endTime); } }