Beispiel #1
0
        public bool IsSimilar(TwelveToneSet other)
        {
            if (other.Count != this.Count)
            {
                return(false);
            }

            if (this.Equals(other))
            {
                return(true);
            }

            TwelveToneSet copy = new TwelveToneSet(this);

            for (int i = 1; i < TWELVE; i++)
            {
                copy = copy.ShiftRight(1);
                if (copy.Equals(other))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// Distance based on the number of common underlying Scales
        /// </summary>
        public int DistanceScales(TwelveToneSet other)
        {
            int           count = 0;
            TwelveToneSet copy  = new TwelveToneSet(majorScale);

            for (int i = 0; i < TWELVE; i++)
            {
                if (this.CoveredBy(copy) && other.CoveredBy(copy))
                {
                    count++;
                }
                copy.ShiftRight(1);
            }

            int ret = Math.Min(CountMajorScales(), other.CountMajorScales()) - count;

            return(ret);
        }
Beispiel #3
0
        public bool CoveredByAnySimilar(TwelveToneSet other)
        {
            if (this.CoveredBy(other))
            {
                return(true);
            }

            TwelveToneSet copy = new TwelveToneSet(this);

            for (int i = 1; i < TWELVE; i++)
            {
                copy = copy.ShiftRight(1);
                if (copy.CoveredBy(other))
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #4
0
        int CountMajorScales()
        {
            int count = 0;

            TwelveToneSet copy = new TwelveToneSet(majorScale);

            if (this.CoveredBy(copy))
            {
                count++;
            }

            for (int i = 1; i < TWELVE; i++)
            {
                copy.ShiftRight(1);
                if (this.CoveredBy(copy))
                {
                    count++;
                }
            }

            return(count);
        }
Beispiel #5
0
        /// <summary>
        /// Produces a list containing all similar scales.
        /// For example, if given only major scale (or similarly only minor scale)
        /// it will return: ionian(major), dorian, phrygian, lydian, mixolydian, aeolian and locrian scale.
        /// </summary>
        private static List <TwelveToneSet> CalculateAllScales(List <TwelveToneSet> scales)
        {
            if (scales == null)
            {
                return(null);
            }

            // Assert each scale is rooted, no two scales are similar
            for (int i = 0; i < scales.Count; i++)
            {
                Debug.Assert(scales[i].IsRooted);

                for (int j = i + 1; j < scales.Count; j++)
                {
                    Debug.Assert(!scales[i].IsSimilar(scales[j]));
                }
            }

            List <TwelveToneSet> allScales = new List <TwelveToneSet>();

            foreach (var scale in scales)
            {
                TwelveToneSet currScale = scale;
                do
                {
                    // Shift to next inversion e.g. ionian to dorian
                    do
                    {
                        currScale = currScale.ShiftRight(1);
                    } while (!currScale.IsRooted);

                    allScales.Add(currScale);
                } while (currScale != scale);
            }

            return(allScales);
        }