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 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)); }
private Tone GetNextToneToDisplay() { int actualNoteIndex = Convert.ToInt32(this.ActualNoteIndex.Value); if (this.ActualNoteIndex.Value.Equals("")) { return(null); } if (this.PreviousTone.Value.Equals("")) { return(this.ActualScale.StartingTone); } Tone tonePrev = ToneGraph.GetToneByName(this.PreviousTone.Value); int halftoneNumber; if (this.ActualScale.Type.Equals("dur")) { halftoneNumber = durIntervals[actualNoteIndex - 2]; } else { halftoneNumber = molIntervals[actualNoteIndex - 2]; } IntervalGenerator intervalGenerator = new IntervalGenerator(); GeneralInterval interval = intervalGenerator.GetIntervalByNumeralAndNumberOfHalftones(2, halftoneNumber); return(intervalGenerator.ComputeSecondToneOfInterval(tonePrev, interval)); }
private void DetermineAnswer(int chromaticChange) { Tone tone = ToneGraph.GetBasicToneByIndex(Convert.ToInt32(this.ToneClicked.Value)); Tone toneWithChromaticChange = ToneGraph.GetToneByReferenceToneAndChromaticChange(tone, chromaticChange); if (toneWithChromaticChange.Name.Equals(this.ActualInterval.Tone2.Name)) { this.SetQuestionAsAnswered(); } }
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 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 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); }
static ConstructingScales() { listOfScales = new List <Scale>(); string[] lines = VyukaHN.Properties.Resources.Scales.Split(null); foreach (var line in lines) { if (line.Equals("")) { continue; } var items = line.Split(';'); Scale scale = new Scale(items[0] + " " + items[1], items[1], ToneGraph.GetToneByName(items[2]), Convert.ToInt32(items[3])); listOfScales.Add(scale); } }
private void NextExercise() { this.HideSecondNote(); this.AddPointerToFirstNote(); IntervalGenerator intervalGenerator = new IntervalGenerator(); this.ActualInterval = intervalGenerator.GenerateIntervalWithTones(); this.QuestionInterval.InnerText = this.ActualInterval.GeneralInterval.ToString(); this.QuestionInterval.Attributes.Add("title", this.WholeIntervalAdjective(this.ActualInterval.GeneralInterval.adjective) + " " + this.WholeIntervalNumeral(this.ActualInterval.GeneralInterval.numeral)); this.Tone1Index.Value = ToneGraph.GetReferenceToneIndex(this.ActualInterval.Tone1).ToString(); StaveObjectsPosition sop = new StaveObjectsPosition(226, 30); Tuple <Point, Point, Point> notePosition = sop.DrawNote(this.ActualInterval.Tone1, 240); this.ChangePositionOfNote(notePosition, this.Note1, this.LedgerLine1, this.SharpFlatSymbol1, this.ActualInterval.Tone1); }
private bool SharpFlatSymbolOverlapping(Interval interval) { int lowerNoteSymbolLowestPositionY = this.GetLowestFlatSharpSymbolPositionY(this.GetNoteFlatSharpSymbolHeight(interval.Tone1), interval.Tone1.ChromaticChange); int higerNoteSymbolLowestPositionY = this.GetLowestFlatSharpSymbolPositionY(this.GetNoteFlatSharpSymbolHeight(interval.Tone2), interval.Tone2.ChromaticChange); int lowerNoteSymbolPositionY = lowerNoteSymbolLowestPositionY - ToneGraph.GetReferenceToneIndex(interval.Tone1) * (this.DistanceBetweenLines / 2); int higherNoteSymbolPositionY = higerNoteSymbolLowestPositionY - ToneGraph.GetReferenceToneIndex(interval.Tone2) * (this.DistanceBetweenLines / 2); int distanceBetweenSymbols = lowerNoteSymbolPositionY - higherNoteSymbolPositionY - this.GetNoteFlatSharpSymbolHeight(interval.Tone2); return(distanceBetweenSymbols <= 0 ? true : false); }
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); }
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)); }