protected void UpdateUI()
        {
            var note = LevelManager.CurrentNote;

            Text.text = $"{note.Name} {note.Octave}";

            int noteStep = MusicalScale
                           .GetNoteAbsoluteIndex(note.Name, LevelManager.MaxOctave, note.Octave);

            int anchorY = -(noteStep * 18) - 30;
            var rt      = Text
                          .rectTransform;
            var pos = rt.anchoredPosition;

            pos.y = anchorY;
            rt.anchoredPosition = pos;

            float ratio = (noteStep / 60f);

            Text.color = Color
                         .Lerp(LevelManager.StartColor, LevelManager.EndColor, ratio);

            Animator
            .SetTrigger("DoIntro");
        }
Пример #2
0
        public Song ComposeSong(string root, int octave, ScaleType mode, float minNoteLength)
        {
            var song = CreateSong(minNoteLength);

            MusicalScale scale = new MusicalScale(root, mode, octave);

            SongStyle songStyle = new SongStyle(this, song, scale, minNoteLength);

            songStyle
            .Compose();

            return(song);
        }
Пример #3
0
        public Song ComposeFanfare(string root, int octave)
        {
            var song = CreateSong(0.25f);

            MusicalScale scale = new MusicalScale(root, ScaleType.Major, octave);

            var notes = scale.AscendingNotes;

            float runningTime = 0;

            AddNoteToSong(song, runningTime, 1, 0.5f, notes[5], NoteTimbre.Oh, -1);
            AddNoteToSong(song, runningTime, 2, 0.5f, notes[4], NoteTimbre.Oh, 0);
            AddNoteToSong(song, runningTime, 3, 0.5f, notes[0], NoteTimbre.Oh, 0);
            AddNoteToSong(song, runningTime, 4, 0.75f, notes[3], NoteTimbre.Ee, 0);

            runningTime += 0.75f;

            AddNoteToSong(song, runningTime, 1, 0.5f, notes[1], NoteTimbre.Ee, 0);
            AddNoteToSong(song, runningTime, 2, 0.5f, notes[0], NoteTimbre.Ee, 0);
            AddNoteToSong(song, runningTime, 3, 0.5f, notes[5], NoteTimbre.Ee, 0);
            AddNoteToSong(song, runningTime, 4, 0.75f, notes[4], NoteTimbre.Ee, 0);

            runningTime += 0.75f;

            AddNoteToSong(song, runningTime, 1, 0.5f, notes[4], NoteTimbre.Oh, -1);
            AddNoteToSong(song, runningTime, 2, 0.5f, notes[6], NoteTimbre.Oh, -1);
            AddNoteToSong(song, runningTime, 3, 0.5f, notes[3], NoteTimbre.Oh, 0);
            AddNoteToSong(song, runningTime, 4, 0.75f, notes[1], NoteTimbre.Ee, 0);

            runningTime += 0.75f;

            AddNoteToSong(song, runningTime, 1, 0.5f, notes[0], NoteTimbre.Ee, 0);
            AddNoteToSong(song, runningTime, 2, 0.5f, notes[2], NoteTimbre.Ee, 0);
            AddNoteToSong(song, runningTime, 3, 0.5f, notes[4], NoteTimbre.Ee, 0);
            AddNoteToSong(song, runningTime, 4, 0.75f, notes[2], NoteTimbre.Ee, 0);

            runningTime += 0.75f;

            song.TotalTime = runningTime + 2f;

            return(song);
        }