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;
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            WaveAudio test = new WaveAudio(44100, 1);
            test.LengthInSamples = 44100 * 7;
            double freq = 100;//300;
            PeriodicAlternative osc = new PAChangeSquare(4.0);//new PASin();
            for (int i = 0; i < test.LengthInSamples; i++)
            {
                test.data[0][i] = 0.9 * osc.GetValue(i * freq * 2.0 * Math.PI / (double)44100.0);
            }
            //player.Play(test, true);

            WaveAudio win = new WaveAudio(strMedia + "acoust.wav");
            WaveAudio wmixed = WaveAudio.Mix(WaveAudio.Modulate(test, win), 0.7, win, 0.3);
            player.Play(wmixed, true);
        }
        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);
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            WaveAudio test = new WaveAudio(44100, 1);

            test.LengthInSamples = 44100 * 7;
            double freq             = 100;                     //300;
            PeriodicAlternative osc = new PAChangeSquare(4.0); //new PASin();

            for (int i = 0; i < test.LengthInSamples; i++)
            {
                test.data[0][i] = 0.9 * osc.GetValue(i * freq * 2.0 * Math.PI / (double)44100.0);
            }
            //player.Play(test, true);

            WaveAudio win    = new WaveAudio(strMedia + "acoust.wav");
            WaveAudio wmixed = WaveAudio.Mix(WaveAudio.Modulate(test, win), 0.7, win, 0.3);

            player.Play(wmixed, true);
        }