void reset() { processedData = 15; rowsBox.Clear(); rowsBpm.Clear(); rowsBeat.Clear(); rowsLanePositions.Clear(); rhythmData = null; inited = false; }
private void OnLoaded(AudioClip audioClip) { //Clean up old resources. Destroy(player.audioClip); Destroy(player.rhythmData); //Start analyzing the song. RhythmData rhythmData = analyzer.Analyze(audioClip); //Give the AudioClip and RhythmData to the RhythmPlayer. player.audioClip = audioClip; player.rhythmData = rhythmData; }
public void process(RhythmData rData)//, float currentTimestamp = 0) { //TODO add more row types for secondary VFX features, like spectrum visualiser? //string patternFilePath = getPatternPath(); //bool exists = File.Exists(patternFilePath); //float songDuration = audioSource.clip.length; //Debug.Log("************* SONGLOADER.PROCESS " + patternFilePath + " " + songDuration + " " + totalLanes); Debug.Log("************* SONGLOADER.COMPETED ANALYSIS " + songData); List <Beat> tmpBeats = new List <Beat>(); rData.GetFeatures <Beat>(tmpBeats, 0, songData.getClipLength()); //Debug.Log("beats detected " + tmpBeats.Count); rhythmData = rData; //getSegmentData(0, processedData); inited = true; }
public override void NextSong() { base.NextSong(); //Clean up old resources. Destroy(player.rhythmData); //start analyzing the next song. currentSong++; if (currentSong >= songs.Count) { currentSong = 0; } AudioClip audioClip = songs[currentSong]; RhythmData rhythmData = analyzer.Analyze(audioClip); //Give the AudioClip and RhythmData to the RhythmPlayer. player.audioClip = audioClip; player.rhythmData = rhythmData; }
//TODO something wrong with layout comparison, using layout index somewhere, and layout totalLanes in other void songLoaded(AudioClip clip) { Debug.Log("************* SONGLOADER.SONGLOADED " + clip.name + " " + clip.length); Debug.Log("Errors? " + importer.error); reset(); state = State.LOADED; songData.setClip(clip); if (clip.loadState == AudioDataLoadState.Unloaded) { Debug.Log("Clip not loaded, loading now"); clip.LoadAudioData(); } //string patternFilePath = getPatternPath(); //bool exists = File.Exists(patternFilePath); //TODO are we loading custom patterns correctly? Dictionary <string, string> patternFilePaths = new Dictionary <string, string>(); SongData.findPatterns(patternFilePaths, clip.name); //SongData.PatternType validTypesForLoading = SongData.PatternType.AUTO; //if (patternType == SongData.PatternType.CUSTOM) // patternType = SongData.PatternType.CUSTOM; string suffix = SongData.getPatternSuffix(patternLanes, patternType); //Debug.Log("Patterns found:"); //foreach (string s in patternFilePaths.Keys) // Debug.Log(s + "->" + patternFilePaths[s]); bool patternExists = patternFilePaths.ContainsKey(suffix); if (!patternExists) { Debug.Log("No existing pattern (" + suffix + "), will create"); } if (!Settings.instance.patternOverwriteAuto && patternExists) { //Debug.Log("Auto pattern files already exists, no need to create"); loadPattern(patternFilePaths[suffix]); //string[] fileContent = File.ReadAllLines(patternFilePaths[suffix]); ////List<SongRow> rows = new List<SongRow>(); //foreach (string rowStr in fileContent) //{ // SongRow row = SongRow.parse(rowStr); // if (row != null) // { // if (row.type == SongRow.Type.BEAT) // { // rowsBeat.Add(row); // } // else // { // if (row.type == SongRow.Type.BPM) // rowsBpm.Add(row); // else // if (row.type == SongRow.Type.BOX) // rowsBox.Add(row); // else // if (row.type == SongRow.Type.LANE_POS) // rowsLanePositions.Add(row); // } // } //} isLoading = false; Debug.Log("SongLoader loaded pattern " + rowsBeat.Count + " beats, " + rowsBox.Count + " boxes, " + rowsBpm.Count + " bpms, " + rowsLanePositions.Count + " lanePositions"); Dictionary <SongRow.Type, List <SongRow> > rows = new Dictionary <SongRow.Type, List <SongRow> >(); rows.Add(SongRow.Type.BPM, rowsBpm); rows.Add(SongRow.Type.BOX, rowsBox); rows.Add(SongRow.Type.BEAT, rowsBeat); rows.Add(SongRow.Type.LANE_POS, rowsLanePositions); songData.rows = rows; songReady(songData); //lane pos format: first three for 4,6,8 lanes, then 4,6,8,timestamp if it changes during song } else { //TODO rhythmAnalyzer.Abort if stopping before finished... but that should never happen Debug.Log("************* SONGLOADER.ANALYZE " + clip.name); //rhythmAnalyzer.Analyze(audioSource.clip, (int)(audioSource.clip.length - 1)); //clip.loadState == AudioDataLoadState.Loaded rhythmData = rhythmAnalyzer.Analyze(clip, (int)processedData); } }
private void OnInitialized(RhythmData rhythmData) { //Start playing the song. player.Play(); }