public int[] Go(int length)
        {
            //create the wave.
            int[] res = new int[length];

            double amplitude = double.Parse(this.txtAmplitude.Text) * 44100 / 2.0; //divide by 2 so that you type in "1" for range -1 to 1 
            double freq = double.Parse(this.txtFreq.Text);
            double mean = double.Parse(this.txtMean.Text) * 44100;
            double multiply = double.Parse(this.txtMultiply.Text);
            PeriodicAlternative palt = new PASin();
            if (this.comboBox1.SelectedIndex == 1) palt = new PASin();
            else if (this.comboBox1.SelectedIndex == 2) palt = new PATri();
            else if (this.comboBox1.SelectedIndex == 3) palt = new PASawtooth();
            else if (this.comboBox1.SelectedIndex == 4) palt = new PASquare();
            else if (this.comboBox1.SelectedIndex == 5) palt = new PAChangeSquare();
            
            for (int i = 0; i < length; i++)
            {
                if (this.comboBox1.SelectedIndex == 0) // Constant
                {
                    res[i] = (int)mean;
                }
                else
                {
                    res[i] = (int)(mean + amplitude * palt.GetValue(i * 2.0 * Math.PI * freq / 44100.0));
                }
               // if (i % 1000 == 0) System.Diagnostics.Debug.WriteLine("hhhh");
            }

            return res;
        }
        public int[] Go(int length)
        {
            //create the wave.
            int[] res = new int[length];

            double amplitude         = double.Parse(this.txtAmplitude.Text) * 44100 / 2.0; //divide by 2 so that you type in "1" for range -1 to 1
            double freq              = double.Parse(this.txtFreq.Text);
            double mean              = double.Parse(this.txtMean.Text) * 44100;
            double multiply          = double.Parse(this.txtMultiply.Text);
            PeriodicAlternative palt = new PASin();

            if (this.comboBox1.SelectedIndex == 1)
            {
                palt = new PASin();
            }
            else if (this.comboBox1.SelectedIndex == 2)
            {
                palt = new PATri();
            }
            else if (this.comboBox1.SelectedIndex == 3)
            {
                palt = new PASawtooth();
            }
            else if (this.comboBox1.SelectedIndex == 4)
            {
                palt = new PASquare();
            }
            else if (this.comboBox1.SelectedIndex == 5)
            {
                palt = new PAChangeSquare();
            }

            for (int i = 0; i < length; i++)
            {
                if (this.comboBox1.SelectedIndex == 0) // Constant
                {
                    res[i] = (int)mean;
                }
                else
                {
                    res[i] = (int)(mean + amplitude * palt.GetValue(i * 2.0 * Math.PI * freq / 44100.0));
                }
                // if (i % 1000 == 0) System.Diagnostics.Debug.WriteLine("hhhh");
            }

            return(res);
        }