public Tone ComputeSecondToneOfInterval(Tone firstTone, GeneralInterval itv) { int sumOfHalftones = 0; Tone targetTone = firstTone; Tone startingToneReference = firstTone.ReferenceTone; if (firstTone.ChromaticChange == -1) { targetTone = startingToneReference; sumOfHalftones += 1; } else if (firstTone.ChromaticChange == 1) { targetTone = startingToneReference; sumOfHalftones -= 1; } for (int i = 1; i < itv.numeral; i++) { ToneRelationship nextBasicToneRelationship = this.GetBasicToneRelationship(targetTone); targetTone = nextBasicToneRelationship.Tone2; sumOfHalftones += nextBasicToneRelationship.NumberOfHalftones; } while (sumOfHalftones != itv.halftoneNumber) { ToneRelationship derivedToneRelationship = this.GetDerivedToneRelationship(targetTone, itv.halftoneNumber - sumOfHalftones); targetTone = derivedToneRelationship.Tone2; sumOfHalftones += derivedToneRelationship.NumberOfHalftones; } return(targetTone); }
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)); }
public Interval GenerateIntervalWithTones() { GeneralInterval itv = this.intervals[this.RandomNumber(0, this.intervals.Count)]; Tone startingTone = this.GenerateStartingTone(itv); Tone targetTone = this.ComputeSecondToneOfInterval(startingTone, itv); return(new Interval(startingTone, targetTone, itv)); }
private void ReadIntervals() { this.intervals = new List <GeneralInterval>(); string[] lines = VyukaHN.Properties.Resources.Intervals.Split(null); foreach (var line in lines) { if (line.Equals("")) { continue; } var items = line.Split(';'); GeneralInterval interval = new GeneralInterval(items[0], Convert.ToInt32(items[1]), Convert.ToInt32(items[2])); this.intervals.Add(interval); } }
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 Interval(Tone tone1, Tone tone2, GeneralInterval generalInterval) { this.Tone1 = tone1; this.Tone2 = tone2; this.GeneralInterval = generalInterval; }