Example #1
0
        public TwelveToneSet(Random rand, int ntones, TwelveToneSet scale)
        {
            Debug.Assert(ntones <= scale.Count);
            tone12 pos = 0;

            // Find the first tone the scale
            while (!scale[pos])
            {
                pos++;
            }

            // Randomly move it forward
            int times = rand.Next(scale.Count);

            pos = scale.Next(pos, times);

            tones  = 0;
            tones &= (short)(1 << pos);
            for (int i = 1; i < ntones; i++)
            {
                pos    = scale.Next(pos, 2);
                tones &= (short)(1 << pos);
            }

            Debug.Assert(ntones == this.Count);
        }