00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023
00024
00025
00026
00027 #ifndef SOUND_ENGINE_H
00028 #define SOUND_ENGINE_H
00029
00030 #include <PalmOS.h>
00031 #include "Customization.h"
00032
00033
00034 #ifdef NO_SOUND
00035
00036 class SoundEngine
00037 {
00038 public:
00039
00040 static void timeTick();
00041
00042 private:
00043 SoundEngine() {};
00044 ~SoundEngine() {};
00045
00046 static void init();
00047 static void destroy();
00048
00049 friend class Presentation;
00050 };
00051
00052 #else
00053
00054
00055 class MusicEngine;
00056 class FxEngine;
00057
00058 00059 00060 00061
00062 class SoundEngine
00063 {
00064 public: 00065 00066 00067 00068 00069 00070
00071 static void playFx(DmResID resID);
00072 00073 00074 00075 00076 00077 00078 00079 00080
00081 static void playSong(DmResID resID);
00082
00083 00084 00085 00086
00087 static void stopSong();
00088
00089 00090 00091 00092 00093
00094 static void timeTick();
00095
00096
00097 private:
00098
00099 SoundEngine() {}
00100 ~SoundEngine() {}
00101
00102 static void init();
00103 static void destroy();
00104
00105 static FxEngine *fxEngine;
00106 static MusicEngine *musicEngine;
00107
00108 static UInt16 baseAmplitude;
00109 static Boolean mute;
00110 static UInt32 nextTimer;
00111
00112
00113 friend class Presentation;
00114 };
00115
00116
00117 00118 00119 00120
00121 class FxEngine
00122 {
00123 private:
00124
00125 FxEngine(UInt16 baseAmplitude);
00126 ~FxEngine();
00127 00128 00129 00130 00131 00132
00133 Boolean timeTick();
00134
00135 void playFx(DmResID resID);
00136
00137
00138 Boolean playing;
00139 DmResID fxResID;
00140 UInt16 fxPosition;
00141 UInt16 baseAmplitude;
00142 00143 00144 static const UInt16 FREQ_END = 0x0000;00145 00146 static const UInt8 DURATION_YIELD = 0x00;
00147
00148 friend class SoundEngine;
00149 };
00150
00151 00152 00153 00154 00155
00156 class MusicEngine
00157 {
00158 private:
00159
00160 MusicEngine(UInt16 baseAmplitude);
00161 ~MusicEngine();
00162
00163 00164 00165 00166 00167 00168
00169 Boolean timeTick();
00170
00171 void playSong(DmResID resID);
00172 void stopSong();
00173
00174 void setPatternsFromTrack();
00175
00176 void playNote(UInt16 note, UInt16 octave, UInt16 amplitude, UInt16 duration, Boolean wait) const;
00177 void playMute(UInt16 duration, Boolean wait) const;
00178
00179 void hitIt(UInt16 position, UInt16 pattern, UInt16 amplitude, UInt16 duration, Boolean wait) const;
00180
00181
00182 DmResID trackResID;
00183 UInt16 trackPosition;
00184 UInt16 channel1Pattern;
00185 UInt16 channel2Pattern;
00186 UInt16 channel3Pattern;
00187
00188 UInt16 pattern;
00189 UInt16 patternPosition;
00190
00191 Boolean playing;
00192 Boolean channel1Playing;
00193 Boolean channel2Playing;
00194 Boolean channel3Playing;
00195
00196 UInt16 baseDuration;
00197 UInt16 baseAmplitude;
00198
00199 static const UInt8 CHANNEL_MUTE = 0xFD;
00200 static const UInt8 TRACK_REPEAT = 0xFE;
00201 static const UInt8 TRACK_END = 0xFF;
00202
00203 friend class SoundEngine;
00204 };
00205
00206
00207 #endif // !NO_SOUND
00208
00209 #endif