void AnalyzeAll(string rootPath) { List <CustomSongInfo> songInfos = SongLoader.RetrieveAllSongs(rootPath); foreach (CustomSongInfo song in songInfos) { if (song.songName != "Hit The Blocks") //This map causes an infinite loop, don't know why { foreach (CustomSongInfo.DifficultyLevel difficulty in song.difficultyLevels) { Analyzer analyzer; analyzer = new Analyzer(); BeatMap beatMap = SongLoader.GetBeatMap(song, difficulty); if (beatMap == null) { continue; } beatMap.songName = song.songName; var metrics = analyzer.Analyze(beatMap); SongDifficulty d = new SongDifficulty(song.songName, difficulty.difficulty, metrics); songDifficulties.Add(d); } } } }
public SongMetrics Analyze(BeatMap _beatMap) { beatMap = _beatMap; redNotes = new ArrayList(); blueNotes = new ArrayList(); allNotes = new ArrayList(); foreach (Note note in beatMap.notes) { if (note.type == 0) { redNotes.Add(note); allNotes.Add(note); } if (note.type == 1) { blueNotes.Add(note); allNotes.Add(note); } if (note.time > totalBeats) { totalBeats = note.time; // Keep track of how long the song is } } if (allNotes.Count > 20) //TODO: Add stamina { byte[] cutDirections = new byte[allNotes.Count]; byte[] notePos = new byte[allNotes.Count]; for (int i = 0; i < allNotes.Count; i++) { Note n = (Note)allNotes[i]; cutDirections[i] = (byte)((Note)allNotes[i]).cutDirection; notePos[i] = (byte)(n.lineIndex * 3 + n.lineLayer); } SongMetrics sm = new SongMetrics(); sm.avgNotesPerSec = GetAverageNotesPerSecond(allNotes, true); sm.cutDistancePerSec = GetCutDistancePerSecond(redNotes) + GetCutDistancePerSecond(blueNotes); sm.cutDirectionEntropy = Entropy(cutDirections); sm.notePosEntropy = Entropy(notePos); sm.maxScore = MaxScoreForNumberOfNotes(allNotes.Count); sm.noteJumpSpeed = beatMap.noteJumpSpeed; return(sm); } else { return(new SongMetrics()); } }