void OnSongChanged(Song song) { // TODO: do some checks to see whether it was a transition (the old song was finished // playing) or a user-invoked skip. // for now, just stop recording the current track and start recording the new one if(isRecording){ // stop existing invocations of AddHeadsetData, then save the data CancelInvoke("AddHeadsetData"); // determine the highest and next highest bar, and their colors int highestIndex = 0; int secondIndex = 0; int highestValue = 0; if(eq.bars[0].topBarCounter / 4 >= eq.bars[1].topBarCounter){ highestValue = eq.bars[0].topBarCounter / 4; highestIndex = 0; secondIndex = 1; } else { highestValue = eq.bars[1].topBarCounter; highestIndex = 1; secondIndex = 0; } for(int i = 1; i < eq.bars.Length; i++){ GraphBar b = eq.bars[i]; if(b.topBarCounter > highestValue){ highestValue = b.topBarCounter; secondIndex = highestIndex; highestIndex = i; } } Color c = (0.6f * eq.bars[highestIndex].color) + (0.4f * eq.bars[secondIndex].color); //MessageBox.Show(Localizer.Content["datarecorder"]["saveddata"], MessageBox.MessageType.Message); MessageBox.ShowSwatch(Localizer.Content["datarecorder"]["saveddata"], c, swatch); eq.ResetBarCounters(); data.Write(System.IO.Path.Combine(UserStatus.dataPath, data.song.DataFileName)); // create a new data container, and start tossing in data data = new BrainMusicData(song); InvokeRepeating("AddHeadsetData", 0.0f, 0.9f); elapsedTime = 0.0; } // if a new song is played, then dispatch the relevant events if(isPlaying){ BrainMusicData b = BrainMusicData.Load(System.IO.Path.Combine(UserStatus.dataPath, song.DataFileName)); if(b == null){ MessageBox.Show(Localizer.Content["datarecorder"]["playnodata"], MessageBox.MessageType.Message); DispatchStoppedPlaying(); GameHelper.SendMessageToAll("OnUnloadBrainMusicData", null, SendMessageOptions.DontRequireReceiver); } else { GameHelper.SendMessageToAll("OnLoadNextBrainMusicData", b, SendMessageOptions.DontRequireReceiver); } } }
void OnLoadBrainMusicData(BrainMusicData b) { updateDataThreadActive = false; updateThread.Abort(); dataPlayer = b; elapsedTime = 0.0; Invoke("UpdateDataValues", 1.0f); InvokeRepeating("UpdateElapsedTimeFromITunes", 0.0f, 4.0f); }
/* * VIEW EVENTS */ void OnRecordClicked(Song song) { iTunesConnector.backTrack(); data = new BrainMusicData(song); InvokeRepeating("AddHeadsetData", 0.0f, 1.0f); elapsedTime = 0.0; if(isPlaying) OnStopPlayClicked(); DispatchStartedRecording(); }
void OnLoadNextBrainMusicData(BrainMusicData b) { updateDataThreadActive = false; updateThread.Abort(); elapsedTime = 0.0; dataPlayer = b; Invoke("UpdateDataValues", 1.0f); }