public void GeneratePhraseIterationsData(IAttributes attribute, dynamic song, GameVersion gameVersion) { if (song.PhraseIterations == null) return; for (int i = 0; i < song.PhraseIterations.Length; i++) { var phraseIteration = song.PhraseIterations[i]; var phrase = song.Phrases[phraseIteration.PhraseId]; var endTime = i >= song.PhraseIterations.Length - 1 ? song.SongLength : song.PhraseIterations[i + 1].Time; var phraseIt = new PhraseIteration(); phraseIt.StartTime = phraseIteration.Time; phraseIt.EndTime = endTime; phraseIt.PhraseIndex = phraseIteration.PhraseId; phraseIt.Name = phrase.Name; phraseIt.MaxDifficulty = phrase.MaxDifficulty; if (gameVersion == GameVersion.RS2012) phraseIt.MaxScorePerDifficulty = new List<float>(); attribute.PhraseIterations.Add(phraseIt); } var noteCnt = 0; foreach (var y in attribute.PhraseIterations) { if (song.Levels[y.MaxDifficulty].Notes != null) { if (gameVersion == GameVersion.RS2012) noteCnt += GetNoteCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); else noteCnt += GetNoteCount2014(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); } if (song.Levels[y.MaxDifficulty].Chords != null) { noteCnt += GetChordCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Chords); } } attribute.Score_MaxNotes = noteCnt; attribute.Score_PNV = ((float)attribute.TargetScore) / noteCnt; foreach (var y in attribute.PhraseIterations) { var phrase = song.Phrases[y.PhraseIndex]; for (int ndx = 0; ndx <= phrase.MaxDifficulty; ndx++) { var multiplier = ((float)(ndx + 1)) / (phrase.MaxDifficulty + 1); var pnv = attribute.Score_PNV; var noteCount = 0; if (song.Levels[ndx].Chords != null) { if (gameVersion == GameVersion.RS2012) noteCnt += GetNoteCount(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); else noteCnt += GetNoteCount2014(y.StartTime, y.EndTime, song.Levels[y.MaxDifficulty].Notes); } if (song.Levels[ndx].Chords != null) noteCount += GetChordCount(y.StartTime, y.EndTime, song.Levels[ndx].Chords); if (gameVersion == GameVersion.RS2012) { var score = pnv * noteCount * multiplier; y.MaxScorePerDifficulty.Add(score); } } } }
public SngFile(string file) { _filePath = file; using (var stream = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read)) { BinaryReader br = new BinaryReader(stream); Version = br.ReadInt32(); _beatCount = br.ReadInt32(); Beats = new Ebeat[_beatCount]; for (int i = 0; i < _beatCount; ++i) { Beats[i] = new Ebeat(br); } _PhraseCount = br.ReadInt32(); Phrases = new Phrase[_PhraseCount]; for (int i = 0; i < _PhraseCount; ++i) { Phrases[i] = new Phrase(br); } _chordTemplateCount = br.ReadInt32(); ChordTemplates = new ChordTemplate[_chordTemplateCount]; for (int i = 0; i < _chordTemplateCount; ++i) { ChordTemplates[i] = new ChordTemplate(br); } _fretHandMuteTemplateCount = br.ReadInt32(); // always 0? _vocalsCount = br.ReadInt32(); _vocals = new Vocal[_vocalsCount]; for (int i = 0; i < _vocalsCount; ++i) { _vocals[i] = new Vocal(br); } _phraseIterationCount = br.ReadInt32(); PhraseIterations = new PhraseIteration[_phraseIterationCount]; for (int i = 0; i < _phraseIterationCount; ++i) { PhraseIterations[i] = new PhraseIteration(br); } PhrasePropertyCount = br.ReadInt32(); PhraseProperties = new PhraseProperty[PhrasePropertyCount]; for (int i = 0; i < PhrasePropertyCount; ++i) { PhraseProperties[i] = new PhraseProperty(br); } LinkedDiffCount = br.ReadInt32(); LinkedDiffs = new LinkedDiff[LinkedDiffCount]; for (int i = 0; i < LinkedDiffCount; ++i) { LinkedDiffs[i] = new LinkedDiff(br); } ControlCount = br.ReadInt32(); Controls = new Control[ControlCount]; for (int i = 0; i < ControlCount; ++i) { Controls[i] = new Control(br); } _songEventCount = br.ReadInt32(); SongEvents = new SongEvent[_songEventCount]; for (int i = 0; i < _songEventCount; ++i) { SongEvents[i] = new SongEvent(br); } SongSectionCount = br.ReadInt32(); SongSections = new SongSection[SongSectionCount]; for (int i = 0; i < SongSectionCount; ++i) { SongSections[i] = new SongSection(br); } _songLevelCount = br.ReadInt32(); SongLevels = new SongLevel[_songLevelCount]; for (int i = 0; i < _songLevelCount; ++i) { SongLevels[i] = new SongLevel(br, Version); } Metadata = new Metadata(br); // Not sure what this junk is down here yet int endLength = (int)(br.BaseStream.Length - br.BaseStream.Position); _unknown2 = br.ReadBytes(endLength); } }