public Tuple<Point, Point, Point> DrawNote(Tone tone, int notePositionX) { int toneIndex = ToneGraph.GetReferenceToneIndex(tone); Point notePosition = new Point(); notePosition.X = notePositionX; notePosition.Y = 226 - 15 * toneIndex; int ledgerLineTop; if (toneIndex < 12) { ledgerLineTop = (LowestNotePositionY - 1) - (int)(toneIndex / 2) * DistanceBetweenLines; } else { ledgerLineTop = (LowestNotePositionY - 1) - (int)((toneIndex - 1) / 2) * DistanceBetweenLines; } Point ledgerLinePosition = new Point(); ledgerLinePosition.X = notePositionX - 5; ledgerLinePosition.Y = ledgerLineTop; Point sharpFlatSymbolPosition = SharpFlatSymbolPosition(tone, notePositionX); return new Tuple<Point, Point, Point>(notePosition, ledgerLinePosition, sharpFlatSymbolPosition); }
public Bitmap DrawNote(Bitmap stave, Bitmap note, Tone tone, int notePositionX) { int index = ToneGraph.GetReferenceToneIndex(tone); Bitmap newBitmap = new Bitmap(stave.Width, stave.Height); using (Graphics graphics = Graphics.FromImage(newBitmap)) { Rectangle ImageSize = new Rectangle(0, 0, stave.Width, stave.Height); graphics.FillRectangle(Brushes.White, ImageSize); if (tone.ChromaticChange != 0) { DrawFlatSharpSymbol(newBitmap, tone, index, notePositionX); } graphics.DrawImage(note, new Point(notePositionX, this.LowestNotePositionY - (this.DistanceBetweenLines / 2) * index)); DrawLedgerLine(newBitmap, tone, index, notePositionX); graphics.CompositingMode = CompositingMode.SourceOver; stave.MakeTransparent(Color.White); graphics.DrawImage(stave, 0, 0); } return newBitmap; }
public Scale(string name, string type, Tone startingTone, int keySignature) { this.Name = name; this.Type = type; this.StartingTone = startingTone; this.KeySignature = keySignature; }
private ToneRelationship GetBasicToneRelationship(Tone tone) { for (int i = 0; i < tone.Neighbors.Count; i++) { ToneRelationship toneRelationship = tone.Neighbors.ElementAt(i); if (ToneGraph.IsBasicTone(toneRelationship.Tone2)) { return(toneRelationship); } } return(null); }
private void DisplayNextNote() { int actualNoteIndex = Convert.ToInt32(this.ActualNoteIndex.Value); Tone nextTone = this.GetNextToneToDisplay(); if (nextTone != null) { StaveObjectsPosition sop = new StaveObjectsPosition(226, 30); Tuple <Point, Point, Point> notePosition = sop.DrawNote(nextTone, 150 + (117 * (actualNoteIndex - 1))); this.ActualNoteIndex.Value = (Convert.ToInt32(this.ActualNoteIndex.Value) + 1).ToString(); this.PreviousTone.Value = nextTone.Name; switch (actualNoteIndex) { case 1: this.ChangePositionOfNote(notePosition, this.Note1, this.LedgerLine1, this.SharpFlatSymbol1, nextTone); break; case 2: this.ChangePositionOfNote(notePosition, this.Note2, this.LedgerLine2, this.SharpFlatSymbol2, nextTone); break; case 3: this.ChangePositionOfNote(notePosition, this.Note3, this.LedgerLine3, this.SharpFlatSymbol3, nextTone); break; case 4: this.ChangePositionOfNote(notePosition, this.Note4, this.LedgerLine4, this.SharpFlatSymbol4, nextTone); break; case 5: this.ChangePositionOfNote(notePosition, this.Note5, this.LedgerLine5, this.SharpFlatSymbol5, nextTone); break; case 6: this.ChangePositionOfNote(notePosition, this.Note6, this.LedgerLine6, this.SharpFlatSymbol6, nextTone); break; case 7: this.ChangePositionOfNote(notePosition, this.Note7, this.LedgerLine7, this.SharpFlatSymbol7, nextTone); break; case 8: this.ChangePositionOfNote(notePosition, this.Note8, this.LedgerLine8, this.SharpFlatSymbol8, nextTone); this.SetQuestionAsAnswered(); break; } } }
private void DetermineAnswer(int chromaticChange) { int actualNoteIndex = Convert.ToInt32(this.ActualNoteIndex.Value); Tone toneAux = ToneGraph.GetBasicToneByIndex(Convert.ToInt32(this.ToneClicked.Value)); Tone toneClicked = ToneGraph.GetToneByReferenceToneAndChromaticChange(toneAux, chromaticChange); Tone nextTone = this.GetNextToneToDisplay(); if (toneClicked.Name.Equals(nextTone.Name)) { this.DisplayNextNote(); } }
private void DrawFlatSharpSymbol(Bitmap newBitmap, Tone tone, int index, int notePositionX) { Bitmap symbol = GetFlatSharpSymbol(tone.ChromaticChange); // ideal distance from note is 7/29 of height of note int symbolPositionX = notePositionX - (symbol.Width + (VyukaHN.Properties.Resources.nota.Height * 7 / 29)) - this.distanceOfFlatSharpSymbol; //in case an interval (3, 4, 5, 6) is drawn, otherwise 0 int lowestSymbolPositionY = GetLowestFlatSharpSymbolPositionY(symbol.Height, tone.ChromaticChange); int symbolPositionY = lowestSymbolPositionY - (this.DistanceBetweenLines / 2) * index; using (Graphics graphics = Graphics.FromImage(newBitmap)) { graphics.DrawImage(symbol, new Point(symbolPositionX, symbolPositionY)); } }
private ToneRelationship GetDerivedToneRelationship(Tone tone, int halftoneDifference) { for (int i = 0; i < tone.Neighbors.Count; i++) { ToneRelationship toneRelationship = tone.Neighbors.ElementAt(i); if (!ToneGraph.IsBasicTone(toneRelationship.Tone2) && Math.Abs(halftoneDifference - toneRelationship.NumberOfHalftones) < Math.Abs(halftoneDifference)) { return(toneRelationship); } } return(null); }
private static void ReadTones() { string[] lines = VyukaHN.Properties.Resources.Tones.Split(null); foreach (var line in lines) { if (line.Equals("")) { continue; } var items = line.Split(';'); Tone tone = new Tone(items[0], items[1], Convert.ToInt32(items[2]), ReadDistancesOfTones(items[0])); toneList.Add(tone); } }
private Point SharpFlatSymbolPosition(Tone tone, int notePositionX) { if (tone.ChromaticChange == 0) { return(new Point()); } Bitmap symbol = GetFlatSharpSymbol(tone.ChromaticChange); // ideal distance from note is 7/29 of height of note int symbolPositionX = notePositionX - (symbol.Width + (VyukaHN.Properties.Resources.nota.Height * 7 / 29)) - this.distanceOfFlatSharpSymbol; //in case an interval (3, 4, 5, 6) is drawn, otherwise 0 int lowestSymbolPositionY = GetLowestFlatSharpSymbolPositionY(symbol.Height, tone.ChromaticChange); int symbolPositionY = lowestSymbolPositionY - (this.DistanceBetweenLines / 2) * ToneGraph.GetReferenceToneIndex(tone); return(new Point(symbolPositionX, symbolPositionY)); }
private Tone GenerateStartingTone(GeneralInterval itv) { int randomNumber = this.RandomNumber(0, 14 - (itv.numeral - 1)); Tone tone = ToneGraph.GetBasicToneByIndex(randomNumber); int randomNumber2 = this.RandomNumber(-1, 3); if (randomNumber2 != 0) { if (tone.Name != "h") { tone = this.GetDerivedToneRelationship(tone, randomNumber2).Tone2; } else { tone = this.GetDerivedToneRelationship(tone, Math.Abs(randomNumber2)).Tone2; } } return(tone); }
public static Tone GetToneByReferenceToneAndChromaticChange(Tone referenceTone, int chromaticChange) { if(referenceTone.ChromaticChange != 0 || referenceTone == null || chromaticChange > 3 || chromaticChange < -3) { return null; } if (chromaticChange == 0) { return referenceTone; } Tone tone = null; foreach (Tone t in toneList) { if (t.ReferenceTone.Name.Equals(referenceTone.Name) && t.ChromaticChange == chromaticChange) { tone = t; } } return tone; }
public static Tone GetToneByReferenceToneAndChromaticChange(Tone referenceTone, int chromaticChange) { if (referenceTone.ChromaticChange != 0 || referenceTone == null || chromaticChange > 3 || chromaticChange < -3) { return(null); } if (chromaticChange == 0) { return(referenceTone); } Tone tone = null; foreach (Tone t in toneList) { if (t.ReferenceTone.Name.Equals(referenceTone.Name) && t.ChromaticChange == chromaticChange) { tone = t; } } return(tone); }
private int GetNoteFlatSharpSymbolWidth(Tone tone) { return(this.GetFlatSharpSymbol(tone.ChromaticChange) == null ? 0 : this.GetFlatSharpSymbol(tone.ChromaticChange).Width); }
public static bool IsBasicTone(Tone tone) { return basicTones.Any(item => item.Equals(tone.Name)); }
public static int GetReferenceToneIndex(Tone tone) { return basicTones.FindIndex(x => x.Contains(tone.ReferenceTone.Name)); }
private void ChangePositionOfNote(Tuple<Point, Point, Point> notePosition, HtmlImage Note, HtmlGenericControl LedgerLine, HtmlImage SharpFlatSymbol, Tone tone) { Note.Style.Add("visibility", "visible"); Note.Style.Add("left", notePosition.Item1.X.ToString() + "px"); Note.Style.Add("top", notePosition.Item1.Y.ToString() + "px"); LedgerLine.Style.Add("visibility", "visible"); LedgerLine.Style.Add("left", notePosition.Item2.X.ToString() + "px"); LedgerLine.Style.Add("top", notePosition.Item2.Y.ToString() + "px"); string sharpFlatSymbolSrc = this.SharpFlatSymbolSrc(tone.ChromaticChange); if (sharpFlatSymbolSrc.Equals("")) { SharpFlatSymbol.Style.Add("visibility", "hidden"); } else { SharpFlatSymbol.Style.Add("visibility", "visible"); SharpFlatSymbol.Src = this.SharpFlatSymbolSrc(tone.ChromaticChange); } SharpFlatSymbol.Style.Add("left", notePosition.Item3.X.ToString() + "px"); SharpFlatSymbol.Style.Add("top", notePosition.Item3.Y.ToString() + "px"); }
public static int GetReferenceToneIndex(Tone tone) { return(basicTones.FindIndex(x => x.Contains(tone.ReferenceTone.Name))); }
private Point SharpFlatSymbolPosition(Tone tone, int notePositionX) { if (tone.ChromaticChange == 0) { return new Point(); } Bitmap symbol = GetFlatSharpSymbol(tone.ChromaticChange); // ideal distance from note is 7/29 of height of note int symbolPositionX = notePositionX - (symbol.Width + (VyukaHN.Properties.Resources.nota.Height * 7 / 29)) - this.distanceOfFlatSharpSymbol; //in case an interval (3, 4, 5, 6) is drawn, otherwise 0 int lowestSymbolPositionY = GetLowestFlatSharpSymbolPositionY(symbol.Height, tone.ChromaticChange); int symbolPositionY = lowestSymbolPositionY - (this.DistanceBetweenLines / 2) * ToneGraph.GetReferenceToneIndex(tone); return new Point(symbolPositionX, symbolPositionY); }
private int GetNoteFlatSharpSymbolWidth(Tone tone) { return this.GetFlatSharpSymbol(tone.ChromaticChange) == null ? 0 : this.GetFlatSharpSymbol(tone.ChromaticChange).Width; }
private int GetNoteFlatSharpSymbolHeight(Tone tone) { return this.GetFlatSharpSymbol(tone.ChromaticChange) == null ? 0 : this.GetFlatSharpSymbol(tone.ChromaticChange).Height; }
private void ChangePositionOfNote(Tuple <Point, Point, Point> notePosition, HtmlImage Note, HtmlGenericControl LedgerLine, HtmlImage SharpFlatSymbol, Tone tone) { Note.Style.Add("visibility", "visible"); Note.Style.Add("left", notePosition.Item1.X.ToString() + "px"); Note.Style.Add("top", notePosition.Item1.Y.ToString() + "px"); LedgerLine.Style.Add("visibility", "visible"); LedgerLine.Style.Add("left", notePosition.Item2.X.ToString() + "px"); LedgerLine.Style.Add("top", notePosition.Item2.Y.ToString() + "px"); string sharpFlatSymbolSrc = this.SharpFlatSymbolSrc(tone.ChromaticChange); if (sharpFlatSymbolSrc.Equals("")) { SharpFlatSymbol.Style.Add("visibility", "hidden"); } else { SharpFlatSymbol.Style.Add("visibility", "visible"); SharpFlatSymbol.Src = this.SharpFlatSymbolSrc(tone.ChromaticChange); } SharpFlatSymbol.Style.Add("left", notePosition.Item3.X.ToString() + "px"); SharpFlatSymbol.Style.Add("top", notePosition.Item3.Y.ToString() + "px"); }
public Interval(Tone tone1, Tone tone2, GeneralInterval generalInterval) { this.Tone1 = tone1; this.Tone2 = tone2; this.GeneralInterval = generalInterval; }
private void DrawLedgerLine(Bitmap newBitmap, Tone tone, int index, int XLowestNote) { int ledgerLinePositionY; switch (index) { case 0: case 1: ledgerLinePositionY = this.LowestNotePositionY - 1; break; case 13: ledgerLinePositionY = (this.LowestNotePositionY - 1) - 12 * (this.DistanceBetweenLines / 2); break; default: return; } using (Graphics graphics = Graphics.FromImage(newBitmap)) { graphics.DrawImage(VyukaHN.Properties.Resources.pomocnaLinka, new Point(XLowestNote - ((VyukaHN.Properties.Resources.pomocnaLinka.Width - VyukaHN.Properties.Resources.nota.Width) / 2), ledgerLinePositionY)); } }
public static bool IsBasicTone(Tone tone) { return(basicTones.Any(item => item.Equals(tone.Name))); }
private int GetNoteFlatSharpSymbolHeight(Tone tone) { return(this.GetFlatSharpSymbol(tone.ChromaticChange) == null ? 0 : this.GetFlatSharpSymbol(tone.ChromaticChange).Height); }