public void SetAlteration(char note, NoteAlterationType newAlterationType) { switch (note) { case 'A': A = newAlterationType; return; case 'B': B = newAlterationType; return; case 'C': C = newAlterationType; return; case 'D': D = newAlterationType; return; case 'E': E = newAlterationType; return; case 'F': F = newAlterationType; return; case 'G': G = newAlterationType; return; } }
public Alterations() { A = NoteAlterationType.Natural; B = NoteAlterationType.Natural; C = NoteAlterationType.Natural; D = NoteAlterationType.Natural; E = NoteAlterationType.Natural; F = NoteAlterationType.Natural; G = NoteAlterationType.Natural; }
public NoteAlterationType GetAlteration(Note note) { if (note.Pitch == null) { return(NoteAlterationType.Natural); } var proposedNoteAlteration = Alterations.IntToAlteration(note.Pitch.Alter); var naturalKeyAlteration = Alterations.CreateFromFifths(_currentKey.Fifths).ForNote(note.Pitch.Step); var currentKeyAlteration = _alterations.ForNote(note.Pitch.Step); //Do nothing if natural if (currentKeyAlteration == proposedNoteAlteration) { return(NoteAlterationType.Natural); } NoteAlterationType newAlterationType = NoteAlterationType.Natural; switch (note.Pitch.Alter - Alterations.AlterationToInt(currentKeyAlteration)) { case -2: newAlterationType = NoteAlterationType.DoubleFlat; break; case -1: newAlterationType = NoteAlterationType.Flat; break; case 0: newAlterationType = NoteAlterationType.Natural; break; case 1: newAlterationType = NoteAlterationType.Sharp; break; case 2: newAlterationType = NoteAlterationType.DoubleSharp; break; } if (note.Pitch.Alter == 0) { newAlterationType = NoteAlterationType.Natural; } _alterations.SetAlteration(note.Pitch.Step, newAlterationType); if (note.Pitch.Alter == 0) { return(NoteAlterationType.Neutral); } return(newAlterationType); }
public static int AlterationToInt(NoteAlterationType type) { switch (type) { case NoteAlterationType.DoubleFlat: return(-2); case NoteAlterationType.Flat: return(-1); case NoteAlterationType.Natural: return(0); case NoteAlterationType.Sharp: return(1); case NoteAlterationType.DoubleSharp: return(2); } return(0); }
private void AddAlteration(Note note, double noteTime, double yCoord) { NoteAlterationType type = _keyRenderHelper.GetAlteration(note); Type glyphType; switch (type) { case NoteAlterationType.Neutral: glyphType = typeof(NaturalGlyph); break; case NoteAlterationType.DoubleFlat: glyphType = typeof(DoubleFlatGlyph); break; case NoteAlterationType.Flat: glyphType = typeof(FlatGlyph); break; case NoteAlterationType.Sharp: glyphType = typeof(SharpGlyph); break; case NoteAlterationType.DoubleSharp: glyphType = typeof(DoubleSharpGlyph); break; default: return; } TextBlock tb = _renderHelper.Glyphs.GetGlyph(glyphType, ScoreLayoutDetails.DefaultAlterationScaling); _renderHelper.AddItemToRender(noteTime, tb, yCoord - tb.BaselineOffset, ScoreLayoutDetails.DefaultNoteHeight, 0, RenderItemType.Alteration, 0); }