Ejemplo n.º 1
0
    public override void UpdateSinging(double currentBeat)
    {
        Sentence currentSentence = playerController?.CurrentSentence;

        if (currentSentence == null)
        {
            return;
        }

        int  currentMidiNote   = 0;
        Note noteAtCurrentBeat = PlayerNoteRecorder.GetNoteAtBeat(currentSentence, currentBeat);

        if (noteAtCurrentBeat != null)
        {
            currentMidiNote = noteAtCurrentBeat.MidiNote + noteOffset;
        }
        else if (lastNote != null)
        {
            // Change noteOffset on falling flank of note
            // (falling flank: now there is no note, but in last frame there was one)
            noteOffset = (noteOffset + 1) % 5;
        }
        playerController.PlayerNoteRecorder.HandlePitchEvent(new PitchEvent(currentMidiNote));

        lastNote = noteAtCurrentBeat;
    }
Ejemplo n.º 2
0
    private void OnSentenceEnded()
    {
        List <RecordedNote> recordedNotes  = PlayerNoteRecorder.GetRecordedNotes(CurrentSentence);
        SentenceRating      sentenceRating = PlayerScoreController.CalculateScoreForSentence(CurrentSentence, recordedNotes);

        playerUiController.ShowTotalScore((int)PlayerScoreController.TotalScore);
        if (sentenceRating != null)
        {
            playerUiController.ShowSentenceRating(sentenceRating);

            if (sentenceRating == SentenceRating.Perfect)
            {
                perfectSentenceChain++;
            }
            else
            {
                perfectSentenceChain = 0;
            }

            if (perfectSentenceChain >= 2)
            {
                playerUiController.CreatePerfectSentenceEffect();
            }
        }

        sentenceIndex++;
        UpdateSentences(sentenceIndex);
    }
Ejemplo n.º 3
0
    public void Init(SongMeta songMeta, PlayerProfile playerProfile, string voiceIdentifier, MicProfile micProfile)
    {
        this.SongMeta      = songMeta;
        this.PlayerProfile = playerProfile;
        this.MicProfile    = micProfile;

        Voice = LoadVoice(songMeta, voiceIdentifier);
        PlayerScoreController.Init(Voice);
        PlayerNoteRecorder.Init(this, playerProfile, micProfile);
    }
Ejemplo n.º 4
0
    protected Note GetNoteAtCurrentBeat(double currentBeat)
    {
        Sentence currentSentence = playerController?.GetRecordingSentence();

        if (currentSentence == null)
        {
            return(null);
        }

        double micDelayInBeats   = (playerController.MicProfile == null) ? 0 : BpmUtils.MillisecondInSongToBeatWithoutGap(songMeta, playerController.MicProfile.DelayInMillis);
        Note   noteAtCurrentBeat = PlayerNoteRecorder.GetNoteAtBeat(currentSentence, currentBeat - micDelayInBeats);

        return(noteAtCurrentBeat);
    }
Ejemplo n.º 5
0
    private void OnSentenceEnded()
    {
        PlayerNoteRecorder.OnSentenceEnded();
        List <RecordedNote> recordedNotes  = PlayerNoteRecorder.GetRecordedNotes(CurrentSentence);
        SentenceRating      sentenceRating = PlayerScoreController.CalculateScoreForSentence(CurrentSentence, recordedNotes);

        playerUiController.ShowTotalScore(PlayerScoreController.TotalScore);
        if (sentenceRating != null)
        {
            playerUiController.ShowSentenceRating(sentenceRating);
            sentenceRatingStream.OnNext(sentenceRating);
        }

        sentenceIndex++;
        UpdateSentences(sentenceIndex);
    }
Ejemplo n.º 6
0
    public override void UpdateSinging(double currentBeat)
    {
        Sentence currentSentence = playerController?.CurrentSentence;

        if (currentSentence == null)
        {
            return;
        }

        int  currentMidiNote   = 0;
        Note noteAtCurrentBeat = PlayerNoteRecorder.GetNoteAtBeat(currentSentence, currentBeat);

        if (noteAtCurrentBeat != null)
        {
            currentMidiNote = noteAtCurrentBeat.MidiNote + offset;
        }
        playerController.PlayerNoteRecorder.HandlePitchEvent(new PitchEvent(currentMidiNote));
    }
Ejemplo n.º 7
0
    private void UpdatePerfectSinging(PlayerController playerController, double currentBeat)
    {
        Sentence currentSentence = playerController.CurrentSentence;

        if (currentSentence == null)
        {
            return;
        }

        int  currentMidiNote   = 0;
        Note noteAtCurrentBeat = PlayerNoteRecorder.GetNoteAtBeat(currentSentence, currentBeat);

        if (noteAtCurrentBeat != null)
        {
            currentMidiNote = noteAtCurrentBeat.MidiNote;
        }
        playerController.PlayerNoteRecorder.OnPitchDetected(currentMidiNote);
    }
Ejemplo n.º 8
0
    public override void UpdateSinging(double currentBeat)
    {
        Sentence currentSentence = playerController?.CurrentSentence;

        if (currentSentence == null)
        {
            return;
        }

        int  currentMidiNote   = Random.Range(33, 70);
        Note noteAtCurrentBeat = PlayerNoteRecorder.GetNoteAtBeat(currentSentence, currentBeat);

        if (noteAtCurrentBeat != null)
        {
            currentMidiNote = noteAtCurrentBeat.MidiNote + Random.Range(-3, 3);
        }
        if (Random.Range(0, 5) == 0)
        {
            currentMidiNote = 0;
        }
        playerController.PlayerNoteRecorder.HandlePitchEvent(new PitchEvent(currentMidiNote));
    }
Ejemplo n.º 9
0
    private void FinishRecordingSentence(int sentenceIndex)
    {
        PlayerNoteRecorder.OnSentenceEnded();

        Sentence recordingSentence = GetSentence(sentenceIndex);

        if (recordingSentence == null)
        {
            return;
        }

        List <RecordedNote> recordedNotes = PlayerNoteRecorder.GetRecordedNotes(recordingSentence);

        PlayerNoteRecorder.RemoveRecordedNotes(recordingSentence);
        SentenceRating sentenceRating = PlayerScoreController.CalculateScoreForSentence(recordingSentence, recordedNotes);

        playerUiController.ShowTotalScore(PlayerScoreController.TotalScore);
        if (sentenceRating != null)
        {
            playerUiController.ShowSentenceRating(sentenceRating);
            sentenceRatingStream.OnNext(sentenceRating);
        }
    }
Ejemplo n.º 10
0
    public void Init(SongMeta songMeta, PlayerProfile playerProfile, string voiceIdentifier)
    {
        this.SongMeta      = songMeta;
        this.PlayerProfile = playerProfile;

        Voice = LoadVoice(songMeta, voiceIdentifier);

        playerUiArea = FindObjectOfType <PlayerUiArea>();

        PlayerScoreController = GetComponentInChildren <PlayerScoreController>();
        PlayerScoreController.Init(Voice);

        PlayerNoteRecorder = GetComponentInChildren <PlayerNoteRecorder>();
        if (PlayerNoteRecorder == null)
        {
            throw new NullReferenceException("PlayerNoteRecorder is null!");
        }
        PlayerNoteRecorder.Init(this, playerProfile.Difficulty.RoundingDistance);

        CreatePlayerUi();

        sentenceIndex = 0;
        UpdateSentences(sentenceIndex);
    }