Пример #1
0
        /// <summary>
        /// Reusable code snippet to shuffle a given oscillator (used for angular oscillators that can be a sawtooth wave)
        /// </summary>
        /// <param name="index">Index of oscillator shuffler to target</param>
        /// <param name="pattern">Pattern to be mutated by this shuffle operation</param>
        private void RollShufflerLoopable(int index, ref LineCirclePattern pattern)
        {
            //check to see if we should be a sawtooth
            pattern.Oscillators[index].Type = Roll(SawtoothChance)
                                ? OscillatorShape.Sawtooth
                                : OscillatorShape.Sine;

            //do normal stuff
            RollShuffler(index, ref pattern);

            //if sawtooth, make sure we go from 0 to 2 pi (so one full revolution)
            if (pattern.Oscillators[index].Type != OscillatorShape.Sawtooth)
            {
                return;
            }

            OscillatorShuffler.EnforceTwoPi(ref pattern.Oscillators[index]);

            //Once we've done all this enforcing, we need to do one more pass on ensuring that the frequency isn't too high
            if (Shufflers[index].OverrideFrequency)
            {
                Shufflers[index].RandomiseFrequency(ref pattern.Oscillators[index]);
            }
            else
            {
                OscillatorShuffler.RandomiseFrequency(ref pattern.Oscillators[index],
                                                      GlobalMinimumFrequency, GlobalMaximumFrequency);
            }
            Shufflers[index].EnforceMaxFrequency(ref pattern.Oscillators[index]);
        }
Пример #2
0
        /// <summary>
        /// Reusable code snippet to shuffle a given oscillator
        /// </summary>
        /// <param name="index">Index of oscillator shuffler to target</param>
        /// <param name="pattern">Pattern to be mutated by this shuffle operation</param>
        private void RollShuffler(int index, ref LineCirclePattern pattern)
        {
            //check whether we should shuffle at all
            if (!Roll(GlobalShuffleChance))
            {
                return;
            }

            //check whether we should freeze
            if (Roll(FreezeChance))
            {
                Shufflers[index].RandomiseCenter(ref pattern.Oscillators[index]);
                pattern.Oscillators[index].Amplitude = 0;
            }
            else
            {
                Shufflers[index].RandomiseRange(ref pattern.Oscillators[index]);
                OscillatorShuffler.RandomisePhase(ref pattern.Oscillators[index]);

                //check whether we should use override frequency values
                if (Shufflers[index].OverrideFrequency)
                {
                    Shufflers[index].RandomiseFrequency(ref pattern.Oscillators[index]);
                }
                else
                {
                    OscillatorShuffler.RandomiseFrequency(ref pattern.Oscillators[index],
                                                          GlobalMinimumFrequency, GlobalMaximumFrequency);
                }
            }

            Shufflers[index].EnforceMaxFrequency(ref pattern.Oscillators[index]);
        }