示例#1
0
文件: Sound.cs 项目: Kaksisve/Otone
 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);
     }
 }
示例#2
0
文件: Sound.cs 项目: Kaksisve/Otone
 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);
     }
 }
示例#3
0
文件: Sound.cs 项目: Kaksisve/Otone
 // Аддитивная функция, не использующая громкость мастер-канала.
 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);
     }
 }
示例#4
0
文件: Sound.cs 项目: Kaksisve/Otone
 private void Void(Oscillator oscillator, out Double[] data)
 {
     data = new Double[loopDuration];
     // Не нужно.
     for (Int32 i = 0; i < loopDuration; i++)
     {
         data[i] = default(Int32);
     }
 }
示例#5
0
文件: Sound.cs 项目: Kaksisve/Otone
 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);
     }
 }
示例#6
0
文件: Sound.cs 项目: Kaksisve/Otone
 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);
     }
 }
示例#7
0
文件: Sound.cs 项目: Kaksisve/Otone
        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);
            }
        }
示例#8
0
文件: Sound.cs 项目: Kaksisve/Otone
 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);
     }
 }
示例#9
0
文件: Sound.cs 项目: Kaksisve/Otone
 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);
     }
 }
示例#10
0
文件: Sound.cs 项目: Kaksisve/Otone
 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);
     }
 }