public async Task <Note[]> GetPattern(Song s, SongDifficulty d, int expectedNotes) { var title = NormalizeTitle(s.Title); var songIdMap = await GetSongIdMap(false); if (songIdMap == null || !songIdMap.ContainsKey(title)) { songIdMap = await GetSongIdMap(true); if (songIdMap == null || !songIdMap.ContainsKey(title)) { return(null); } } foreach (var info in songIdMap[title]) { if ((int)info.GetType().GetProperty(d.ToString()).GetValue(info) != 0) { var id = $"{info.Id:d3}_{DifficultyIndex[d]}"; var pattern = await GetPattern(id); if (pattern != null && expectedNotes == pattern.Length) { return(pattern); } } } return(null); }
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 SongData(SongDifficulty difficulty, int level, int notes, int duration) { Difficulty = difficulty; Level = level; Notes = notes; Duration = duration; }
public void SscFile_Parses_Difficulty(string sscFilePath, SongDifficulty expecteDifficulty) { var sscFile = new SmFile(sscFilePath); var actualDifficulty = sscFile.ChartMetadata.StepCharts.Single().Difficulty; Assert.Equal(expecteDifficulty, actualDifficulty); }
public SongData() { songName = ""; songBPM = 120; songLength = 0f; songDifficulty = SongDifficulty.Easy; maxCombo = 0; maxScore = 0; playerHighCombo = 0; playerHighScore = 0; playTimes = 0; }
public void Reset() { f = null; tMap = null; notes = null; chords = null; spawner = null; audioSource.clip = null; difficulty = SongDifficulty.Easy; MidiName = ""; PlayingSongForLevel = false; }
public static void StartRecording(String name, String songName, string artistName, string musicName, int beatsPerSecond, SongRecordingSnapping snapping, SongDifficulty difficulty) { TimePassed = 0; IsStopped = false; Song = new Song(name, difficulty); Song.ArtistName = artistName; Song.SongName = songName; Song.MusicName = musicName; Song.StepListName = name; Song.BeatsPerSecond = beatsPerSecond; Song.Snapping = snapping; TimeScale = (float)beatsPerSecond / 60; SnappingScale = 1.0f / (int)snapping; }
//void Analyze(string path) //{ // BeatMap beatMap = SongLoader.GetBeatMap(path); // if (beatMap == null) return; // var metrics = analyzer.Analyze(beatMap); // SongDifficulty d = new SongDifficulty(path.Split('\\')[path.Split('\\').Length - 1], "-", metrics); // songDifficulties.Add(d); //} void DisplayResult() { SongDifficulty D = songDifficulties.Where(o => o.songName == "TTFAF").FirstOrDefault(); songDifficulties = songDifficulties.OrderByDescending(o => o.difficulty).ToList(); string result = String.Format("{0,-30} | {1,-10} | {2,-10} | {3,-10} | {4,-10} | {5,-10} | {6,-10} | {7,-10}\n", "Song Name", "Level", "Avg/Sec", "Max/Sec", "CutDist/Sec", "DirEntropy", "PosEntropy", "Difficulty"); foreach (SongDifficulty d in songDifficulties) { result += String.Format("{0,-30} | {1,-10} | {2,-10} | {3,-10} | {4,-10} | {5,-10} | {6,-10} | {7,-10}\n", d.songName, d.difficultyName, d.m.avgNotesPerSec, d.m.maxNotesPerBarPerSec, d.m.cutDistancePerSec, d.m.cutDirectionEntropy, d.m.notePosEntropy, d.difficulty ); } System.IO.File.WriteAllText("results.txt", result); }
void InitialiseSong() { f = MidiFile.Read(Application.dataPath + "/Midi/" + MidiName); tMap = f.GetTempoMap(); audioSource = GetComponent <AudioSource>(); //MAYBE WE SHOULD LOOK FOR ONE IN THE SCENE? MAKES LOGIC CLEANER Debug.Log(Song.name); audioSource.clip = Song; //1000000 microseconds in a second, this lets us set our fixed deltatime logic. if (tMap.TimeSignature.Values.Count() != 0) { timeSigBars = tMap.TimeSignature.Values.First().Value.Denominator; timeSigBeats = tMap.TimeSignature.Values.First().Value.Numerator; } var seconds = tMap.Tempo.Values.ToArray().First().Value.MicrosecondsPerQuarterNote / (1000000f * timeSigBars); TimeDivision t = tMap.TimeDivision; Debug.Log(t.ToString()); Time.fixedDeltaTime = seconds; songLengthMicroseconds = (f.GetTimedEvents().LastOrDefault(e => e.Event is NoteOffEvent)?.TimeAs <MetricTimeSpan>(tMap) ?? new MetricTimeSpan()).TotalMicroseconds; notes = f.GetNotes(); chords = f.GetChords(); if (songLengthMicroseconds == 0) { songLengthMicroseconds = Math.Max(notes.Max(x => x.Time), chords.Max(x => x.Time)); } for (int i = 1; i < 5; i++) { NotesInSong[(SongDifficulty)i] = new Dictionary <long, Chord>(); } foreach (Melanchall.DryWetMidi.Smf.Interaction.Note note in notes) { SongDifficulty d = (SongDifficulty)note.Octave; var difficultDictionary = NotesInSong[d]; if (difficultDictionary.ContainsKey(note.Time)) { //check if the chord at the target time contains us: if (difficultDictionary[note.Time].Notes.Contains(note)) { continue; } else { //if (d == difficulty) // Debug.Log("Adding note at time: " + note.Time); difficultDictionary[note.Time].Notes.Add(note); } } else { //if (d == difficulty) // Debug.Log("Adding note at time: " + note.Time); difficultDictionary[note.Time] = new Chord(new Melanchall.DryWetMidi.Smf.Interaction.Note[] { note }); } } if (!audioSource.isPlaying) { audioSource.Play(); } // Debug.Log(v.NoteNumber); }
[InlineData(TEST_DATA_ARABIAN_NIGHTS, PlayStyle.Double, SongDifficulty.Challenge)] //Doubles Only chart public void SmFile_GenerateLightsChart_Maintains_Reference_Chart_Data(string smFilePath, PlayStyle referenceChartStyle, SongDifficulty referenceChartDifficulty) { var smFile = new SmFile(smFilePath); var lightsData = StepChartBuilder.GenerateLightsChart(smFile); Assert.Equal(referenceChartStyle, lightsData.ReferenceChart.PlayStyle); Assert.Equal(referenceChartDifficulty, lightsData.ReferenceChart.Difficulty); }
public void SmFile_GetHighestChartedDifficulty_Returns_The_Highest_Difficulty(string smFilePath, SongDifficulty expectedDifficulty) { var smFile = new SmFile(smFilePath); var actualDifficulty = smFile.ChartMetadata.GetHighestChartedDifficulty(PlayStyle.Single); Assert.Equal(expectedDifficulty, actualDifficulty); }
public Song(String name, SongDifficulty difficulty) { DisplayName = name; Difficulty = difficulty; SongNotes = new List<SongNote>(); }
public StepMetadata GetSteps(PlayStyle style, SongDifficulty difficulty) { return(StepCharts.FirstOrDefault(c => c.PlayStyle == style && c.Difficulty == difficulty)); }
private void SaveScore(GameStatus gameStatus) { try { var songScores = localProfilesData.SongScores; var song = songScores.ContainsKey(gameStatus.songHash) ? songScores[gameStatus.songHash] : null; if (song == null) { song = new SongInfo() { Hash = gameStatus.songHash, BeatSaverID = gameStatus.songBeatSaverID, FilePath = gameStatus.songFilePath, Name = gameStatus.songName, SubName = gameStatus.songSubName, AuthorName = gameStatus.songAuthorName, BPM = gameStatus.songBPM, Length = gameStatus.length }; songScores.Add(song.Hash, song); } localProfilesData.lastSong = song; var difficulty = song.Difficulties.FirstOrDefault(x => x.Difficulty == gameStatus.difficulty); if (difficulty == null) { difficulty = new SongDifficulty() { Difficulty = gameStatus.difficulty, BombsCount = gameStatus.bombsCount, MaxRank = gameStatus.maxRank, MaxScore = gameStatus.maxScore, NoteJumpSpeed = gameStatus.noteJumpSpeed, NotesCount = gameStatus.notesCount, ObstaclesCount = gameStatus.obstaclesCount }; song.Difficulties.Add(difficulty); } localProfilesData.lastDiff = difficulty; var profile = difficulty.Profiles.FirstOrDefault(x => x.Name == localProfilesData.CurrentProfile); if (profile == null) { profile = new Profile() { Name = localProfilesData.CurrentProfile }; difficulty.Profiles.Add(profile); } localProfilesData.lastProfile = profile; //var scores = profile.Scores.ContainsKey(gameStatus.songHash) ? profile.Scores[gameStatus.songHash] : null; //if (scores == null) //{ // profile.Scores.Add(gameStatus.songHash, new List<Score>()); //} var score = new Score() { score = gameStatus.score, maxPossibleScore = gameStatus.currentMaxScore, rank = gameStatus.rank, passedNotes = gameStatus.passedNotes, hitNotes = gameStatus.hitNotes, missedNotes = gameStatus.missedNotes, passedBombs = gameStatus.passedBombs, hitBombs = gameStatus.hitBombs, maxCombo = gameStatus.maxCombo, timePlayed = GameStatusTracker.GetCurrentTime() - gameStatus.start, timestamp = (int)(GameStatusTracker.GetCurrentTime() / 1000), modifierMultiplier = gameStatus.modifierMultiplier, batteryLives = gameStatus.batteryLives, modObstacles = gameStatus.modObstacles, modInstaFail = gameStatus.modInstaFail, modNoFail = gameStatus.modNoFail, modBatteryEnergy = gameStatus.modBatteryEnergy, modDisappearingArrows = gameStatus.modDisappearingArrows, modNoBombs = gameStatus.modNoBombs, modSongSpeed = gameStatus.modSongSpeed, modFailOnSaberClash = gameStatus.modFailOnSaberClash, modStrictAngles = gameStatus.modStrictAngles }; profile.Scores.Add(score); localProfilesData.lastScore = score; //var js = Newtonsoft.Json.JsonConvert.SerializeObject(gameStatus, Newtonsoft.Json.Formatting.Indented); //File.WriteAllText(Path.Combine(ScoreDirPath, "score" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt"), js); var js = Newtonsoft.Json.JsonConvert.SerializeObject(song, Newtonsoft.Json.Formatting.Indented); File.WriteAllText(Path.Combine(localProfilesData.ScoreDirPath, song.Hash + ".json"), js); }catch (Exception ex) { Plugin.Log("ERROR SAVING SCORE!! " + ex); } }
public SongGenerator(SongDifficulty dif, AudioClip clip) { this.difficulty = dif; this.audioClip = clip; }
public async Task<Note[]> GetPattern(Song s, SongDifficulty d, int expectedNotes) { var title = NormalizeTitle(s.Title); var songIdMap = await GetSongIdMap(false); if (songIdMap == null || !songIdMap.ContainsKey(title)) { songIdMap = await GetSongIdMap(true); if (songIdMap == null || !songIdMap.ContainsKey(title)) { return null; } } foreach (var info in songIdMap[title]) { if ((int)info.GetType().GetProperty(d.ToString()).GetValue(info) != 0) { var id = $"{info.Id:d3}_{DifficultyIndex[d]}"; var pattern = await GetPattern(id); if (pattern != null && expectedNotes == pattern.Length) { return pattern; } } } return null; }
public static string ToLocalizedString(this SongDifficulty diff) { return(m_songDifficulties[diff]); }