このライブラリでは、単音とメロディの出力が可能です。 In this library, you can output a single tone and melody. mbedのpwmOutとDigitalOutを使ってスピーカや圧電ブザーを直接駆動します。 directly drive speaker or buzzer and DigitalOut pwmOut using the mbed. メロディデータは、mbedのローカルにtxtファイルとして保存するか、プログラム中に配列データとして保存してください。 Melody data is either stored in a txt file on the local mbed, save it as a data array in the program.
Dependents: kitchenTimer_Clock SoundLibraryExample_Melody_ProgramData M3PI_SuiviLigne
Diff: Sound.cpp
- Revision:
- 13:cd42abff5173
- Parent:
- 0:e3f005984c2a
- Child:
- 14:6e0eac903431
- Child:
- 15:d526205994e9
diff -r 71488a68dc58 -r cd42abff5173 Sound.cpp --- a/Sound.cpp Sat Nov 19 08:18:24 2011 +0000 +++ b/Sound.cpp Sun Oct 20 06:00:50 2013 +0000 @@ -59,7 +59,6 @@ * time interrupt *****************************************/ void Sound::pulseCheck(void) { - // uint32_t static C_syuukiKeika = 0; // uint8_t static f_muonSet = 0; // muon ji no sound_out() syori wo kurikaesu no wo fusegu // uint8_t static F_pwmSet = 0; // 0:zenhan hansyuuki 1:kohan hansyuuki wo request @@ -155,7 +154,8 @@ uint8_t kaicho; // oto no frequency // do re mi fa so ra si -const uint16_t DT_onkaiHzN[3][7] = {// C1 D1 E1 F1 G1 A1 B1 // frequency (1/1 [Hz]/count) +//131020const float DT_onkaiHzN[3][7] = {// C1 D1 E1 F1 G1 A1 B1 // frequency (1/1 [Hz]/count) //131020 +const float DT_onkaiHzN[3][7] = {// C1 D1 E1 F1 G1 A1 B1 // frequency (1/1 [Hz]/count) //131020 {30.8677, 34.6478, 38.8909, 41.2034, 46.2493, 51.9131, 58.2705}, // b {32.7032, 36.7081, 41.2034, 43.6535, 48.9994, 55.0000, 61.7354}, // nomal {34.6478, 38.8909, 43.6535, 46.2493, 51.9131, 58.2705, 65.4064}, // # @@ -183,7 +183,8 @@ break; default: // enso chu & tugi no hatuon settei) - O_sound.syuuki = 1000000 / (DT_onkaiHzN[data.hanon][kaicho] * (pow(2.0, ((double)okutabu - 1)))); +//131020 O_sound.syuuki = 1000000 / (DT_onkaiHzN[data.hanon][kaicho] * (pow(2.0, ((double)okutabu - 1)))); //131020 + O_sound.syuuki = 1000000 / (uint16_t)(DT_onkaiHzN[data.hanon][kaicho] * (pow(2.0, ((double)okutabu - 1)))); //131020 O_sound.envelope = data.envelope * 1000; O_sound.shokichienvelope = data.envelope * 1000; break; @@ -451,3 +452,4 @@ +