/// <summary> /// Play the current song. /// </summary> public void PlayCurrentSong(int songIndex) { //StartCoroutine(LoadSong(_songsData[_currentSongIndex], true)); // Decomment if streaming audio data _currentSongIndex = songIndex; if (_clips.Count != 0) { _audioSource.clip = _clips[_currentSongIndex]; } else { Debug.LogError("AudioFileLoader: AudioSource.clip could not be assigned."); } if (_audioSource.clip != null) { _audioSource.Play(); } else { Debug.LogError("No AudioClip attached to Camera.main.AudioSource"); } if (_songTitle != null) { SongTimer.Set(_songTitle, Path.GetFileNameWithoutExtension(_songsData[_currentSongIndex]._tempDir)); } if (_songTime != null) { SongTimer.SetSongTime(_songTime, _audioSource.clip.length); } Debug.Log("Playing " + _songsData[_currentSongIndex]._tempDir); }
public void Update(float dt) { if (!SongTimer.isSongRunning) { return; } float leadin = SongTimer.LeadInRatio(); float moveDown = Mathf.Cos(SongTimer.TimedValue()) * leadin; float moveSideway = Mathf.Sin(SongTimer.TimedValue(4f)) * leadin; hip.bone.position = hip.initialWorldPosition + new Vector3(moveSideway * .1f, moveDown * .1f, 0); leg_upper.bone.position = leg_upper.initialWorldPosition + new Vector3(moveSideway * .08f, moveDown * .08f, 0); leg_lower.bone.position = leg_lower.initialWorldPosition + new Vector3(moveSideway * .05f, moveDown * .05f, 0); leg_heel.bone.position = leg_heel.initialWorldPosition + new Vector3(moveSideway * .02f, moveDown * .02f, 0); if (isLeft) { float tap = Mathf.Sin(SongTimer.TimedValue(8f)) * leadin; tap -= 1f - 1f / 36f; leg_feet.bone.position = leg_feet.initialWorldPosition + new Vector3(0, Mathf.Max(tap, 0) * 5f, 0); //leg_feet.bone.position = leg_feet.initialWorldPosition; } }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (EventTimer != null) { EventTimer.Stop(); EventTimer.Enabled = false; EventTimer.Elapsed -= ElapsedEventTick; EventTimer.Dispose(); EventTimer = null; } if (SongTimer != null) { SongTimer.Stop(); SongTimer.Enabled = false; SongTimer.Elapsed -= ElapsedSongTick; SongTimer.Dispose(); SongTimer = null; } } _disposed = true; }
private void BTN_Stop_Click(object sender, EventArgs e) { this.player.Stop(); SongTimer.Stop(); PRG_SongProgress.Value = 0; LBL_SongPercent.Text = ""; }
/// <summary> /// Play the previous song. /// </summary> void PlayPreviousSong() { _audioSource.Stop(); _audioSource.timeSamples = 0; if (_currentSongIndex == 0) { _currentSongIndex = _files.Length - 1; } else { _currentSongIndex = _currentSongIndex < 0 ? _currentSongIndex = 0 : --_currentSongIndex; } _audioSource.clip = _clips[_currentSongIndex]; _audioSource.Play(); if (_songTitle != null) { SongTimer.Set(_songTitle, Path.GetFileNameWithoutExtension(_songsData[_currentSongIndex]._tempDir)); } if (_songTime != null) { SongTimer.SetSongTime(_songTime, _audioSource.clip.length); } Debug.Log("Playing " + _songsData[_currentSongIndex]._tempDir); }
private void button14_Click(object sender, EventArgs e) { ClosingBool = true; SongTimer.CancelAsync(); ClosingBool = false; this.Hide(); this.ShowInTaskbar = false; Form2 f2 = new Form2(); try { f2.Show(); } catch { try { f2.Activate(); } catch { MessageBox.Show("The F**k?"); } } }
public void Update(float dt) { Vector2 stick = input.GetRightStick(); stick.x = stick.x * -1f; stick.y = stick.y * -1f; stick.x = Mathf.MoveTowards(currentAppliedVector2.x, stick.x, 18f * dt); stick.y = Mathf.MoveTowards(currentAppliedVector2.y, stick.y, 18f * dt); currentAppliedVector2 = stick; if (birdControl.DEBUG_ENABLE_KEYBOARD) { const float MOV_AMOUNT = 0.15f; if (Input.GetKey(KeyCode.T)) { _keyboardInput.y -= MOV_AMOUNT; } if (Input.GetKey(KeyCode.G)) { _keyboardInput.y += MOV_AMOUNT; } _keyboardInput.y = Mathf.Clamp(_keyboardInput.y, -1f, 1f); if (Input.GetKey(KeyCode.F)) { _keyboardInput.x += MOV_AMOUNT; } if (Input.GetKey(KeyCode.H)) { _keyboardInput.x -= MOV_AMOUNT; } _keyboardInput.x = Mathf.Clamp(_keyboardInput.x, -1f, 1f); stick = _keyboardInput; _keyboardInput.y *= 0.9f; _keyboardInput.x *= 0.9f; } //body.bone.localPosition = body.initialLocalPosition + new Vector3(stick.x * BODY_POS_MOD, stick.y * BODY_POS_MOD); body.bone.localRotation = body.initialLocalRotation * Quaternion.AngleAxis(Mathf.Lerp(-10f, 20f, (stick.y + 1f) / 2f), Vector3.right) * Quaternion.AngleAxis(Mathf.Lerp(-ROTATE_SIDEWAYS, ROTATE_SIDEWAYS, (stick.x + 1f) / 2f), Vector3.forward); if (SongTimer.isSongRunning) { float moveDown = Mathf.Cos(SongTimer.TimedValue()) * SongTimer.LeadInRatio(); float moveSideway = Mathf.Sin(SongTimer.TimedValue(4f)) * SongTimer.LeadInRatio(); body.bone.position = body.initialWorldPosition + new Vector3(moveSideway * .1f, moveDown * .1f, 0); } }
// Called with Invoke() in Start() // ReSharper disable once UnusedMember.Local private void delayedSongStart() { source.Play(); songStarted = true; SongTimer.sourceToSampleTimeFrom = source; SongTimer.StartSong(128f, DelayForBeats); _rhythmStartTime = source.time; }
public async void ElapsedEventTick(object sender, ElapsedEventArgs e) { SpotifyLatestStatus = await SpotifyProcess.GetSpotifyStatus(); if (SpotifyLatestStatus?.CurrentTrack == null) { EventTimer.Start(); return; } var newestTrack = SpotifyLatestStatus.CurrentTrack; if (Track != null) { if (newestTrack.Playing != Track.Playing) { if (newestTrack.Playing) { SongTimer.Start(); } else { SongTimer.Stop(); } await Task.Run(() => OnPlayStateChange?.Invoke(this, new PlayStateEventArgs() { Playing = newestTrack.Playing })); } if (!newestTrack.Equals(Track)) { SongTimer.Start(); await Task.Run(async() => OnTrackChange?.Invoke(this, new TrackChangeEventArgs() { OldTrack = Track, NewTrack = await SpotifyLatestStatus.GetTrack() })); } if (Track.CurrentPosition != null || newestTrack != null) { await Task.Run(() => OnTrackTimeChange?.Invoke(this, new TrackTimeChangeEventArgs() { TrackTime = newestTrack.Equals(Track) ? Track?.CurrentPosition ?? 0 : 0 })); } } if (newestTrack != null) { newestTrack.CurrentPosition = newestTrack.Equals(Track) ? Track?.CurrentPosition ?? 0 : (int?)null; Track = newestTrack; } EventTimer.Start(); }
// Use this for initialization void Start() { if (DEBUG_StartSongTimer) { SongTimer.StartSong(DEBUG_BPM); } if (DEBUG_InitControllerOnStart) { _initializeController(); } }
// Update is called once per frame void Update() { if (_audioSource == null) { if (GameSceneManager.Instance._newScene == "Level") { GetAudioSource(); } else if (GameSceneManager.Instance._newScene == "Menu") { GetAudioSource(); PlayCurrentSong(_selectedSongIndex); } } PlayAudioOnStartGame(); #region Keyboard Input Logic //if (Input.GetKeyDown(KeyCode.Return)) //{ // if (AudioListener.pause == true) // { // AudioListener.pause = false; // GameMaster.Instance.GameState = GameMaster.GamePlayState.PLAYING; // } // else if (AudioListener.pause == false) // { // AudioListener.pause = true; // GameMaster.Instance.GameState = GameMaster.GamePlayState.PLAY_IDLE; // } // if (!_audioSource.isPlaying) // { // PlayCurrentSong(_currentSongIndex); // _isPlaying = true; // } //} if (Input.GetKeyDown(KeyCode.RightArrow)) { PlayNextSong(); } if (Input.GetKeyDown(KeyCode.LeftArrow)) { PlayPreviousSong(); } if (GameMaster.Instance.GameState == GameMaster.GamePlayState.PLAYING) { Debug.Log("Song Timer updating..."); StartCoroutine(SongTimer.UpdateSongTime(_songTime)); } #endregion }
public void Dispose() { if (EventTimer != null) { EventTimer.Enabled = false; EventTimer.Elapsed -= ElapsedEventTick; EventTimer.Dispose(); } if (SongTimer != null) { SongTimer.Enabled = false; SongTimer.Elapsed -= ElapsedSongTick; SongTimer.Dispose(); } }
private void btnPlay_Click(object sender, EventArgs e) { if (listBoxSongs.SelectedItems.Count < 1) { return; } int index = listBoxSongs.Items.IndexOf(listBoxSongs.SelectedItems[0]); player.SoundLocation = path[index]; setSongSlider(path[index]); player.Play(); SetStartParameters(); SongTimer.Interval = timerInterval; SongTimer.Start(); }
/// <summary> /// Play the next song. /// </summary> void PlayNextSong() { _audioSource.Stop(); _audioSource.timeSamples = 0; _currentSongIndex = (_currentSongIndex == _files.Length - 1) ? _currentSongIndex = 0 : ++_currentSongIndex; _audioSource.clip = _clips[_currentSongIndex]; _audioSource.Play(); if (_songTitle != null) { SongTimer.Set(_songTitle, Path.GetFileNameWithoutExtension(_songsData[_currentSongIndex]._tempDir)); } if (_songTime != null) { SongTimer.SetSongTime(_songTime, _audioSource.clip.length); } Debug.Log("Playing " + _songsData[_currentSongIndex]._tempDir); //StartCoroutine(LoadSong(_songsData[_currentSongIndex], true)); // Decomment if streaming audio data }
private void SongTimer_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (ClosingBool == false) { try { label1.Invoke((MethodInvoker) delegate { string TempString = label1.Text; label1.Text = "Now Playing" + Environment.NewLine + madHax.SongInformation(); if (label1.Text != TempString && checkBox1.Checked == true) { ToastNotification(); } }); if (ManualMode == false) { SongTimer.RunWorkerAsync(); } } catch {} } }
// Use this for initialization void Start() { Debug.LogWarning("[CanvasHandler] Needs to pass the songs bpm the timer, not a hardcoded float."); SongTimer.StartSong(128f); }
private void BTN_Play_Click(object sender, EventArgs e) { this.player.Play(); SongTimer.Start(); }
private void Form1_Load(object sender, EventArgs e) { madHax.GUIConsoleWriter(); madHax.readIP(); var parser = new FileIniDataParser(); IniData data = parser.ReadFile("Configuration.ini"); #region Station Buttons station1.Text = madHax.dynStationName(1); station2.Text = madHax.dynStationName(2); station3.Text = madHax.dynStationName(3); station4.Text = madHax.dynStationName(4); station5.Text = madHax.dynStationName(5); station6.Text = madHax.dynStationName(6); station7.Text = madHax.dynStationName(7); station8.Text = madHax.dynStationName(8); station9.Text = madHax.dynStationName(9); station10.Text = madHax.dynStationName(10); #region Station Button ToolTips toolTip1.SetToolTip(station1, madHax.dynStationTip(1)); toolTip1.SetToolTip(station2, madHax.dynStationTip(2)); toolTip1.SetToolTip(station3, madHax.dynStationTip(3)); toolTip1.SetToolTip(station4, madHax.dynStationTip(4)); toolTip1.SetToolTip(station5, madHax.dynStationTip(5)); toolTip1.SetToolTip(station6, madHax.dynStationTip(6)); toolTip1.SetToolTip(station7, madHax.dynStationTip(7)); toolTip1.SetToolTip(station8, madHax.dynStationTip(8)); toolTip1.SetToolTip(station9, madHax.dynStationTip(9)); toolTip1.SetToolTip(station10, madHax.dynStationTip(10)); #endregion Station Button ToolTips #endregion Station Buttons #region MiniPlayer Color try { checkBox1.Checked = Convert.ToBoolean(data["Config"]["Notifications"]); } catch { checkBox1.Checked = false; } foreach (PropertyInfo prop in typeof(Color).GetProperties()) { if (prop.PropertyType.FullName == "System.Drawing.Color") { comboBox1.Items.Add(prop.Name); } } if (comboBox1.Items.Contains(data["Config"]["MiniPlayerColor"]) == true) { comboBox1.SelectedItem = data["Config"]["MiniPlayerColor"]; } else if (comboBox1.Items.Contains(data["Config"]["MiniPlayerColor"]) == true || data["Config"]["MiniPlayerColor"] == "" || data["Config"]["MiniPlayerColor"] == null) { comboBox1.SelectedItem = "White"; data["Config"]["MiniPlayerColor"] = "White"; parser.WriteFile("Configuration.ini", data); } #endregion label1.Text = "Now Playing" + Environment.NewLine + madHax.SongInformation(); SongTimer.RunWorkerAsync(); }
public async Task TriggerEvents() { // avoid concurrences if (_processingEvents == true) { return; } _processingEvents = true; SpotifyLatestStatus = await SpotifyProcess.GetSpotifyStatus(); if (SpotifyLatestStatus?.CurrentTrack != null) { var newestTrack = SpotifyLatestStatus.CurrentTrack; if (Track != null) { if (newestTrack.Playing != Track.Playing) { if (newestTrack.Playing) { SongTimer?.Start(); } else { SongTimer?.Stop(); } _ = Task.Run(() => OnPlayStateChange?.Invoke(this, new PlayStateEventArgs() { Playing = newestTrack.Playing })); } if (!newestTrack.Equals(Track)) { SongTimer?.Start(); _ = Task.Run(async() => OnTrackChange?.Invoke(this, new TrackChangeEventArgs() { OldTrack = Track, NewTrack = await SpotifyLatestStatus.GetTrack() })); } if (Track.CurrentPosition != null || newestTrack != null) { _ = Task.Run(() => OnTrackTimeChange?.Invoke(this, new TrackTimeChangeEventArgs() { TrackTime = newestTrack.Equals(Track) ? Track?.CurrentPosition ?? 0 : 0 })); } } if (newestTrack != null) { newestTrack.CurrentPosition = newestTrack.Equals(Track) ? Track?.CurrentPosition ?? 0 : (int?)null; Track = newestTrack; } } EventTimerStart(); _processingEvents = false; }
private void BtnStop_Click(object sender, EventArgs e) { player.Stop(); SongTimer.Stop(); }