Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Song {
- public:
- int currentNote = 0;
- int base = 400;
- static const int len = 32;
- int notes[len][2] = {
- {0, 450},
- {-100, 50},
- {0, 250},
- {2, 750},
- {0, 750},
- {5, 750},
- {4, 1250},
- {-100, 250},
- {0, 450},
- {-100, 50},
- {0, 250},
- {2, 750},
- {0, 750},
- {7, 750},
- {5, 1250},
- {-100, 250},
- {0, 450},
- {-100, 50},
- {0, 250},
- {12, 750},
- {9, 750},
- {5, 750},
- {4, 750},
- {2, 1250},
- {-100, 250},
- {10, 450},
- {-100, 50},
- {10, 250},
- {9, 750},
- {5, 750},
- {7, 750},
- {5, 1250},
- };
- Song() {
- currentNote = 0;
- }
- int nextNote() {
- if (notes[currentNote][0] == -100) {
- return 0;
- }
- return base * pow(2, notes[currentNote][0]/12.0);
- }
- int nextLength() {
- currentNote++;
- return notes[currentNote-1][1];
- }
- boolean completed() {
- return currentNote == len;
- }
- void reset() {
- currentNote = 0;
- }
- };
Add Comment
Please, Sign In to add comment