public Model(Model m) { filter = m.filter; difficulty = m.difficulty; songs = m.songs; allSongs = m.allSongs; difficulties = m.difficulties; songDifficulties = m.songDifficulties; sortTypes = m.sortTypes; songState = m.songState; selectedCategory = m.selectedCategory; categories = m.categories; previewFilePath = m.previewFilePath; previewState = m.previewState; selectedSong = m.selectedSong; selectedDifficulty = m.selectedDifficulty; selectedSortType = m.selectedSortType; selectedPlayingMethod = m.selectedPlayingMethod; allPlayingMethods = m.allPlayingMethods; resetSongScrollPosition = m.resetSongScrollPosition; }
// Use this for initialization void Start() { roomManager = PlayerRoomManager.instance; roomManager.Register(this); trackToAudioSourceMap.Add(track.Drums, new List <AudioSource>() { drums }); trackToAudioSourceMap.Add(track.Percs, new List <AudioSource>() { percs }); trackToAudioSourceMap.Add(track.Melody, new List <AudioSource>() { melody }); trackToAudioSourceMap.Add(track.Lead, new List <AudioSource>() { lead }); trackToAudioSourceMap.Add(track.Bass, new List <AudioSource>() { bass }); trackToAudioSourceMap.Add(track.Ambient, ambient); background.Play(); currentState = defaults; }
public TargetResult(SongTarget target, SongState songState, bool success, Exception?exception) { Target = target; Success = success; SongState = songState; Exception = exception; }
public override async Task <SongState> CheckSongExistsAsync(string songHash) { SongState state = SongState.Wanted; if (SongHasher != null) { if (!SongHasher.Initialized) { await SongHasher.InitializeAsync().ConfigureAwait(false); } if (SongHasher.ExistingSongs.ContainsKey(songHash)) { state = SongState.Exists; } } if (state == SongState.Wanted && HistoryManager != null) { if (!HistoryManager.IsInitialized) { HistoryManager.Initialize(); } if (HistoryManager.TryGetValue(songHash, out HistoryEntry entry)) { if (!entry.AllowRetry) { state = SongState.NotWanted; entry.Flag = HistoryFlag.Deleted; } } } return(state); }
private void ProcessFile(object a) { //ThreadInfo ti = a as ThreadInfo; //ti.File = TagLib.File.Create(ti.Filepath); Title = Path.GetFileNameWithoutExtension(Filepath); if (!LoadFile()) { State = SongState.Invalid; return; } loaded = true; dirty = false; Album = file.Tag.Album; Artist = file.Tag.FirstAlbumArtist; Track = file.Tag.Track; Lyrics = file.Tag.Lyrics; Year = file.Tag.Year.ToString(); Length = file.Length.ToString(); if (file.Tag.Genres.Length > 0) { Genres = file.Tag.Genres; //genre loading appers tp be broken } if (!string.IsNullOrEmpty(file.Tag.Title) && !string.IsNullOrWhiteSpace(file.Tag.Title)) { Title = file.Tag.Title; } LoadAlbumArt(); }
// preplays currently loaded audio track private void PrestartSong() { currentSongPosInBeats = -secondsBeforeStart / currentSecPerBeat; // waiting period dspPreSongTime = (float)AudioSettings.dspTime; songState = SongState.PREPLAYING; songPrestarted?.Invoke(this, EventArgs.Empty); }
private void triggerLeave(Collider collider, VRSensor sensor) { if (audio == SongState.playing) { Speaker.Pause(); audio = SongState.paused; buttonPlayClicked = false; } }
void ChangeState(SongState state) { Debug.Log("Changing state"); if (state == currentState) { return; } currentState.LeaveState(); currentState = state; state.InitState(); }
void SetDownloadState(SongState state) { lock (this) { SongState = state; if (OnModified != null) { OnModified(this); } } }
//plays currently loaded audio track private void StartSong() { if (audioSource.clip == null) { throw new MissingReferenceException("No song currently loaded."); } dspSongTime = (float)AudioSettings.dspTime; audioSource.Play(); songState = SongState.PLAYING; songStarted?.Invoke(this, EventArgs.Empty); }
private void OnEject(int no) { if (cdIn != null) { cdIn = null; var geschwindigkeit = 1.5f; var richtung = new Vector3(9f, 4f, 0f); Speaker.Stop(); //Stop Audio audio = SongState.stopped; //Audio Stopped buttonPlayClicked = false; cd.transform.position += richtung * geschwindigkeit * Time.deltaTime; } }
public static void PauseMusic(String name, SongState state) { AudioFile clip = Array.Find(Instance.audioFiles, AudioFile => AudioFile.audioName == name); if (clip == null) { Debug.LogError("Sound name" + name + "not found!"); return; } else { clip.source.Pause(); } }
public Song(string filePath) { Album = "Untitled"; Artist = "Someone"; Year = "Unknown"; //Genre = "A genre"; Genres = new string[] { "Music Genre" }; loaded = false; Filepath = filePath; Title = Path.GetFileNameWithoutExtension(filePath); if (!System.IO.File.Exists(filePath)) { State = SongState.Invalid; } }
public void NewPlaystate(SongState ss) { //newSong = ss; if (lastSong != ss) { if (ss == SongState.Battle) { MediaPlayer.Play(bbgm); } if (ss == SongState.Menu) { MediaPlayer.Play(mbgm); } lastSong = ss; } }
public void Play(int index) { if (state != SongState.Paused) { state = SongState.Stopped; if (thread == null) { thread = new Thread(new ParameterizedThreadStart(threadLoop)); thread.IsBackground = true; thread.Start(index); } } messageQueue.Enqueue(new SongPlayerPlayMessage(index)); waveOut.Play(); }
// finishes the current song playing, cleanup private void CloseSong() { Debug.Log("song ended"); currentSongPos = 0; currentSongPosInBeats = 0; songState = SongState.STOPPED; audioSource.time = 0; songEnded?.Invoke(this, EventArgs.Empty); Destroy(activeBeatText.gameObject); if (currentBuffer != null) { activeNameSongPopup.Show(); } }
public static void PlaySong(Song song) { switch (state) { case SongState.None: songQueue.Add(song); MediaPlayer.Play(songQueue.First()); state = SongState.Playing; break; case SongState.Playing: if (songQueue.Last().Name != song.Name) { songQueue.Add(song); } break; } }
bool LoadFile() { if (!System.IO.File.Exists(Filepath)) { return(false); } try { file = TagLib.File.Create(Filepath); file.GetTag(TagTypes.AllTags); return(true); } catch (Exception e) { TagLoadingLog.Add(string.Concat("--> Failed to Get All Tags: \n", e.Message, "\n", Filepath)); State = SongState.MissingTags; return(false); // if (file != null) // file.Dispose(); } }
// Update is called once per frame void Update() { //song position is in milliseconds songPosition = vt.timelineInfo.position; //divide by 1000 to get proper beat count songPosInBeats = songPosition / secPerBeat / 1000; bpm = vt.timelineInfo.tempo; secPerBeat = 60f / bpm; if (state == SongState.STARTED && songPosition > 0) { state = SongState.RUNNING; } if (state == SongState.RUNNING && songPosition == 0) { Debug.Log("Song Ended"); state = SongState.STOPPING; SceneManager.LoadScene(2); } }
public static void Update(GameTime gameTime) { if (songQueue.Count > 1 || transition == true) { if (transition == false) { transitionTimer = 0; volumeChangePerTick = -(_normalSongVolume / (SECONDS_FOR_TRANSITION / 2) / 60); //Dela med updates per sec, Finns i TargetElapsedTime i klassen Game if (volumeChangePerTick <= 0) { songQueue.RemoveAt(0); MediaPlayer.Play(songQueue.First()); return; } } transition = true; transitionTimer += (float)gameTime.ElapsedGameTime.TotalSeconds; if (transitionTimer > SECONDS_FOR_TRANSITION / 2 && volumeChangePerTick <= 0) { songQueue.RemoveAt(0); MediaPlayer.Play(songQueue.First()); volumeChangePerTick *= -1; } else if (MediaPlayer.Volume == _normalSongVolume && transitionTimer > SECONDS_FOR_TRANSITION) { transition = false; } MediaPlayer.Volume = Math.Min(_normalSongVolume, Math.Max(MediaPlayer.Volume + volumeChangePerTick, 0)); } else if (songQueue.Count == 0) { state = SongState.None; } }
private void Update() { if (cdIn != null) //CD inserted { if (buttonPlayClicked) //Button on Play Mode { if (audio == SongState.stopped) //Audio stopped { Speaker.Play(); //Playing Audio audio = SongState.playing; //Audio Playing } if (audio == SongState.paused) //Audio playing { Speaker.UnPause(); //Continue Audio audio = SongState.playing; //Audio Plaing } } else if (audio == SongState.playing) { Speaker.Pause(); //Pause Audio audio = SongState.paused; //Audio Paused } } }
public SongInfo(string name, string sourcePath, string targetPath) : this() { Name = name; SourcePath = sourcePath; TargetPath = targetPath; if (!File.Exists(TargetPath)) { State = SongState.New; } else if (!File.Exists(SourcePath)) { State = SongState.Deleted; } else if (File.GetLastWriteTime(SourcePath) > File.GetLastWriteTime(TargetPath)) { State = SongState.Changed; } else { State = SongState.Actual; } }
public DirectoryTargetResult(SongTarget target, SongState songState, bool success, Exception?exception) : base(target, songState, success, exception) { }
// Update is called once per frame void Update() { if (!PauseMenu.IsPaused) { if (music.time > 0 && music.time < 14.5) { songState = SongState.slow; } else if (music.time >= 15.5 && music.time < 24.5) { songState = SongState.buildUp; } else if (music.time >= 24.5 && music.time < 26.5) { songState = SongState.pause; } else if (music.time >= 26.5 && music.time < 36) { songState = SongState.fastTransition; } else if (music.time >= 36 && music.time < 62) { songState = SongState.fastSteady; } else if (music.time >= 62 && music.time < 65) { songState = SongState.fastTransition; } else if (music.time >= 65 && music.time < 75) { songState = SongState.fastSteady; } else if (music.time >= 75 && music.time < 82) { songState = SongState.pause; } else if (music.time >= 82 && music.time < 98) { songState = SongState.slowBuildUp; } else if (music.time >= 98 && music.time < 123) { songState = SongState.slowSteady; } else if (music.time >= 123 && music.time < 126) { songState = SongState.pause; } else if (music.time >= 126 && music.time < 132) { songState = SongState.buildUp; } else if (music.time >= 132 && music.time < 139) { songState = SongState.fastTransition; } else if (music.time >= 139 && music.time < 160) { songState = SongState.fastSteady; } else if (music.time >= 160 && music.time < 172) { songState = SongState.fastSteady; } else if (music.time >= 172) { songState = SongState.finish; } } }
void Start() { songState = SongState.slow; }
/// <summary> /// Starts the job. /// </summary> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task RunAsync(CancellationToken cancellationToken) { JobState = JobState.Running; if (CancellationToken.CanBeCanceled) { CancellationTokenSource?cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, CancellationToken); cancellationToken = cts.Token; cts.Dispose(); cts = null; } JobStage = JobStage.Downloading; Exception? exception = null; bool canceled = false; EventHandler?handler = JobStarted; handler?.Invoke(this, null); DownloadContainer? downloadContainer = null; List <TargetResult> completedTargets = new List <TargetResult>(_targets.Length); List <SongTarget> pendingTargets = new List <SongTarget>(_targets.Length); foreach (SongTarget?target in _targets) { SongState songState = await target.CheckSongExistsAsync(Song).ConfigureAwait(false); if (songState != SongState.Wanted) { completedTargets.Add(new TargetResult(target, songState, true, null)); } else { pendingTargets.Add(target); } } try { cancellationToken.ThrowIfCancellationRequested(); if (string.IsNullOrEmpty(Song.Key)) { SongInfoResponse?result = await WebUtils.SongInfoManager.GetSongByHashAsync(Song.Hash, cancellationToken).ConfigureAwait(false); if (result.Success) { Song.Key = result.Song?.Key; } } if (pendingTargets.Count > 0) { _downloadJob.JobProgressChanged += _downloadJob_JobProgressChanged; DownloadResult = await _downloadJob.RunAsync(cancellationToken).ConfigureAwait(false); downloadContainer = DownloadResult.DownloadContainer; if (DownloadResult.Exception != null) { throw DownloadResult.Exception; } _stageIndex = 1; ReportProgress(JobProgress.CreateDownloadCompletion(CurrentProgress, DownloadResult)); JobStage = JobStage.TransferringToTargets; foreach (TargetResult?targetResult in completedTargets) { _stageIndex++; ReportProgress(JobProgress.CreateTargetCompletion(CurrentProgress, targetResult)); } completedTargets.AddRange(await TransferToTargets(pendingTargets, downloadContainer, cancellationToken).ConfigureAwait(false)); } else { DownloadResult = new DownloadResult(null, DownloadResultStatus.Skipped, 0); _stageIndex = 1; _downloadJob_JobProgressChanged(this, new DownloadJobProgressChangedEventArgs(DownloadJobStatus.Finished)); JobStage = JobStage.TransferringToTargets; foreach (TargetResult?targetResult in completedTargets) { _stageIndex++; ReportProgress(JobProgress.CreateTargetCompletion(CurrentProgress, targetResult)); } } TargetResult[] failedTargets = completedTargets.Where(t => !t.Success).ToArray(); if (failedTargets.Length > 0) { Exception?firstException = failedTargets.FirstOrDefault(t => t.Exception != null)?.Exception; if (firstException != null) { throw firstException; } } TargetResults = completedTargets.ToArray(); } catch (OperationCanceledException ex) { if (TargetResults == null && completedTargets.Count > 0) { TargetResults = completedTargets.ToArray(); } else { TargetResults = Array.Empty <TargetResult>(); } canceled = true; exception = ex; ReportProgress(JobProgress.CreateFromFault(JobProgressType.Cancellation, JobStage, CurrentProgress)); JobState = JobState.Cancelled; } catch (Exception ex) { if (TargetResults == null && completedTargets.Count > 0) { TargetResults = completedTargets.ToArray(); } else { TargetResults = Array.Empty <TargetResult>(); } exception = ex; JobState = JobState.Error; ReportProgress(JobProgress.CreateFromFault(JobProgressType.Error, JobStage, CurrentProgress)); } finally { JobStage = JobStage.Finishing; try { downloadContainer?.Dispose(); } catch { } if (DownloadResult == null) { // TODO: What was this for? } FinishJob(canceled, exception); JobFinishedAsyncCallback?asyncCallback = JobFinishedAsyncCallback; if (asyncCallback != null) { await asyncCallback(Result).ConfigureAwait(false); } } }
public DirectoryTargetResult(SongTarget target, SongState songState, bool success, ZipExtractResult?zipExtractResult, Exception?exception) : base(target, songState, success, exception) { ZipExtractResult = zipExtractResult; }
public void CacheSongState() { _prevState = State; }
public void MakeSearchedState() { CacheSongState(); State = SongState.Searched; }
public void RestorePrevState() { State = _prevState; }