private static Note calculateNote(int distance, Note _key) { int next = _key.getValue() + distance; if (next > 12) { next = next - 12; } return(NoteFactory.getNoteByValue(next, _key)); }
public static void drawChromaticGeometry(string filePath, System.Web.UI.WebControls.Image image) { bitmap = new Bitmap(400, 400); Graphics g = Graphics.FromImage(bitmap); Font font = new Font(FontFamily.GenericSerif, 18, FontStyle.Italic); StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center; Pen blackPen = new Pen(Color.Black, 3); Pen grayPen = new Pen(Color.Gray, 5); Pen goldPen = new Pen(Color.Gold, 3); Point pointOne = new Point(200, 50); Point pointTwo = new Point(275, 70); Point pointThree = new Point(330, 125); Point pointFour = new Point(350, 200); Point pointFive = new Point(330, 275); Point pointSix = new Point(275, 330); Point pointSeven = new Point(200, 350); Point pointEight = new Point(125, 330); Point pointNine = new Point(70, 275); Point pointTen = new Point(50, 200); Point pointEleven = new Point(70, 125); Point pointTwelve = new Point(125, 70); List <Point> points = new List <Point>(); points.Add(pointOne); points.Add(pointTwo); points.Add(pointThree); points.Add(pointFour); points.Add(pointFive); points.Add(pointSix); points.Add(pointSeven); points.Add(pointEight); points.Add(pointNine); points.Add(pointTen); points.Add(pointEleven); points.Add(pointTwelve); string R = Progression.getKey().getName(); nextNote = Progression.getKey().getValue() + 1; if (nextNote > 12) { nextNote = nextNote - 12; } string m2 = NoteFactory.getNoteByValue(nextNote, Progression.getKey()).getName(); nextNote = Progression.getKey().getValue() + 2; if (nextNote > 12) { nextNote = nextNote - 12; } string M2 = NoteFactory.getNoteByValue(nextNote, Progression.getKey()).getName(); nextNote = Progression.getKey().getValue() + 3; if (nextNote > 12) { nextNote = nextNote - 12; } string m3 = NoteFactory.getNoteByValue(nextNote, Progression.getKey()).getName(); nextNote = Progression.getKey().getValue() + 4; if (nextNote > 12) { nextNote = nextNote - 12; } string M3 = NoteFactory.getNoteByValue(nextNote, Progression.getKey()).getName(); nextNote = Progression.getKey().getValue() + 5; if (nextNote > 12) { nextNote = nextNote - 12; } string P4 = NoteFactory.getNoteByValue(nextNote, Progression.getKey()).getName(); nextNote = Progression.getKey().getValue() + 6; if (nextNote > 12) { nextNote = nextNote - 12; } string b5 = NoteFactory.getNoteByValue(nextNote, Progression.getKey()).getName(); nextNote = Progression.getKey().getValue() + 7; if (nextNote > 12) { nextNote = nextNote - 12; } string P5 = NoteFactory.getNoteByValue(nextNote, Progression.getKey()).getName(); nextNote = Progression.getKey().getValue() + 8; if (nextNote > 12) { nextNote = nextNote - 12; } string m6 = NoteFactory.getNoteByValue(nextNote, Progression.getKey()).getName(); nextNote = Progression.getKey().getValue() + 9; if (nextNote > 12) { nextNote = nextNote - 12; } string M6 = NoteFactory.getNoteByValue(nextNote, Progression.getKey()).getName(); nextNote = Progression.getKey().getValue() + 10; if (nextNote > 12) { nextNote = nextNote - 12; } string m7 = NoteFactory.getNoteByValue(nextNote, Progression.getKey()).getName(); nextNote = Progression.getKey().getValue() + 11; if (nextNote > 12) { nextNote = nextNote - 12; } string M7 = NoteFactory.getNoteByValue(nextNote, Progression.getKey()).getName(); g.Clear(Color.White); g.DrawEllipse(grayPen, 50, 50, 300, 300); g.DrawEllipse(blackPen, 50, 50, 300, 300); int firstPoint = 0; int secondPoint = 0; for (int i = 0; i < Progression.getMode().getSize(); i++) { for (int j = 0; j < (Progression.getMode().getSize() - i); j++) { secondPoint = Progression.getMode().getIntervalValue(j + i); g.DrawLine(goldPen, points.ElementAt(firstPoint), points.ElementAt(secondPoint)); } firstPoint = Progression.getMode().getIntervalValue(i); } g.DrawLine(goldPen, points.ElementAt(firstPoint), points.ElementAt(0)); g.DrawString(R, font, Brushes.Black, new RectangleF(180, 10, 40, 40), stringFormat); g.DrawString(m2, font, Brushes.Black, new RectangleF(275, 30, 40, 40), stringFormat); g.DrawString(M2, font, Brushes.Black, new RectangleF(330, 85, 40, 40), stringFormat); g.DrawString(m3, font, Brushes.Black, new RectangleF(350, 180, 40, 40), stringFormat); g.DrawString(M3, font, Brushes.Black, new RectangleF(330, 275, 40, 40), stringFormat); g.DrawString(P4, font, Brushes.Black, new RectangleF(275, 330, 40, 40), stringFormat); g.DrawString(b5, font, Brushes.Black, new RectangleF(180, 350, 40, 40), stringFormat); g.DrawString(P5, font, Brushes.Black, new RectangleF(85, 330, 40, 40), stringFormat); g.DrawString(m6, font, Brushes.Black, new RectangleF(30, 275, 40, 40), stringFormat); g.DrawString(M6, font, Brushes.Black, new RectangleF(10, 180, 40, 40), stringFormat); g.DrawString(m7, font, Brushes.Black, new RectangleF(30, 85, 40, 40), stringFormat); g.DrawString(M7, font, Brushes.Black, new RectangleF(85, 30, 40, 40), stringFormat); //string path = Server.MapPath(filePath); bitmap.Save(filePath, ImageFormat.Jpeg); image.ImageUrl = filePath; g.Dispose(); bitmap.Dispose(); }
public static List <Note> GetFirstRecommendedDegrees(Note key, Mode mode) { List <Note> notes = new List <Note>(); int noteOffset; notes.Add(key); if (mode.containsInterval(7)) { noteOffset = key.getValue() + 7; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(5)) { noteOffset = key.getValue() + 5; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(8)) { noteOffset = key.getValue() + 8; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(9)) { noteOffset = key.getValue() + 9; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(3)) { noteOffset = key.getValue() + 3; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(4)) { noteOffset = key.getValue() + 4; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(1)) { noteOffset = key.getValue() + 1; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(2)) { noteOffset = key.getValue() + 2; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(10)) { noteOffset = key.getValue() + 10; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(11)) { noteOffset = key.getValue() + 11; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(6)) { noteOffset = key.getValue() + 6; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } return(notes); }
public static List <Note> GetRecommendedDegreesByLast(Note key, Note lastTonic, Mode mode) { List <Note> notes = new List <Note>(); int noteOffset; int distance = lastTonic.getValue() - key.getValue(); if (distance < 12) { distance = distance + 12; } if (mode.containsInterval(5 + distance) || mode.containsInterval(5 + distance - 12) || mode.containsInterval(5 + distance - 24)) { noteOffset = lastTonic.getValue() + 5; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(2 + distance) || mode.containsInterval(2 + distance - 12) || mode.containsInterval(2 + distance - 24)) { noteOffset = lastTonic.getValue() + 2; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(1 + distance) || mode.containsInterval(1 + distance - 12) || mode.containsInterval(1 + distance - 24)) { noteOffset = lastTonic.getValue() + 1; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(4 + distance) || mode.containsInterval(4 + distance - 12) || mode.containsInterval(4 + distance - 24)) { noteOffset = lastTonic.getValue() + 4; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(3 + distance) || mode.containsInterval(3 + distance - 12) || mode.containsInterval(3 + distance - 24)) { noteOffset = lastTonic.getValue() + 3; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(7 + distance) || mode.containsInterval(7 + distance - 12) || mode.containsInterval(7 + distance - 24)) { noteOffset = lastTonic.getValue() + 7; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(10 + distance) || mode.containsInterval(10 + distance - 12) || mode.containsInterval(10 + distance - 24)) { noteOffset = lastTonic.getValue() + 10; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(11 + distance) || mode.containsInterval(11 + distance - 12) || mode.containsInterval(11 + distance - 24)) { noteOffset = lastTonic.getValue() + 11; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(8 + distance) || mode.containsInterval(8 + distance - 12) || mode.containsInterval(8 + distance - 24)) { noteOffset = lastTonic.getValue() + 8; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(9 + distance) || mode.containsInterval(9 + distance - 12) || mode.containsInterval(9 + distance - 24)) { noteOffset = lastTonic.getValue() + 9; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } if (mode.containsInterval(6 + distance) || mode.containsInterval(6 + distance - 12) || mode.containsInterval(6 + distance - 24)) { noteOffset = lastTonic.getValue() + 6; if (noteOffset > 12) { noteOffset = noteOffset - 12; } notes.Add(NoteFactory.getNoteByValue(noteOffset, key)); } notes.Add(lastTonic); return(notes); }