Ejemplo n.º 1
0
        public void PopulateHorizontalIntervals()
        {
            this.HorizontalIntervals = new List <int>();

            for (int j = 0; j < Bars.Count; j++)
            {
                for (int i = 0; i < Bars[j].notes.Count; i++)
                {
                    if (i + 1 < Bars[j].notes.Count)
                    {
                        HorizontalIntervals.Add(CounterpointAnalysis.GetIntervalInSemitones(Bars[j].notes[i], Bars[j].notes[i + 1]));
                    }
                    else
                    {
                        if (j + 1 < Bars.Count)
                        {
                            HorizontalIntervals.Add(CounterpointAnalysis.GetIntervalInSemitones(Bars[j].notes[i], Bars[j + 1].notes[0]));
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void SetVerticalIntervals(VoiceLine firstVoice, VoiceLine secondVoice, int voiceNumber)
        {
            long currentPositionInBar1 = 0;
            long currentPositionInBar2 = 0;

            firstVoice.VerticalIntervals.Add(new List <int>());

            TextFileLog log = new TextFileLog();


            for (int i = 0; i < firstVoice.Bars.Count; i++)
            {
                if (i < secondVoice.Bars.Count)
                {
                    int j = 0; // iterates over fist voices notes
                    int k = 0; // itarates over second voices notes

                    //variables keeping record of last value of j and k
                    int lastJ = -1;
                    int lastK = -1;


                    while (j < firstVoice[i].notes.Count && k < secondVoice[i].notes.Count)
                    {
                        firstVoice.VerticalIntervals[voiceNumber]
                        .Add(CounterpointAnalysis.GetIntervalInSemitones(firstVoice[i][j], secondVoice[i][k]));



                        if (lastJ != j)
                        {
                            var a = firstVoice[i][j].LengthAs <MusicalTimeSpan>(tempoMap);
                            currentPositionInBar1 += a.Numerator % 2 == 0 ? a.Numerator : a.Numerator + 1;
                        }
                        if (lastK != k)
                        {
                            var b = secondVoice[i][k].LengthAs <MusicalTimeSpan>(tempoMap);
                            currentPositionInBar2 += b.Numerator % 2 == 0 ? b.Numerator : b.Numerator + 1;
                        }

                        lastJ = j;
                        lastK = k;

                        if (currentPositionInBar1 < currentPositionInBar2)
                        {
                            j++;
                        }
                        else if (currentPositionInBar1 > currentPositionInBar2)

                        {
                            k++;
                        }
                        else
                        {
                            k++;
                            j++;
                        }
                    }
                }
            }
        }