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(); }
public FullNote FullNoteAt(int str, int fret, InternalNoteStringStyle style) { if (str < 0 || str >= RootNotes.Length) { throw new ArgumentOutOfRangeException("str"); } if (fret < 0) { throw new ArgumentOutOfRangeException("fret"); } return(RootNotes[str].Shift(fret, style)); }
public static Note ToNote(InternalNote note, InternalNoteStringStyle style) { switch (note) { case InternalNote.C: return(Note.C); case InternalNote.Cs_Db: if (style == InternalNoteStringStyle.PreferSharp) { return(Note.Cs); } else if (style == InternalNoteStringStyle.PreferFlat) { return(Note.Db); } break; case InternalNote.D: return(Note.D); case InternalNote.Ds_Eb: if (style == InternalNoteStringStyle.PreferSharp) { return(Note.Ds); } else if (style == InternalNoteStringStyle.PreferFlat) { return(Note.Eb); } break; case InternalNote.E: return(Note.E); case InternalNote.F: return(Note.F); case InternalNote.Fs_Gb: if (style == InternalNoteStringStyle.PreferSharp) { return(Note.Fs); } else if (style == InternalNoteStringStyle.PreferFlat) { return(Note.Gb); } break; case InternalNote.G: return(Note.G); case InternalNote.Gs_Ab: if (style == InternalNoteStringStyle.PreferSharp) { return(Note.Gs); } else if (style == InternalNoteStringStyle.PreferFlat) { return(Note.Ab); } break; case InternalNote.A: return(Note.A); case InternalNote.As_Bb: if (style == InternalNoteStringStyle.PreferSharp) { return(Note.As); } else if (style == InternalNoteStringStyle.PreferFlat) { return(Note.Bb); } break; case InternalNote.B: return(Note.B); } throw new ArgumentException(); }