private void debugButton1_Click(object sender, EventArgs e) { string fileDirectory = songFile.FileDirectory; float valueThreshold = (float)Convert.ToDouble(debugTextBox4.Text); float maximumSquaredError = (float)Convert.ToDouble(debugTextBox5.Text); SongPropertyValues spv = SongAnalyzer.GetSongPropertyValues(fileDirectory, valueThreshold, maximumSquaredError); if (lastSeries != null) { songValueChart.Series.Remove(lastSeries); } PlotSPVTest(spv); Update(); }
// Start is called before the first frame update private void Awake() { instance = this; }
void NextBar(int currentBar) { // Check if song is null, and continue checking until it is not if (song == null) { song = Song.GetCurrentSong(); events = SongAnalyzer.generateEventList(song); currentEvent = 0; pianoRollEvent = 0; /* * tolerance = SongAnalyzer.generateEventList(song, BEATS_TO_TOLERATE); * toleranceRunner = 0; * activeNotes = new HashSet<int>();*/ } else { ClearBar(); if (currentBar == 0) { currentEvent = 0; pianoRollEvent = 0; //toleranceRunner = 0; bar_prev1 = new Bar(new List <Note>()); foreach (var key in ErrorKeys) { keyHighlighter.SetKeyHighlight(false, key.Key); ErrorKeys.Remove(key.Key); } } else { bar_prev1 = song.GetBars()[currentBar - 1]; } bar = song.GetBars()[currentBar]; if (currentBar + 1 >= song.GetBars().Count) { bar_next1 = new Bar(new List <Note>()); } else { bar_next1 = song.GetBars()[currentBar + 1]; } if (currentBar + 2 >= song.GetBars().Count) { bar_next2 = new Bar(new List <Note>()); } else { bar_next2 = song.GetBars()[currentBar + 2]; } RenderBar(bar, 0, false); // 0 is current bar RenderBar(bar_prev1, 1, true); // 0 is current bar RenderBar(bar_next1, 2, true); // 0 is current bar RenderBar(bar_next2, 3, true); // 0 is current bar } }
// Update is called once per frame void Update() { if (HasSongChanged()) { Timing.ClearSongUpdatedFlag(); // If the song has changed, #1 -- Get the new song and generate the pending roll key list. song = Song.GetCurrentSong(); events = SongAnalyzer.generateEventList(song); currentEvent = 0; pianoRollEvent = 0; // #2 - clear error keys, regardless of expiration. Not sure why, but without this step, // keys can be redrawn as error keys after they are destroyed. foreach (var key in ErrorKeys) { keyHighlighter.SetKeyHighlight(false, key.Key); ErrorKeys.Remove(key.Key); } // #3 - Destroy all piano roll keys, and prepare the first bar keyHighlighter.DestroyAllPianoRollItems(); NextBar(0); LastBar = 1; } else { CurrentBar = Timing.GetCurrentBar(); if (CurrentBar != LastBar) { NextBar(CurrentBar - 1); } LastBar = CurrentBar; } //figure out what events happened in the last frame and handle it! if (song != null) { /* * //key highlighting. * while (currentEvent < events.Count) * { * SongEvent e = (SongEvent)events[currentEvent]; * if (e.measureNumber <=Timing.CurrentMeasure) * { * //process e. * keyHighlighter.SetKeyHighlight(e.isStart, e.keyID); * currentEvent++; * } * else { break; } * }*/ //tolerance updating: /*while (toleranceRunner < tolerance.Count) * { * SongEvent e = (SongEvent)tolerance[toleranceRunner]; * if (e.MeasureNumber <= Timing.CurrentMeasure) * { * //process e. * if (e.IsStart) activeNotes.Add(e.KeyID); * else activeNotes.Remove(e.KeyID); * toleranceRunner++; * } * else { break; } * }*/ //piano roll float futureTick = Timing.CurrentMeasure + 2 * Timing.BeatsPerMeasure; while (pianoRollEvent < events.Count) { SongEvent e = (SongEvent)events[pianoRollEvent]; if (e.EndPoint <= futureTick) { //process e. startDroplet(e, futureTick); pianoRollEvent++; } else { break; } } // clear error keys, if they have expired foreach (var key in ErrorKeys) { if (key.Value < Timing.CurrentMeasure) { keyHighlighter.SetKeyHighlight(false, key.Key); ErrorKeys.Remove(key.Key); } } } Vector3 oldpos = playhead.transform.position; playhead.transform.position = new Vector3(GetPositionFromBeat(Timing.GetCurrentBeat(), 0), oldpos.y, oldpos.z); }