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)); }
public static string ToString(InternalNote note, InternalNoteStringStyle style) { if (NoteUtils.IsNatural(note) || style != InternalNoteStringStyle.ShowBoth) { return(NoteUtils.ToString(NoteUtils.ToNote(note, style))); } else { switch (note) { case InternalNote.Cs_Db: return("C#/Db"); case InternalNote.Ds_Eb: return("D#/Eb"); case InternalNote.Fs_Gb: return("F#/Gb"); case InternalNote.Gs_Ab: return("G#/Ab"); case InternalNote.As_Bb: return("A#/Bb"); } } throw new ArgumentException(); }