Пример #1
0
        public static Note Execute(Tact tact)
        {
            var result = new Note();

            foreach (var current in tact.Notes)
            {
                if (result.Denominator == default)
                {
                    result.Numerator   = current.Numerator;
                    result.Denominator = current.Denominator;

                    continue;
                }
                if (current.Denominator == result.Denominator)
                {
                    result.Numerator++;
                    continue;
                }

                LeadToCommonDenominator(result, current);
                result.Numerator += current.Numerator;
            }

            Optimizator.ExecuteForNote(result);
            return(result);
        }
Пример #2
0
        private static void LeadToCommonDenominator(Note result, Note current)
        {
            int greatestCommonDivisior =
                Optimizator.FindGreatestCommonDivisior(result.Denominator, current.Denominator);
            var maxValue            = Math.Max(result.Denominator, current.Denominator);
            var multiplyCoefficient = maxValue / greatestCommonDivisior;

            if (current.Denominator == maxValue)
            {
                LeadToCommonDenominator(result, multiplyCoefficient);
                return;
            }

            LeadToCommonDenominator(current, multiplyCoefficient);
        }