CaptainSpaceCat

Song.h

Apr 3rd, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. class Song {
  2.  
  3.   public:
  4.     int currentNote = 0;
  5.     int base = 400;
  6.     static const int len = 32;
  7.     int notes[len][2] = {
  8.       {0, 450},
  9.       {-100, 50},
  10.       {0, 250},
  11.       {2, 750},
  12.       {0, 750},
  13.       {5, 750},
  14.       {4, 1250},
  15.       {-100, 250},
  16.       {0, 450},
  17.       {-100, 50},
  18.       {0, 250},
  19.       {2, 750},
  20.       {0, 750},
  21.       {7, 750},
  22.       {5, 1250},
  23.       {-100, 250},
  24.       {0, 450},
  25.       {-100, 50},
  26.       {0, 250},
  27.       {12, 750},
  28.       {9, 750},
  29.       {5, 750},
  30.       {4, 750},
  31.       {2, 1250},
  32.       {-100, 250},
  33.       {10, 450},
  34.       {-100, 50},
  35.       {10, 250},
  36.       {9, 750},
  37.       {5, 750},
  38.       {7, 750},
  39.       {5, 1250},
  40.     };
  41.  
  42.     Song() {
  43.       currentNote = 0;
  44.     }
  45.  
  46.     int nextNote() {
  47.       if (notes[currentNote][0] == -100) {
  48.         return 0;
  49.       }
  50.       return base * pow(2, notes[currentNote][0]/12.0);
  51.     }
  52.  
  53.     int nextLength() {
  54.       currentNote++;
  55.       return notes[currentNote-1][1];
  56.     }
  57.  
  58.     boolean completed() {
  59.       return currentNote == len;
  60.     }
  61.  
  62.     void reset() {
  63.       currentNote = 0;
  64.     }
  65.  
  66. };
Add Comment
Please, Sign In to add comment