Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. float noteToFreq(float midiNote) {
  2. return (pow(2, ((midiNote+12)-69)/12) * 440);
  3. }
  4. void play(float note, int length) {
  5. length = (float) length / 2;
  6. if(note > 0) {
  7. playTone(noteToFreq(note), length * 25);
  8. }
  9. wait(length * 300, milliseconds);
  10. ClearSounds();
  11. }
  12. task main() {
  13. nVolume = 1;
  14. int totalNotes = 54;
  15. int notes[54][2] = {
  16. {67, 2}, // G5
  17. {68, 2}, // A5B
  18. {60, 2}, // C5
  19. {67, 4}, // G5
  20. {68, 6}, // A5B
  21. {67, 2}, // G5
  22. {68, 2}, // A5B
  23. {60, 2}, // C5
  24. {68, 4}, // A5B
  25. {67, 4}, // G5
  26. {58, 2}, // B4B
  27. {65, 2}, // F5
  28. {67, 2}, // G5
  29. {58, 2}, // B4B
  30. {65, 2}, // F5
  31. {67, 4}, // G5
  32. {63, 8}, // E5B
  33. {61, 8}, // D5B
  34. {67, 2}, // G5
  35. {68, 2}, // A5B
  36. {60, 2}, // C5
  37. {67, 4}, // G5
  38. {68, 6}, // A5B
  39. {68, 2}, // A5B
  40. {67, 2}, // G5
  41. {60, 2}, // C5
  42. {68, 4}, // A5B
  43. {67, 4}, // G5
  44. {58, 2}, // B4B
  45. {65, 2}, // F5
  46. {67, 2}, // G5
  47. {58, 2}, // B4B
  48. {65, 2}, // F5
  49. {67, 2}, // G5
  50. {58, 2}, // B4B
  51. {0, 12}, // rest 12
  52. {46, 2}, // B3B
  53. {48, 4}, // C4
  54. {48, 4}, // C4
  55. {48, 4}, // C4
  56. {48, 2}, // C4
  57. {48, 2}, // C4
  58. {48, 2}, // C4
  59. {46, 2}, // B3B
  60. {44, 2}, // A3B
  61. {44, 4}, // A3B
  62. {44, 2}, // A3B
  63. {44, 2}, // A3B
  64. {46, 2}, // B3B
  65. {46, 8}, // B3B
  66. {44, 2}, // A3B
  67. {43, 2}, // G3
  68. {41, 10}, // F3
  69. {0, 6} // rest 6
  70. };
  71.  
  72. for(int i = 0; i < totalNotes - 1; i++) {
  73. play(notes[i][0], notes[i][1]); // The song is Let It Go
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement