コード例 #1
0
ファイル: PlaylistManager.cs プロジェクト: MairusuPawa/Play
 public void RemoveSongFromPlaylist(UltraStarPlaylist playlist, SongMeta songMeta)
 {
     playlist.RemoveSongEntry(songMeta.Artist, songMeta.Title);
     playlistChangeEventStream.OnNext(new PlaylistChangeEvent(playlist, songMeta));
     SavePlaylist(playlist);
 }
コード例 #2
0
ファイル: Statistics.cs プロジェクト: segmeton/Play
 public LocalStatistic GetLocalStats(SongMeta songMeta)
 {
     LocalStatistics.TryGetValue(songMeta.SongHash, out LocalStatistic result);
     return(result);
 }
コード例 #3
0
ファイル: Statistics.cs プロジェクト: segmeton/Play
 public void RecordSongStarted(SongMeta songMeta)
 {
     LocalStatistics.GetOrInitialize(songMeta.SongHash).UpdateSongStarted();
     IsDirty = true;
 }
コード例 #4
0
 private bool IsFavorite(SongMeta songMeta)
 {
     return(songMeta != null &&
            playlistManager.FavoritesPlaylist.HasSongEntry(songMeta.Artist, songMeta.Title));
 }
コード例 #5
0
 public void MultiplyBpmAndNotify(SongMeta songMeta, int factor)
 {
     MultiplyBpm(songMeta, factor);
     songMetaChangeEventStream.OnNext(new SongPropertyChangedEvent(ESongProperty.Bpm));
 }
コード例 #6
0
 public void MoveNotesToVoiceAndNotify(SongMeta songMeta, List <Note> selectedNotes, string voiceName)
 {
     MoveNotesToVoice(songMeta, selectedNotes, voiceName);
     songMetaChangeEventStream.OnNext(new MovedNotesToVoiceEvent(selectedNotes));
 }
コード例 #7
0
ファイル: BpmUtils.cs プロジェクト: Zeitless/Play
 public static double MillisecondInSongToBeat(SongMeta songMeta, double millisInSong)
 {
     return(MillisecondInSongToBeatWithoutGap(songMeta, millisInSong - songMeta.Gap));
 }
コード例 #8
0
 public void Init(SongMeta songMeta, SongAudioPlayer songAudioPlayer)
 {
     this.SongMeta        = songMeta;
     this.SongAudioPlayer = songAudioPlayer;
     InitVideo(songMeta);
 }
コード例 #9
0
ファイル: Statistics.cs プロジェクト: stjordanis/Play
 public void RecordSongStarted(SongMeta songMeta)
 {
     GetOrInitialize <LocalStatistic>(LocalStatistics, songMeta.SongHash).UpdateSongStarted();
     TriggerDatabaseWrite();
 }
コード例 #10
0
ファイル: ChangeBpmAction.cs プロジェクト: xxxDSSxxx/Play
 public void ReduceBpmAndNotify(SongMeta songMeta)
 {
     ReduceBpm(songMeta);
     songMetaChangeEventStream.OnNext(new BpmChangeEvent());
 }
コード例 #11
0
ファイル: ChangeBpmAction.cs プロジェクト: xxxDSSxxx/Play
 public void MultiplyBpmAndNotify(SongMeta songMeta, int factor)
 {
     MultiplyBpm(songMeta, factor);
     songMetaChangeEventStream.OnNext(new BpmChangeEvent());
 }
コード例 #12
0
 private void preDownload(SongMeta song)
 {
     Debug.LogFormat("Predonwloading {0}", song);
     APICacheManager.Instance.downloadAudio(song.musicPath, (clip) => {
     });
 }
コード例 #13
0
ファイル: PlaylistManager.cs プロジェクト: MairusuPawa/Play
 public PlaylistChangeEvent(UltraStarPlaylist playlist, SongMeta songMeta)
 {
     Playlist = playlist;
     SongMeta = songMeta;
 }
コード例 #14
0
ファイル: PlaylistManager.cs プロジェクト: MairusuPawa/Play
 public void AddSongToPlaylist(UltraStarPlaylist playlist, SongMeta songMeta)
 {
     playlist.AddLineEntry(new UltraStartPlaylistSongEntry(songMeta.Artist, songMeta.Title));
     playlistChangeEventStream.OnNext(new PlaylistChangeEvent(playlist, songMeta));
     SavePlaylist(playlist);
 }
コード例 #15
0
 public void SubmitSearch()
 {
     selectedSongBeforeSearch = SelectedSong;
     songSearchControl.ResetSearchText();
 }
コード例 #16
0
ファイル: SongMetaUtils.cs プロジェクト: Zeitless/Play
 public static List <Sentence> GetSentencesAtBeat(SongMeta songMeta, int beat)
 {
     return(songMeta.GetVoices().SelectMany(voice => voice.Sentences)
            .Where(sentence => IsBeatInSentence(sentence, beat)).ToList());
 }
コード例 #17
0
    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"));
        });
    }
コード例 #18
0
ファイル: SongMetaUtils.cs プロジェクト: Zeitless/Play
 public static string GetAbsoluteSongFilePath(SongMeta songMeta)
 {
     return(songMeta.Directory + Path.DirectorySeparatorChar + songMeta.Mp3);
 }
コード例 #19
0
    public SongMeta FindSongMeta(Func <SongMeta, bool> predicate)
    {
        SongMeta songMeta = songMetas.Where(predicate).FirstOrDefault();

        return(songMeta);
    }
コード例 #20
0
ファイル: SongMetaUtils.cs プロジェクト: Zeitless/Play
    // 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);
    }
コード例 #21
0
ファイル: BpmUtils.cs プロジェクト: Zeitless/Play
 public static double BeatToMillisecondsInSong(SongMeta songMeta, double beat)
 {
     return(BeatToMillisecondsInSongWithoutGap(songMeta, beat) + songMeta.Gap);
 }
コード例 #22
0
 private int GetSongIndex(SongMeta songMeta)
 {
     return(songs.IndexOf(songMeta));
 }
コード例 #23
0
 public void ReduceBpmAndNotify(SongMeta songMeta)
 {
     ReduceBpm(songMeta);
     songMetaChangeEventStream.OnNext(new SongPropertyChangedEvent(ESongProperty.Bpm));
 }
コード例 #24
0
 public void ExecuteAndNotify(SongMeta songMeta, int beat, int midiNote)
 {
     Execute(songMeta, beat, midiNote);
     songMetaChangeEventStream.OnNext(new NotesAddedEvent());
 }
コード例 #25
0
    public static void WriteFile(string absolutePath, SongMeta songMeta)
    {
        string txtFileContent = GetTxtFileContent(songMeta);

        File.WriteAllText(absolutePath, txtFileContent, Encoding.UTF8);
    }
コード例 #26
0
ファイル: BpmUtils.cs プロジェクト: xxxDSSxxx/Play
 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);
 }
コード例 #27
0
ファイル: Statistics.cs プロジェクト: segmeton/Play
 public WebStatistic GetWebStats(SongMeta songMeta)
 {
     WebStatistics.TryGetValue(songMeta.SongHash, out WebStatistic result);
     return(result);
 }
コード例 #28
0
ファイル: BpmUtils.cs プロジェクト: xxxDSSxxx/Play
 public static double GetBeatsPerSecond(SongMeta songMeta)
 {
     return(GetBeatsPerMinute(songMeta) / 60.0);
 }
コード例 #29
0
 private void DrawVoice(int songDurationInMillis, SongMeta songMeta, Voice voice, Color color)
 {
     DrawAlternatingSentenceBackgrounds(songDurationInMillis, songMeta, voice);
     DrawNotes(songDurationInMillis, songMeta, voice, color);
 }
コード例 #30
0
    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));
    }