Flappy Bird game on mbed with a micro LCD screen, class D amp, speaker, SD card reader/writer, 5-button navigation switch, and potentiometer speed control
Dependencies: 4DGL-uLCD-SE PinDetect SDFileSystem mbed-rtos mbed
soundBuilder.h@0:cd1d2540aaf4, 2016-03-15 (annotated)
- Committer:
- Mpmart08
- Date:
- Tue Mar 15 01:11:07 2016 +0000
- Revision:
- 0:cd1d2540aaf4
added comments
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mpmart08 | 0:cd1d2540aaf4 | 1 | #include "Speaker.h" |
Mpmart08 | 0:cd1d2540aaf4 | 2 | |
Mpmart08 | 0:cd1d2540aaf4 | 3 | #ifndef SOUNDBUILDER_H |
Mpmart08 | 0:cd1d2540aaf4 | 4 | #define SOUNDBUILDER_H |
Mpmart08 | 0:cd1d2540aaf4 | 5 | |
Mpmart08 | 0:cd1d2540aaf4 | 6 | // class that represents a note played by a speaker |
Mpmart08 | 0:cd1d2540aaf4 | 7 | class Note |
Mpmart08 | 0:cd1d2540aaf4 | 8 | { |
Mpmart08 | 0:cd1d2540aaf4 | 9 | public: |
Mpmart08 | 0:cd1d2540aaf4 | 10 | // Constructor |
Mpmart08 | 0:cd1d2540aaf4 | 11 | Note(); |
Mpmart08 | 0:cd1d2540aaf4 | 12 | Note(float, float, float); |
Mpmart08 | 0:cd1d2540aaf4 | 13 | // Set Functions |
Mpmart08 | 0:cd1d2540aaf4 | 14 | void setFreq(float); // set the note's frequency |
Mpmart08 | 0:cd1d2540aaf4 | 15 | void setLength(float); // set the note's length |
Mpmart08 | 0:cd1d2540aaf4 | 16 | void setVolume(float); // set the note's volume |
Mpmart08 | 0:cd1d2540aaf4 | 17 | // Get Functions |
Mpmart08 | 0:cd1d2540aaf4 | 18 | float getFreq(); // return the note's frequency |
Mpmart08 | 0:cd1d2540aaf4 | 19 | float getLength(); // return the note's length |
Mpmart08 | 0:cd1d2540aaf4 | 20 | float getVolume(); // return the note's volume |
Mpmart08 | 0:cd1d2540aaf4 | 21 | private: |
Mpmart08 | 0:cd1d2540aaf4 | 22 | float freq; // the note's frequency |
Mpmart08 | 0:cd1d2540aaf4 | 23 | float length; // the note's length |
Mpmart08 | 0:cd1d2540aaf4 | 24 | float volume; // the note's volume |
Mpmart08 | 0:cd1d2540aaf4 | 25 | }; |
Mpmart08 | 0:cd1d2540aaf4 | 26 | |
Mpmart08 | 0:cd1d2540aaf4 | 27 | class SoundBuilder |
Mpmart08 | 0:cd1d2540aaf4 | 28 | { |
Mpmart08 | 0:cd1d2540aaf4 | 29 | public: |
Mpmart08 | 0:cd1d2540aaf4 | 30 | // Set Song |
Mpmart08 | 0:cd1d2540aaf4 | 31 | SoundBuilder (float [], float [], float [], int, Speaker *); |
Mpmart08 | 0:cd1d2540aaf4 | 32 | // Set sound, where int is the note number starting from 0 |
Mpmart08 | 0:cd1d2540aaf4 | 33 | void setNote(float, float, float, int); |
Mpmart08 | 0:cd1d2540aaf4 | 34 | // Play Song from given start and stop positions |
Mpmart08 | 0:cd1d2540aaf4 | 35 | void playNotes(int, int); |
Mpmart08 | 0:cd1d2540aaf4 | 36 | // Play Song |
Mpmart08 | 0:cd1d2540aaf4 | 37 | void playSong(); |
Mpmart08 | 0:cd1d2540aaf4 | 38 | // Clear Songs |
Mpmart08 | 0:cd1d2540aaf4 | 39 | void clearSong(); |
Mpmart08 | 0:cd1d2540aaf4 | 40 | |
Mpmart08 | 0:cd1d2540aaf4 | 41 | private: |
Mpmart08 | 0:cd1d2540aaf4 | 42 | Note song[20]; // a song of up to 20 notes |
Mpmart08 | 0:cd1d2540aaf4 | 43 | Speaker *speaker; // speaker that plays the song |
Mpmart08 | 0:cd1d2540aaf4 | 44 | |
Mpmart08 | 0:cd1d2540aaf4 | 45 | }; |
Mpmart08 | 0:cd1d2540aaf4 | 46 | |
Mpmart08 | 0:cd1d2540aaf4 | 47 | #endif // SOUNDBUILDER_H |