示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }