RUOFAN LI
/
el17rl
Li Ruofan 201199450
Diff: bgm/bgm.cpp
- Revision:
- 3:cf9fead9c3f4
- Child:
- 6:cbd9e1f26a10
diff -r 5969f78a25ba -r cf9fead9c3f4 bgm/bgm.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bgm/bgm.cpp Thu May 14 13:12:28 2020 +0000 @@ -0,0 +1,132 @@ +#include "bgm.h" + +// construct & destruct/ +bgm::bgm() +{ +} +bgm::~bgm() +{ +} + +// The number "1,2,3,4,5,6,7" means each number note in the notation + +// Excerpted from famous Chinese and English songs +void bgm::welcome(){ + tone(784.0f,0.4f); + wait(0.4f); + tone(784.0f,0.1f); + wait(0.1f); + tone(880.0f,0.4f); + wait(0.4f); + tone(587.0f,0.8f); + wait(0.8f); + tone(523.0f,0.4f); + wait(0.4f); + tone(523.0f,0.1f); + wait(0.1f); + tone(440.0f,0.4f); + wait(0.4f); + tone(587.0f,0.8f); + wait(0.8f); + tone(784.0f,0.4f); + wait(0.4f); + tone(784.0f,0.4f); + wait(0.4f); + tone(880.0f,0.1f); + wait(0.1f); + tone(1046.0f,0.4f); + wait(0.4f); + tone(880.0f,0.2f); + wait(0.2f); + tone(784.0f,0.2f); + wait(0.2f); + tone(523.0f,0.4f); + wait(0.4f); + tone(523.0f,0.1f); + wait(0.1f); + tone(440.0f,0.1f); + wait(0.1f); + tone(587.0f,0.8f); + wait(0.8f); + +} + +void bgm::battlefield(){ + tone(659.0f,0.3f); + wait(0.3f); + tone(659.0f,0.2f); + wait(0.2f); + tone(587.0f,0.3f); + wait(0.3f); + tone(523.0f,0.2f); + wait(0.2f); + tone(523.0f,0.3f); + wait(0.3f); + tone(659.0f,0.2f); + wait(0.2f); + tone(784.0f,0.3f); + wait(0.3f); + tone(1046.0f,0.3f); + wait(0.3f); + tone(1046.0f,0.2f); + wait(0.2f); + tone(1046.0f,0.2f); + wait(0.2f); + tone(880.0f,0.5f); + wait(0.5f); + tone(784.0f,0.3f); + wait(0.3f); + tone(784.0f,0.2f); + wait(0.2f); + tone(880.0f,0.3f); + wait(0.3f); + tone(784.0f,0.3f); + wait(0.3f); + tone(659.0f,0.2f); + wait(0.2f); + tone(523.0f,0.3f); + wait(0.3f); + tone(587.0f,0.3f); + wait(0.3f); + tone(587.0f,0.2f); + wait(0.2f); + tone(659.0f,0.3f); + wait(0.3f); + tone(587.0f,0.2f); + wait(0.2f); + +} + +void bgm::died(){ + tone(784.0f,0.2f); + wait(0.2f); + tone(880.0f,0.3f); + wait(0.3f); + tone(784.0f,0.2f); + wait(0.2f); + tone(698.0f,0.3f); + wait(0.3f); + tone(659.0f,0.2f); + wait(0.2f); + tone(698.0f,0.3f); + wait(0.3f); + tone(784.0f,0.3f); + wait(0.3f); + tone(587.0f,0.3f); + wait(0.3f); + tone(784.0f,0.2f); + wait(0.2f); + tone(784.0f,0.3f); + wait(0.3f); + tone(659.0f,0.2f); + wait(0.2f); + tone(523.0f,0.3f); + wait(0.3f); + +} + +void bgm::tone_off() +{ + // called after timeout + _buzzer->write(0.0); +}