public void PlayMusic(uint time = 0) { TimeBegan = 1; setMusicPositionToUsCooldown = setMusicPositionToUsReset; hasSetMusicPositionToUs = false; Music.setStarted(true); Music.SetTimePosition((uint)Math.Max(0, (int)time - timePositionSetOffset)); Music.SetVolume(MusicVolume); }
private void Start_Click(object sender, EventArgs e) { if (songs.Text == "") { } else { //set difficulty SetDifficulty(difficulty.Text); delay = (280 / gamespeed); //create a new instance of beat detector and load FMOD system detector = BeatDetector.Instance(); detector.loadSystem(); //load song in array detector.LoadSong(1024, songPaths[currentSongIndex]); //delay spawn to time beats detector.loadSongToDelay(delay); //start the song detector.setStarted(true); //start gravity timer gravity.Enabled = true; gravity.Start(); //hide main menu UI start.Visible = false; songs.Visible = false; loadSongs.Visible = false; difficulty.Visible = false; topEU.SendToBack(); //show in-game UI DisplayScore(); SetHitField(); SetHitBar(); highScore.Visible = true; scoreDisplay.Visible = true; NowPlaying(); np.Visible = true; np.Text = "Now Playing:\n" + songs.Text; Focus(); } }
//public Task GetDetectionTask() //{ //} public void DetectAndReportBeats() { detector.setStarted(true); while (true) { detector.update(); lastBeat = detector.getLastBeat(); //I'm sure no song has a bpm higher than 6000 so //it's safe to sleep 10ms before checking if a new beat has been detected //This will also save a lot of processing power. Thread.Sleep(10); if (detector.getLastBeat() != null && lastBeat != null) { if (lastBeat.getMilliseconds() != detector.getLastBeat().getMilliseconds()) { reportLastBeat(); } } } }