Logibotの動作用の基本ライブラリです
Dependents: Logibot_Temp Motor_Temp
beep_sound.h
00001 #ifndef BEEP_SOUND_H 00002 #define BEEP_SOUND_H 00003 #include "mbed.h" 00004 #include <queue> 00005 struct gakuhu{ 00006 int octave; 00007 int note; 00008 float time_s; // 長さが-1:通常ノート -2:終了フラグ 00009 }; 00010 /* 00011 struct beep{ 00012 float userPeriod; 00013 float userWrite; 00014 float time_s; 00015 } 00016 */ 00017 const int frequencyTable[] = {261, 277, 294, 311, 330, 349, 00018 370, 392, 415, 440, 466, 494, 100}; 00019 00020 00021 class beep_sound 00022 { 00023 public: 00024 beep_sound(PinName pwm); 00025 ~beep_sound(); 00026 void SetFrequency(int octave, int note, bool on_off); 00027 void onpu(int octave, int note, float time_s); 00028 void onpu_stop(int octave, int note, float time_s); 00029 void sinwave(float center,int speed,int width); 00030 void setwave(float frequency,float duty,float wait); 00031 // 以下サンプル音集 00032 void boot(); 00033 void beep_right(int nTimes); 00034 void beep_wrong(int nTimes); 00035 void beep_notif1(int nTimes); 00036 void beep_notif2(int nTimes); 00037 void beep_readyGo(int nTimes); 00038 // 以下並列で鳴らすための関数 00039 void stop(); 00040 void setGakuhu(int argOc, int argNo, float argTi); 00041 void setKyuhu(float argTi); 00042 void playGakuhu(); 00043 void playContinue(); 00044 void NoteOn(int octave, int note); 00045 private: 00046 PwmOut* m_pwm; 00047 int frequency; 00048 // 以下並列で鳴らすための宣言 00049 queue<gakuhu> otoQue; 00050 gakuhu bufG; 00051 Timeout interruptStop; 00052 // 再生中にキューにsetGakuhuをさせないためのフラグ 00053 bool playing; // false:停止中 true:再生中 00054 bool teishi; // true:再生を強制停止. ノート再生時に必ずチェック. 00055 }; 00056 00057 #endif
Generated on Wed Jul 20 2022 11:45:10 by 1.7.2