Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float noteToFreq(float midiNote) {
- return (pow(2, ((midiNote+12)-69)/12) * 440);
- }
- void play(float note, int length) {
- length = (float) length / 2;
- if(note > 0) {
- playTone(noteToFreq(note), length * 25);
- }
- wait(length * 300, milliseconds);
- ClearSounds();
- }
- task main() {
- nVolume = 1;
- int totalNotes = 54;
- int notes[54][2] = {
- {67, 2}, // G5
- {68, 2}, // A5B
- {60, 2}, // C5
- {67, 4}, // G5
- {68, 6}, // A5B
- {67, 2}, // G5
- {68, 2}, // A5B
- {60, 2}, // C5
- {68, 4}, // A5B
- {67, 4}, // G5
- {58, 2}, // B4B
- {65, 2}, // F5
- {67, 2}, // G5
- {58, 2}, // B4B
- {65, 2}, // F5
- {67, 4}, // G5
- {63, 8}, // E5B
- {61, 8}, // D5B
- {67, 2}, // G5
- {68, 2}, // A5B
- {60, 2}, // C5
- {67, 4}, // G5
- {68, 6}, // A5B
- {68, 2}, // A5B
- {67, 2}, // G5
- {60, 2}, // C5
- {68, 4}, // A5B
- {67, 4}, // G5
- {58, 2}, // B4B
- {65, 2}, // F5
- {67, 2}, // G5
- {58, 2}, // B4B
- {65, 2}, // F5
- {67, 2}, // G5
- {58, 2}, // B4B
- {0, 12}, // rest 12
- {46, 2}, // B3B
- {48, 4}, // C4
- {48, 4}, // C4
- {48, 4}, // C4
- {48, 2}, // C4
- {48, 2}, // C4
- {48, 2}, // C4
- {46, 2}, // B3B
- {44, 2}, // A3B
- {44, 4}, // A3B
- {44, 2}, // A3B
- {44, 2}, // A3B
- {46, 2}, // B3B
- {46, 8}, // B3B
- {44, 2}, // A3B
- {43, 2}, // G3
- {41, 10}, // F3
- {0, 6} // rest 6
- };
- for(int i = 0; i < totalNotes - 1; i++) {
- play(notes[i][0], notes[i][1]); // The song is Let It Go
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement