Li Ruofan 201199450

Dependencies:   mbed Gamepad Joystick

Committer:
DannyLee
Date:
Thu May 14 13:12:28 2020 +0000
Revision:
3:cf9fead9c3f4
Child:
6:cbd9e1f26a10
aaa

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DannyLee 3:cf9fead9c3f4 1 #include "bgm.h"
DannyLee 3:cf9fead9c3f4 2
DannyLee 3:cf9fead9c3f4 3 // construct & destruct/
DannyLee 3:cf9fead9c3f4 4 bgm::bgm()
DannyLee 3:cf9fead9c3f4 5 {
DannyLee 3:cf9fead9c3f4 6 }
DannyLee 3:cf9fead9c3f4 7 bgm::~bgm()
DannyLee 3:cf9fead9c3f4 8 {
DannyLee 3:cf9fead9c3f4 9 }
DannyLee 3:cf9fead9c3f4 10
DannyLee 3:cf9fead9c3f4 11 // The number "1,2,3,4,5,6,7" means each number note in the notation
DannyLee 3:cf9fead9c3f4 12
DannyLee 3:cf9fead9c3f4 13 // Excerpted from famous Chinese and English songs
DannyLee 3:cf9fead9c3f4 14 void bgm::welcome(){
DannyLee 3:cf9fead9c3f4 15 tone(784.0f,0.4f);
DannyLee 3:cf9fead9c3f4 16 wait(0.4f);
DannyLee 3:cf9fead9c3f4 17 tone(784.0f,0.1f);
DannyLee 3:cf9fead9c3f4 18 wait(0.1f);
DannyLee 3:cf9fead9c3f4 19 tone(880.0f,0.4f);
DannyLee 3:cf9fead9c3f4 20 wait(0.4f);
DannyLee 3:cf9fead9c3f4 21 tone(587.0f,0.8f);
DannyLee 3:cf9fead9c3f4 22 wait(0.8f);
DannyLee 3:cf9fead9c3f4 23 tone(523.0f,0.4f);
DannyLee 3:cf9fead9c3f4 24 wait(0.4f);
DannyLee 3:cf9fead9c3f4 25 tone(523.0f,0.1f);
DannyLee 3:cf9fead9c3f4 26 wait(0.1f);
DannyLee 3:cf9fead9c3f4 27 tone(440.0f,0.4f);
DannyLee 3:cf9fead9c3f4 28 wait(0.4f);
DannyLee 3:cf9fead9c3f4 29 tone(587.0f,0.8f);
DannyLee 3:cf9fead9c3f4 30 wait(0.8f);
DannyLee 3:cf9fead9c3f4 31 tone(784.0f,0.4f);
DannyLee 3:cf9fead9c3f4 32 wait(0.4f);
DannyLee 3:cf9fead9c3f4 33 tone(784.0f,0.4f);
DannyLee 3:cf9fead9c3f4 34 wait(0.4f);
DannyLee 3:cf9fead9c3f4 35 tone(880.0f,0.1f);
DannyLee 3:cf9fead9c3f4 36 wait(0.1f);
DannyLee 3:cf9fead9c3f4 37 tone(1046.0f,0.4f);
DannyLee 3:cf9fead9c3f4 38 wait(0.4f);
DannyLee 3:cf9fead9c3f4 39 tone(880.0f,0.2f);
DannyLee 3:cf9fead9c3f4 40 wait(0.2f);
DannyLee 3:cf9fead9c3f4 41 tone(784.0f,0.2f);
DannyLee 3:cf9fead9c3f4 42 wait(0.2f);
DannyLee 3:cf9fead9c3f4 43 tone(523.0f,0.4f);
DannyLee 3:cf9fead9c3f4 44 wait(0.4f);
DannyLee 3:cf9fead9c3f4 45 tone(523.0f,0.1f);
DannyLee 3:cf9fead9c3f4 46 wait(0.1f);
DannyLee 3:cf9fead9c3f4 47 tone(440.0f,0.1f);
DannyLee 3:cf9fead9c3f4 48 wait(0.1f);
DannyLee 3:cf9fead9c3f4 49 tone(587.0f,0.8f);
DannyLee 3:cf9fead9c3f4 50 wait(0.8f);
DannyLee 3:cf9fead9c3f4 51
DannyLee 3:cf9fead9c3f4 52 }
DannyLee 3:cf9fead9c3f4 53
DannyLee 3:cf9fead9c3f4 54 void bgm::battlefield(){
DannyLee 3:cf9fead9c3f4 55 tone(659.0f,0.3f);
DannyLee 3:cf9fead9c3f4 56 wait(0.3f);
DannyLee 3:cf9fead9c3f4 57 tone(659.0f,0.2f);
DannyLee 3:cf9fead9c3f4 58 wait(0.2f);
DannyLee 3:cf9fead9c3f4 59 tone(587.0f,0.3f);
DannyLee 3:cf9fead9c3f4 60 wait(0.3f);
DannyLee 3:cf9fead9c3f4 61 tone(523.0f,0.2f);
DannyLee 3:cf9fead9c3f4 62 wait(0.2f);
DannyLee 3:cf9fead9c3f4 63 tone(523.0f,0.3f);
DannyLee 3:cf9fead9c3f4 64 wait(0.3f);
DannyLee 3:cf9fead9c3f4 65 tone(659.0f,0.2f);
DannyLee 3:cf9fead9c3f4 66 wait(0.2f);
DannyLee 3:cf9fead9c3f4 67 tone(784.0f,0.3f);
DannyLee 3:cf9fead9c3f4 68 wait(0.3f);
DannyLee 3:cf9fead9c3f4 69 tone(1046.0f,0.3f);
DannyLee 3:cf9fead9c3f4 70 wait(0.3f);
DannyLee 3:cf9fead9c3f4 71 tone(1046.0f,0.2f);
DannyLee 3:cf9fead9c3f4 72 wait(0.2f);
DannyLee 3:cf9fead9c3f4 73 tone(1046.0f,0.2f);
DannyLee 3:cf9fead9c3f4 74 wait(0.2f);
DannyLee 3:cf9fead9c3f4 75 tone(880.0f,0.5f);
DannyLee 3:cf9fead9c3f4 76 wait(0.5f);
DannyLee 3:cf9fead9c3f4 77 tone(784.0f,0.3f);
DannyLee 3:cf9fead9c3f4 78 wait(0.3f);
DannyLee 3:cf9fead9c3f4 79 tone(784.0f,0.2f);
DannyLee 3:cf9fead9c3f4 80 wait(0.2f);
DannyLee 3:cf9fead9c3f4 81 tone(880.0f,0.3f);
DannyLee 3:cf9fead9c3f4 82 wait(0.3f);
DannyLee 3:cf9fead9c3f4 83 tone(784.0f,0.3f);
DannyLee 3:cf9fead9c3f4 84 wait(0.3f);
DannyLee 3:cf9fead9c3f4 85 tone(659.0f,0.2f);
DannyLee 3:cf9fead9c3f4 86 wait(0.2f);
DannyLee 3:cf9fead9c3f4 87 tone(523.0f,0.3f);
DannyLee 3:cf9fead9c3f4 88 wait(0.3f);
DannyLee 3:cf9fead9c3f4 89 tone(587.0f,0.3f);
DannyLee 3:cf9fead9c3f4 90 wait(0.3f);
DannyLee 3:cf9fead9c3f4 91 tone(587.0f,0.2f);
DannyLee 3:cf9fead9c3f4 92 wait(0.2f);
DannyLee 3:cf9fead9c3f4 93 tone(659.0f,0.3f);
DannyLee 3:cf9fead9c3f4 94 wait(0.3f);
DannyLee 3:cf9fead9c3f4 95 tone(587.0f,0.2f);
DannyLee 3:cf9fead9c3f4 96 wait(0.2f);
DannyLee 3:cf9fead9c3f4 97
DannyLee 3:cf9fead9c3f4 98 }
DannyLee 3:cf9fead9c3f4 99
DannyLee 3:cf9fead9c3f4 100 void bgm::died(){
DannyLee 3:cf9fead9c3f4 101 tone(784.0f,0.2f);
DannyLee 3:cf9fead9c3f4 102 wait(0.2f);
DannyLee 3:cf9fead9c3f4 103 tone(880.0f,0.3f);
DannyLee 3:cf9fead9c3f4 104 wait(0.3f);
DannyLee 3:cf9fead9c3f4 105 tone(784.0f,0.2f);
DannyLee 3:cf9fead9c3f4 106 wait(0.2f);
DannyLee 3:cf9fead9c3f4 107 tone(698.0f,0.3f);
DannyLee 3:cf9fead9c3f4 108 wait(0.3f);
DannyLee 3:cf9fead9c3f4 109 tone(659.0f,0.2f);
DannyLee 3:cf9fead9c3f4 110 wait(0.2f);
DannyLee 3:cf9fead9c3f4 111 tone(698.0f,0.3f);
DannyLee 3:cf9fead9c3f4 112 wait(0.3f);
DannyLee 3:cf9fead9c3f4 113 tone(784.0f,0.3f);
DannyLee 3:cf9fead9c3f4 114 wait(0.3f);
DannyLee 3:cf9fead9c3f4 115 tone(587.0f,0.3f);
DannyLee 3:cf9fead9c3f4 116 wait(0.3f);
DannyLee 3:cf9fead9c3f4 117 tone(784.0f,0.2f);
DannyLee 3:cf9fead9c3f4 118 wait(0.2f);
DannyLee 3:cf9fead9c3f4 119 tone(784.0f,0.3f);
DannyLee 3:cf9fead9c3f4 120 wait(0.3f);
DannyLee 3:cf9fead9c3f4 121 tone(659.0f,0.2f);
DannyLee 3:cf9fead9c3f4 122 wait(0.2f);
DannyLee 3:cf9fead9c3f4 123 tone(523.0f,0.3f);
DannyLee 3:cf9fead9c3f4 124 wait(0.3f);
DannyLee 3:cf9fead9c3f4 125
DannyLee 3:cf9fead9c3f4 126 }
DannyLee 3:cf9fead9c3f4 127
DannyLee 3:cf9fead9c3f4 128 void bgm::tone_off()
DannyLee 3:cf9fead9c3f4 129 {
DannyLee 3:cf9fead9c3f4 130 // called after timeout
DannyLee 3:cf9fead9c3f4 131 _buzzer->write(0.0);
DannyLee 3:cf9fead9c3f4 132 }