Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: N5110 PinDetect PowerControl mbed
Sound.cpp
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 ¬e) 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 }
Generated on Tue Jul 12 2022 21:59:47 by
1.7.2