private static void ParseMetadata(string line, ref MusicMap map) { string[] parts = line.Split(':'); string value = parts[1].Trim(); switch (parts[0]) { case "Title": map.metadata.title = value; break; case "TitleUnicode": map.metadata.titleUnicode = value; break; case "Artist": map.metadata.artist = value; break; case "ArtistUnicode": map.metadata.artistUnicode = value; break; case "Creator": map.metadata.creator = value; break; } }
public static MusicMap LoadOsuMap(string folderpath) { MusicMap newMap = new MusicMap(); newMap.metadata = new MusicMetadata(); newMap.timingPoints = new List <TimingPoint>(); string osuFilepath = GetOsuFilePaths(folderpath)[0]; string[] fileLines = File.ReadAllLines(osuFilepath); Parser parserDelegate = ParseGeneral; for (int i = 0; i < fileLines.Length; i++) { if (fileLines[i][0] == '[') { parserDelegate = GetParser(fileLines[i]); } parserDelegate(fileLines[i], ref newMap); } return(newMap); }
private static void ParseTimingPoints(string line, ref MusicMap map) { TimingPoint newPoint = new TimingPoint(); string[] values = line.Split(','); newPoint.offSetMilliSecs = Int32.Parse(values[0]); newPoint.beatInterval = Int32.Parse(values[1]); newPoint.beatsPerMeasure = Int32.Parse(values[2]); map.timingPoints.Add(newPoint); }
// Start is called before the first frame update void Start() { toLoad = new MusicMap(); toLoad.audioFilename = "resistance"; //toLoad.bpm = 30.0F; toLoad.bpm = 37.0F; toLoad.offset = 0.810810810810F; toLoad.beatsPerMeasure = 4; nome = GetComponent <Metronome>(); nome.AddBeatListener(() => cube.SetActive(!cube.active)); nome.LoadMap(toLoad);//Load a json from streaming assets. link to mp3 file nome.Play(); Debug.Log("Done"); }
private static void ParseGeneral(string line, ref MusicMap map) { string[] parts = line.Split(':'); string value = parts[1].Trim(); switch (parts[0]) { case "AudioFileName": map.audioFilename = value; break; case "AudioLeadIn": map.audioLeadInMilliSecs = Int32.Parse(value); break; } }
public void LoadMap(MusicMap map) { _map = map; _audioSource.clip = (AudioClip)Resources.Load(map.audioFilename); }