Beispiel #1
0
 private void Triangle(Oscillator oscillator, out Double[] data)
 {
     data = new Double[loopDuration];
     SineAdditive(oscillator, out Double[] extra);
     for (Int32 i = 0; i < loopDuration; i++)
     {
         Double sum = 0;
         for (Int32 j = 0; j < secondaryLoopDuration; j++)
         {
             if (j != 0)
             {
                 sum += Math.Pow(-1, (j - 1) / 2) * (extra[i] / Math.Pow(j, 2));
             }
             else
             {
                 sum += oscillator.Amplitude;
             }
         }
         data[i] = ((8 * oscillator.Amplitude) / Math.Pow(Math.PI, 2)) * sum;
         if (data[i] > oscillator.Amplitude)
         {
             data[i] = oscillator.Amplitude;
         }
         data[i] *= (oscillator.Volume / 100);
         data[i] *= (volume / 100);
     }
 }
Beispiel #2
0
 private void Saw(Oscillator oscillator, out Double[] data)
 {
     data = new Double[loopDuration];
     SineAdditive(oscillator, out Double[] extra);
     for (Int32 i = 0; i < loopDuration; i++)
     {
         Double sum = 0;
         for (Int32 j = 0; j < secondaryLoopDuration; j++)
         {
             if (j != 0)
             {
                 sum += (Math.Pow(-1, j + 1) / j) * extra[i];
             }
             else
             {
                 sum += oscillator.Amplitude;
             }
         }
         data[i] = (2 / Math.PI) * sum;
         if (data[i] > oscillator.Amplitude)
         {
             data[i] = oscillator.Amplitude;
         }
         data[i] *= (oscillator.Volume / 100);
         data[i] *= (volume / 100);
     }
 }
Beispiel #3
0
 // Аддитивная функция, не использующая громкость мастер-канала.
 private void CosineAdditive(Oscillator oscillator, out Double[] data)
 {
     data = new Double[loopDuration];
     for (Int32 i = 0; i < loopDuration; i++)
     {
         data[i] = oscillator.Amplitude * Math.Cos(oscillator.Frequency * 2 * Math.PI * i);
     }
 }
Beispiel #4
0
 private void Void(Oscillator oscillator, out Double[] data)
 {
     data = new Double[loopDuration];
     // Не нужно.
     for (Int32 i = 0; i < loopDuration; i++)
     {
         data[i] = default(Int32);
     }
 }
Beispiel #5
0
 private void Sine(Oscillator oscillator, out Double[] data)
 {
     data = new Double[loopDuration];
     for (Int32 i = 0; i < loopDuration; i++)
     {
         data[i]  = oscillator.Amplitude * Math.Sin(oscillator.Frequency * 2 * Math.PI * i);
         data[i] *= (oscillator.Volume / 100);
         data[i] *= (volume / 100);
     }
 }
Beispiel #6
0
 private void WhiteNoise(Oscillator oscillator, out Double[] data)
 {
     data = new Double[loopDuration];
     for (Int32 i = 0; i < loopDuration; i++)
     {
         data[i]  = oscillator.Amplitude;
         data[i] *= (oscillator.Volume / 100);
         data[i] *= (volume / 100);
     }
 }
Beispiel #7
0
        private void Noise(Oscillator oscillator, out Double[] data)
        {
            data = new Double[loopDuration];
            Random value = new Random();

            for (Int32 i = 0; i < loopDuration; i++)
            {
                data[i]  = value.Next(-oscillator.Amplitude, oscillator.Amplitude + 1);
                data[i] *= (oscillator.Volume / 100);
                data[i] *= (volume / 100);
            }
        }
Beispiel #8
0
 private void Secant(Oscillator oscillator, out Double[] data)
 {
     data = new Double[loopDuration];
     CosineAdditive(oscillator, out Double[] extra);
     for (Int32 i = 0; i < loopDuration; i++)
     {
         if (extra[i] == 0)
         {
             data[i] = oscillator.Amplitude;
         }
         else
         {
             data[i] = (1 / extra[i]);
         }
         data[i] *= (oscillator.Volume / 100);
         data[i] *= (volume / 100);
     }
 }
Beispiel #9
0
 private void Square(Oscillator oscillator, out Double[] data)
 {
     data = new Double[loopDuration];
     SineAdditive(oscillator, out Double[] extra);
     for (Int32 i = 0; i < loopDuration; i++)
     {
         if (extra[i] > 0)
         {
             data[i] = oscillator.Amplitude;
         }
         else if (extra[i] < 0)
         {
             data[i] = oscillator.Amplitude;
         }
         else
         {
             data[i] = 0;
         }
         data[i] *= (oscillator.Volume / 100);
         data[i] *= (volume / 100);
     }
 }
Beispiel #10
0
 private void Tangent(Oscillator oscillator, out Double[] data)
 {
     data = new Double[loopDuration];
     SineAdditive(oscillator, out Double[] extra1);
     CosineAdditive(oscillator, out Double[] extra2);
     for (Int32 i = 0; i < loopDuration; i++)
     {
         if (extra2[i] == 0)
         {
             data[i] = oscillator.Amplitude;
         }
         else
         {
             data[i] = (extra1[i] / extra2[i]);
         }
         if (data[i] > oscillator.Amplitude)
         {
             data[i] = oscillator.Amplitude;
         }
         data[i] *= (oscillator.Volume / 100);
         data[i] *= (volume / 100);
     }
 }