Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2015
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1.        public void Write(int iter, byte[] fftData)
  2.         {
  3.             // Black background lights
  4.             for (int x = 0; x < 91; x++)
  5.             {
  6.                 for (int y = 0; y < 7; y++)
  7.                 {
  8.                     this.SetLed((x + iter) % 92, y, 0x00, 0x00, 0x00);
  9.                 }
  10.             }
  11.  
  12.             // FFT Data to key lights (rainbow)
  13.             for (int i = 0; i < 91; i++)
  14.             {
  15.                 for (int k = 0; k < 7; k++)
  16.                 {
  17.                     if (fftData[(int)(i * 2.1 + 1)] > (255 / (15 + (i * 0.8))) * (7 - k))
  18.                     {
  19.                         if (i <= 30)
  20.                         {
  21.                             this.red = (byte)(7.0f * (Math.Sin((i / 60.0f) * 3.14f + 1.57f)));
  22.                             this.grn = (byte)(7.0f * (Math.Sin((i / 60.0f) * 3.14f)));
  23.                             this.blu = 0x00;
  24.                         }
  25.                         if (i > 30 && i <= 60)
  26.                         {
  27.                             this.red = 0x00;
  28.                             this.grn = (byte)(7.0f * (Math.Sin(((i - 30.0f) / 60.0f) * 3.14f + 1.57f)));
  29.                             this.blu = (byte)(7.0f * (Math.Sin(((i - 30.0f) / 60.0f) * 3.14f)));
  30.                         }
  31.                         if (i > 60)
  32.                         {
  33.                             this.red = (byte)(7.0f * (Math.Sin(((i - 60.0f) / 62.0f) * 3.14f)));
  34.                             this.grn = 0x00;
  35.                             this.blu = (byte)(7.0f * (Math.Sin(((i - 60.0f) / 62.0f) * 3.14f + 1.57f)));
  36.                         }
  37.                         this.SetLed(i, k, red, grn, blu);
  38.                     }-
  39.                 }
  40.             }
  41.  
  42.             UpdateKeyboard();
  43.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement