Words don't say much, on the code:
#include <windows.h> #include <iostream> #include <map>using namespace std;const int do = 261;const int R E = 293;const int MI = 329;const int FA = 349;const int so = 392;const int LA = 440;const int TI = 493;const int do_ = 130 ; const int re_ = 147;const int mi_ = 165;const int fa_ = 174;const int so_ = 186;const int la_ = 220;const int ti_ = 247;i NT frequency (char note) {static map<const char,int> table; if (table.size () = = 0) {table[' 1 '] = do; table[' 2 '] = RE; table[' 3 '] = MI; table[' 4 '] = FA; table[' 5 '] = so; table[' 6 '] = LA; table[' 7 '] = TI; Table[' C '] = Do_; table[' d '] = re_; Table[' e '] = mi_; table[' f '] = Fa_; Table[' g '] = So_; Table[' a '] = La_; Table[' B '] = ti_; } return Table.find (note), second;} Class music{private:string notes; int TenUTO; Public:music (string &song, int tenuto_) {notes = song; tenuto = Tenuto_; Play (Notes.end (), Tenuto);} void Play (String::iterator it,int duration);}; void Music::p Lay (String::iterator it, int duration) {char note = *it; if (it = = Notes.begin ()) return; if (note = = '-') Play (it-1, duration + tenuto); else {if (isalnum (note)) {Play (it-1, 0); Beep (Frequency (note), Tenuto + duration); } else Play (it-1, duration); }} String bee = "5 3 3-| 4 2 2-| 1 2 3 4 | 5 5 5-| 5 3 3-| 4 2 2-| 1 3 5 5 | 3 3 3-| 2 2 2 2 | 2 3 4-| 3 3 3 3 | 3 4 5-| 5 3 3-| 4 2 2-| 1 3 5 5 | 1 3 1-| "; String happynewyear = "1 1 1-g-| 3 3 3-1-| 1 3 5-5-| 4 3 2---| 2 3 4-4-| 3 2 3-1-| 1 3 2-g-| B 2 1---| "; int main () {Music m (bee, 300); Music m2 (happynewyear, 200); return 0; }
Call BIOS speaker Audible