예제 #1
0
        public FullNote Shift(int steps, InternalNoteStringStyle style)
        {
            if (steps == 0)
            {
                return(new FullNote(NoteUtils.ToNote(InternalNote, style), Octave));
            }

            int direction = Math.Sign(steps);

            InternalNote note   = InternalNote;
            int          octave = Octave;

            for (int i = 0; i < steps; i++)
            {
                int noteIndex = (int)note + direction;
                if (noteIndex < 0)
                {
                    noteIndex += 12;
                }

                note = (InternalNote)(noteIndex % 12);

                if (direction > 0 && note == InternalNote.C)
                {
                    octave++;
                }
                else if (direction < 0 && note == InternalNote.B)
                {
                    octave--;
                }
            }

            return(new FullNote(NoteUtils.ToNote(note, style), octave));
        }