Andreas Garmannslund / Mbed 2 deprecated SimplePlatformGame

Dependencies:   N5110 PinDetect PowerControl mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Sound.cpp Source File

Sound.cpp

Go to the documentation of this file.
00001 #include "Sound.h "
00002 
00003 /// @file Sound.cpp
00004 
00005 Sound::Sound(PinName buzzerPin)
00006 {
00007     buzzer = new PwmOut(buzzerPin);
00008 }
00009 
00010 Sound::~Sound()
00011 {
00012     delete buzzer;
00013 }
00014 
00015 void Sound::playNote(Note &note)
00016 {
00017     start();
00018     buzzer->period(1.0/note.frequency);
00019     ticker.attach(this, &Sound::stop, 0.5 * note.beat);
00020 }
00021 
00022 // Sound effects - definitions
00023 namespace SFX
00024 {
00025     Note PLAYER_DEAD(1174.66, 0.2);
00026     Note ENEMY_DEAD(1567.98, 0.1);
00027     Note BULLET_FIRED(1661.22, 0.1);
00028     Note PLAYER_JUMP(1760.00, 0.2);
00029     Note RESTART(1318.51, 1.0);   
00030 }