00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __dsound_h__
00028 #define __dsound_h__
00029
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033
00034 #include <config.h>
00035
00036 #ifdef CONF_DSOUND
00037
00038 #include <time.h>
00039
00040 #include <unistd.h>
00041
00043
00044
00045
00047
00056 typedef struct {
00057 unsigned char pitch;
00058 unsigned char length;
00059 } note_t;
00060
00061
00063
00064
00066 #define WHOLE 16
00067
00069 #define HALF 8
00070
00072 #define QUARTER 4
00073
00075 #define EIGHTH 2
00076
00078
00079
00080
00081
00083
00084
00086 #define PITCH_A0 0
00087 #define PITCH_Am0 1
00088 #define PITCH_H0 2
00089 #define PITCH_C1 3
00090 #define PITCH_Cm1 4
00091 #define PITCH_D1 5
00092 #define PITCH_Dm1 6
00093 #define PITCH_E1 7
00094 #define PITCH_F1 8
00095 #define PITCH_Fm1 9
00096 #define PITCH_G1 10
00097 #define PITCH_Gm1 11
00098 #define PITCH_A1 12
00099 #define PITCH_Am1 13
00100 #define PITCH_H1 14
00101 #define PITCH_C2 15
00102 #define PITCH_Cm2 16
00103 #define PITCH_D2 17
00104 #define PITCH_Dm2 18
00105 #define PITCH_E2 19
00106 #define PITCH_F2 20
00107 #define PITCH_Fm2 21
00108 #define PITCH_G2 22
00109 #define PITCH_Gm2 23
00110 #define PITCH_A2 24
00111 #define PITCH_Am2 25
00112 #define PITCH_H2 26
00113 #define PITCH_C3 27
00114 #define PITCH_Cm3 28
00115 #define PITCH_D3 29
00116 #define PITCH_Dm3 30
00117 #define PITCH_E3 31
00118 #define PITCH_F3 32
00119 #define PITCH_Fm3 33
00120 #define PITCH_G3 34
00121 #define PITCH_Gm3 35
00122 #define PITCH_A3 36
00123 #define PITCH_Am3 37
00124 #define PITCH_H3 38
00125 #define PITCH_C4 39
00126 #define PITCH_Cm4 40
00127 #define PITCH_D4 41
00128 #define PITCH_Dm4 42
00129 #define PITCH_E4 43
00130 #define PITCH_F4 44
00131 #define PITCH_Fm4 45
00132 #define PITCH_G4 46
00133 #define PITCH_Gm4 47
00134 #define PITCH_A4 48
00135 #define PITCH_Am4 49
00136 #define PITCH_H4 50
00137 #define PITCH_C5 51
00138 #define PITCH_Cm5 52
00139 #define PITCH_D5 53
00140 #define PITCH_Dm5 54
00141 #define PITCH_E5 55
00142 #define PITCH_F5 56
00143 #define PITCH_Fm5 57
00144 #define PITCH_G5 58
00145 #define PITCH_Gm5 59
00146 #define PITCH_A5 60
00147 #define PITCH_Am5 61
00148 #define PITCH_H5 62
00149 #define PITCH_C6 63
00150 #define PITCH_Cm6 64
00151 #define PITCH_D6 65
00152 #define PITCH_Dm6 66
00153 #define PITCH_E6 67
00154 #define PITCH_F6 68
00155 #define PITCH_Fm6 69
00156 #define PITCH_G6 70
00157 #define PITCH_Gm6 71
00158 #define PITCH_A6 72
00159 #define PITCH_Am6 73
00160 #define PITCH_H6 74
00161 #define PITCH_C7 75
00162 #define PITCH_Cm7 76
00163 #define PITCH_D7 77
00164 #define PITCH_Dm7 78
00165 #define PITCH_E7 79
00166 #define PITCH_F7 80
00167 #define PITCH_Fm7 81
00168 #define PITCH_G7 82
00169 #define PITCH_Gm7 83
00170 #define PITCH_A7 84
00171 #define PITCH_Am7 85
00172 #define PITCH_H7 86
00173 #define PITCH_C8 87
00174 #define PITCH_Cm8 88
00175 #define PITCH_D8 89
00176 #define PITCH_Dm8 90
00177 #define PITCH_E8 91
00178 #define PITCH_F8 92
00179 #define PITCH_Fm8 93
00180 #define PITCH_G8 94
00181 #define PITCH_Gm8 95
00182 #define PITCH_A8 96
00183
00185
00187 #define PITCH_PAUSE 97
00188
00190 #define PITCH_MAX 98
00191
00193 #define PITCH_END 255
00194
00195
00197 #define DSOUND_BEEP 0
00198
00200 #define DSOUND_SYS_MAX 1
00201
00202
00204 #define DSOUND_DEFAULT_16th_ms 200
00205
00207 #define DSOUND_DEFAULT_internote_ms 15
00208
00210
00211
00212
00214
00215 #ifndef DOXYGEN_SHOULD_SKIP_INTERNALS
00216
00217 extern unsigned dsound_16th_ms;
00218 extern unsigned dsound_internote_ms;
00219 extern volatile note_t *dsound_next_note;
00220 extern volatile time_t dsound_next_time;
00221
00222 extern const note_t *dsound_system_sounds[];
00223
00224 #endif // DOXYGEN_SHOULD_SKIP_INTERNALS
00225
00226
00228
00229
00230
00232
00234 static inline void dsound_play(const note_t *notes) {
00235 dsound_next_note=(volatile note_t*) notes;
00236 dsound_next_time=0;
00237 }
00238
00240 static inline void dsound_system(unsigned nr) {
00241 if(nr<DSOUND_SYS_MAX)
00242 dsound_play(dsound_system_sounds[nr]);
00243 }
00244
00246 static inline unsigned dsound_set_duration(unsigned duration) {
00247 unsigned orig_duration = dsound_16th_ms;
00248 dsound_16th_ms=duration;
00249 return orig_duration;
00250 }
00251
00253
00255 static inline void dsound_set_internote(unsigned duration) {
00256 dsound_internote_ms=duration;
00257 }
00258
00260 static inline int dsound_playing(void) {
00261 return dsound_next_note!=0;
00262 }
00263
00265 extern wakeup_t dsound_finished(wakeup_t data);
00266
00268 extern void dsound_stop(void);
00269
00270 #endif // CONF_DSOUND
00271
00272 #ifdef __cplusplus
00273 }
00274 #endif
00275
00276 #endif