Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int time = 0;
- int getpitch(int offset)
- {
- return 440 * 2 ^ ((offset - 48) / 12);
- }
- int pwm(int offset, int w = 50)
- {
- return (time * getpitch(offset))%100 > w ? 1 : 0;
- }
- int tune()
- {
- int t = time * 8;
- int w = 0;
- if (t%100 > 90 && t%100 < 95)
- w = w + rand()%2;
- if (t%80 < 50)
- w = w + rand()%2;
- if (t%40 > 20 && t%40 < 25)
- w = w + pwm(12);
- if (t%40 > 25 && t%40 < 30)
- w = w + pwm(0);
- return w;
- }
Advertisement
Add Comment
Please, Sign In to add comment