CapsAdmin

Untitled

Apr 18th, 2012
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. static int time = 0;
  2.  
  3. int getpitch(int offset)
  4. {
  5.     return 440 * 2 ^ ((offset - 48) / 12);
  6. }
  7.  
  8. int pwm(int offset, int w = 50)
  9. {
  10.     return (time * getpitch(offset))%100 > w ? 1 : 0;
  11. }
  12.  
  13. int tune()
  14. {
  15.     int t = time * 8;
  16.     int w = 0;
  17.  
  18.     if (t%100 > 90 && t%100 < 95)
  19.         w = w + rand()%2;
  20.  
  21.     if (t%80 < 50)
  22.         w = w + rand()%2;
  23.  
  24.     if (t%40 > 20 && t%40 < 25)
  25.         w = w + pwm(12);
  26.  
  27.  
  28.     if (t%40 > 25 && t%40 < 30)
  29.         w = w + pwm(0);
  30.  
  31.     return w;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment