public void RemoveSongFromPlaylist(UltraStarPlaylist playlist, SongMeta songMeta) { playlist.RemoveSongEntry(songMeta.Artist, songMeta.Title); playlistChangeEventStream.OnNext(new PlaylistChangeEvent(playlist, songMeta)); SavePlaylist(playlist); }
public LocalStatistic GetLocalStats(SongMeta songMeta) { LocalStatistics.TryGetValue(songMeta.SongHash, out LocalStatistic result); return(result); }
public void RecordSongStarted(SongMeta songMeta) { LocalStatistics.GetOrInitialize(songMeta.SongHash).UpdateSongStarted(); IsDirty = true; }
private bool IsFavorite(SongMeta songMeta) { return(songMeta != null && playlistManager.FavoritesPlaylist.HasSongEntry(songMeta.Artist, songMeta.Title)); }
public void MultiplyBpmAndNotify(SongMeta songMeta, int factor) { MultiplyBpm(songMeta, factor); songMetaChangeEventStream.OnNext(new SongPropertyChangedEvent(ESongProperty.Bpm)); }
public void MoveNotesToVoiceAndNotify(SongMeta songMeta, List <Note> selectedNotes, string voiceName) { MoveNotesToVoice(songMeta, selectedNotes, voiceName); songMetaChangeEventStream.OnNext(new MovedNotesToVoiceEvent(selectedNotes)); }
public static double MillisecondInSongToBeat(SongMeta songMeta, double millisInSong) { return(MillisecondInSongToBeatWithoutGap(songMeta, millisInSong - songMeta.Gap)); }
public void Init(SongMeta songMeta, SongAudioPlayer songAudioPlayer) { this.SongMeta = songMeta; this.SongAudioPlayer = songAudioPlayer; InitVideo(songMeta); }
public void RecordSongStarted(SongMeta songMeta) { GetOrInitialize <LocalStatistic>(LocalStatistics, songMeta.SongHash).UpdateSongStarted(); TriggerDatabaseWrite(); }
public void ReduceBpmAndNotify(SongMeta songMeta) { ReduceBpm(songMeta); songMetaChangeEventStream.OnNext(new BpmChangeEvent()); }
public void MultiplyBpmAndNotify(SongMeta songMeta, int factor) { MultiplyBpm(songMeta, factor); songMetaChangeEventStream.OnNext(new BpmChangeEvent()); }
private void preDownload(SongMeta song) { Debug.LogFormat("Predonwloading {0}", song); APICacheManager.Instance.downloadAudio(song.musicPath, (clip) => { }); }
public PlaylistChangeEvent(UltraStarPlaylist playlist, SongMeta songMeta) { Playlist = playlist; SongMeta = songMeta; }
public void AddSongToPlaylist(UltraStarPlaylist playlist, SongMeta songMeta) { playlist.AddLineEntry(new UltraStartPlaylistSongEntry(songMeta.Artist, songMeta.Title)); playlistChangeEventStream.OnNext(new PlaylistChangeEvent(playlist, songMeta)); SavePlaylist(playlist); }
public void SubmitSearch() { selectedSongBeforeSearch = SelectedSong; songSearchControl.ResetSearchText(); }
public static List <Sentence> GetSentencesAtBeat(SongMeta songMeta, int beat) { return(songMeta.GetVoices().SelectMany(voice => voice.Sentences) .Where(sentence => IsBeatInSentence(sentence, beat)).ToList()); }
private void UpdateSongDetailsInOverlay() { songDetailOverlayScrollView.Clear(); SongMeta songMeta = SelectedSong; if (songMeta == null) { return; } Label CreateSongDetailLabel(string fieldName, object fieldValue) { Label label = new(); label.enableRichText = true; label.AddToClassList("songDetailOverlayLabel"); string fieldValueDisplayString = fieldValue?.ToString(); fieldValueDisplayString = fieldValueDisplayString.IsNullOrEmpty() ? "-" : fieldValueDisplayString; label.text = $"<b><u>{fieldName}</u></b>: {fieldValueDisplayString}"; return(label); } songDetailOverlayScrollView.Add(CreateSongDetailLabel("Artist", songMeta.Artist)); songDetailOverlayScrollView.Add(CreateSongDetailLabel("Title", songMeta.Title)); songDetailOverlayScrollView.Add(CreateSongDetailLabel("Genre", songMeta.Genre)); songDetailOverlayScrollView.Add(CreateSongDetailLabel("Year", songMeta.Year > 0 ? songMeta.Year : null)); songDetailOverlayScrollView.Add(CreateSongDetailLabel("Audio", songMeta.Mp3)); songDetailOverlayScrollView.Add(CreateSongDetailLabel("Gap", songMeta.Gap)); songDetailOverlayScrollView.Add(CreateSongDetailLabel("Bpm", songMeta.Bpm)); songDetailOverlayScrollView.Add(CreateSongDetailLabel("Video", songMeta.Video)); songDetailOverlayScrollView.Add(CreateSongDetailLabel("Video Gap", songMeta.VideoGap)); songDetailOverlayScrollView.Add(CreateSongDetailLabel("Cover", songMeta.Cover)); songDetailOverlayScrollView.Add(CreateSongDetailLabel("Language", songMeta.Language)); songDetailOverlayScrollView.Add(CreateSongDetailLabel("Edition", songMeta.Edition)); songDetailOverlayScrollView.Add(new Label("\n")); songMeta.VoiceNames.Keys.ForEach(voiceNameKey => { string lyrics = SongMetaUtils.GetLyrics(songMeta, voiceNameKey); if (lyrics.IsNullOrEmpty()) { return; } if (voiceNameKey != Voice.soloVoiceName) { Label voiceNameLabel = new(); voiceNameLabel.enableRichText = true; voiceNameLabel.AddToClassList("songDetailOverlayLabel"); string voiceName = songMeta.VoiceNames[voiceNameKey]; string voiceNameText = voiceName != voiceNameKey ? $" ({voiceName})" : ""; voiceNameLabel.text = $"<b>{voiceNameKey}{voiceNameText}</b>"; songDetailOverlayScrollView.Add(voiceNameLabel); } Label lyricsLabel = new(); lyricsLabel.AddToClassList("songDetailOverlayLabel"); lyricsLabel.text = lyrics; songDetailOverlayScrollView.Add(lyricsLabel); songDetailOverlayScrollView.Add(new Label("\n")); }); }
public static string GetAbsoluteSongFilePath(SongMeta songMeta) { return(songMeta.Directory + Path.DirectorySeparatorChar + songMeta.Mp3); }
public SongMeta FindSongMeta(Func <SongMeta, bool> predicate) { SongMeta songMeta = songMetas.Where(predicate).FirstOrDefault(); return(songMeta); }
// Returns the notes in the song as well as the notes in the layers in no particular order. public static List <Note> GetAllNotes(SongMeta songMeta) { List <Note> result = GetAllSentences(songMeta).SelectMany(sentence => sentence.Notes).ToList(); return(result); }
public static double BeatToMillisecondsInSong(SongMeta songMeta, double beat) { return(BeatToMillisecondsInSongWithoutGap(songMeta, beat) + songMeta.Gap); }
private int GetSongIndex(SongMeta songMeta) { return(songs.IndexOf(songMeta)); }
public void ReduceBpmAndNotify(SongMeta songMeta) { ReduceBpm(songMeta); songMetaChangeEventStream.OnNext(new SongPropertyChangedEvent(ESongProperty.Bpm)); }
public void ExecuteAndNotify(SongMeta songMeta, int beat, int midiNote) { Execute(songMeta, beat, midiNote); songMetaChangeEventStream.OnNext(new NotesAddedEvent()); }
public static void WriteFile(string absolutePath, SongMeta songMeta) { string txtFileContent = GetTxtFileContent(songMeta); File.WriteAllText(absolutePath, txtFileContent, Encoding.UTF8); }
public static double GetBeatsPerMinute(SongMeta songMeta) { // Ultrastar BPM is not "beats per minute" but "bars per minute" in four-four-time. // To get the common "beats per minute", one has to multiply with 4. return(songMeta.Bpm * 4.0); }
public WebStatistic GetWebStats(SongMeta songMeta) { WebStatistics.TryGetValue(songMeta.SongHash, out WebStatistic result); return(result); }
public static double GetBeatsPerSecond(SongMeta songMeta) { return(GetBeatsPerMinute(songMeta) / 60.0); }
private void DrawVoice(int songDurationInMillis, SongMeta songMeta, Voice voice, Color color) { DrawAlternatingSentenceBackgrounds(songDurationInMillis, songMeta, voice); DrawNotes(songDurationInMillis, songMeta, voice, color); }
public MovedNotesToVoiceEvent MoveNotesToVoice(SongMeta songMeta, List <Note> selectedNotes, string voiceName) { Voice targetVoice = SongMetaUtils.GetOrCreateVoice(songMeta, voiceName); List <Sentence> changedSentences = new(); List <Sentence> removedSentences = new(); List <Sentence> createdSentences = new(); List <SentenceWithRange> createdSentencesWithRange = new(); List <Sentence> sortedTargetSentences = targetVoice.Sentences.ToList(); sortedTargetSentences.Sort(Sentence.comparerByStartBeat); selectedNotes.Sort(Note.comparerByStartBeat); selectedNotes.ForEach(note => { Sentence oldSentence = note.Sentence; // Find or create a sentence in the target voice for the note Sentence targetSentence; Sentence existingTargetSentence = SongMetaUtils.FindExistingSentenceForNote(sortedTargetSentences, note); if (existingTargetSentence == null) { SentenceWithRange existingSentenceWithRange = createdSentencesWithRange .FirstOrDefault(sentenceWithRange => sentenceWithRange.ContainsBeatRange(note.StartBeat, note.EndBeat)); if (existingSentenceWithRange != null) { existingTargetSentence = existingSentenceWithRange.Sentence; } } if (existingTargetSentence != null) { targetSentence = existingTargetSentence; } else { // Create sentence to fill the gap between adjacent sentences. Sentence previousSentence = sortedTargetSentences .LastOrDefault(sentence => sentence.MaxBeat < note.StartBeat); Sentence nextSentence = sortedTargetSentences .LastOrDefault(sentence => sentence.MinBeat > note.EndBeat); int newSentenceFromBeat = previousSentence != null ? previousSentence.ExtendedMaxBeat : int.MinValue; int newSentenceUntilBeat = nextSentence != null ? nextSentence.MinBeat : int.MaxValue; Sentence createdSentence = new(newSentenceFromBeat, newSentenceUntilBeat); createdSentence.SetVoice(targetVoice); createdSentences.Add(createdSentence); sortedTargetSentences.Add(createdSentence); sortedTargetSentences.Sort(Sentence.comparerByStartBeat); // Remember this sentence with its full range (that fills the gap between adjacent sentences) // The MinBeat and MaxBeat of the sentence will change to fit the notes, // such that the original range has to be stored in a dedicated data structure. createdSentencesWithRange.Add(new SentenceWithRange(createdSentence, newSentenceFromBeat, newSentenceUntilBeat)); targetSentence = createdSentence; } targetSentence.AddNote(note); // Set lyrics if none yet (otherwise, there is a warning because of missing lyrics) if (note.Text.IsNullOrEmpty()) { note.SetText(" "); } changedSentences.Add(targetSentence); if (oldSentence != null) { // Remove old sentence if empty now if (oldSentence.Notes.Count == 0 && oldSentence.Voice != null) { removedSentences.Add(oldSentence); oldSentence.SetVoice(null); } else { changedSentences.Add(oldSentence); } } }); // Fit sentences to their notes (make them as small as possible) changedSentences .Union(createdSentences) .ForEach(sentence => { sentence.FitToNotes(); }); return(new MovedNotesToVoiceEvent(selectedNotes, changedSentences, removedSentences)); }