22 #ifndef SWORD1_SOUND_H 23 #define SWORD1_SOUND_H 25 #include "sword1/object.h" 26 #include "sword1/sworddefs.h" 28 #include "common/file.h" 29 #include "common/mutex.h" 30 #include "common/random.h" 31 #include "common/timer.h" 32 #include "common/util.h" 34 #include "audio/mixer.h" 35 #include "audio/audiostream.h" 43 #define TOTAL_FX_PER_ROOM 7 // total loop & random fx per room (see fx_list.c) 44 #define MAX_ROOMS_PER_FX 7 // max no. of rooms in the fx's room,vol list 45 #define MAX_FXQ_LENGTH 32 // max length of sound queue - ie. max number of fx that can be stored up/playing together 62 int32 roomNo, leftVol, rightVol;
74 RoomVol roomVolList[MAX_ROOMS_PER_FX];
80 #define MUSIC_UNDERSCORE 50 81 #define NEG_MOUTH_THRESHOLD -750 82 #define POS_MOUTH_THRESHOLD 750 85 #define S_STATUS_FINISHED 1 86 #define S_STATUS_RUNNING 0 87 #define MUSIC_BUFFER_SIZE 0x2000 88 #define TOTAL_TUNES 270 89 #define DEFAULT_SAMPLE_RATE 11025 116 void newScreen(uint32 screen);
117 void closeCowSystem();
121 void checkSpeechFileEndianness();
122 double endiannessHeuristicValue(int16* data, uint32 dataSize, uint32 &maxSamples);
124 void installFadeTimer();
125 void uninstallFadeTimer();
127 void playSample(int32 fxNo);
128 void stopSample(int32 fxNo);
129 void setFXVolume(byte targetVolume,
int handleIdx);
131 int addToQueue(uint32 fxNo);
132 void removeFromQueue(uint32 fxNo);
134 void startSpeech(uint16 roomNo, uint16 localNo);
136 int32 checkSpeechStatus();
140 void streamMusicFile(int32 tuneId, int32 looped);
141 void updateMusicStreaming();
142 void setCrossFadeIncrement();
144 void fadeMusicDown(int32 rate);
145 void fadeFxDown(int32 rate);
146 void fadeFxUp(int32 rate);
149 void unpauseSpeech();
157 byte clampVolume(int32 volume);
163 uint32 _volFX[2] = { 0, 0 };
164 uint32 _volSpeech[2] = { 0, 0 };
165 uint32 _volMusic[2] = { 0, 0 };
169 int32 _fxFadingFlag = 0;
170 int32 _fxFadingRate = 0;
171 int32 _fxFadeVolume[2] = { 0, 0 };
172 int32 _musicFadeVolume[2] = { 0, 0 };
175 bool _fxSampleBusy[MAX_FX] = {
false,
false,
false,
false };
178 byte *_speechSample =
nullptr;
191 uint32 dwSamplesPerSec;
192 uint32 dwAvgBytesPerSec;
194 uint16 wBitsPerSample;
199 void initCowSystem();
201 uint32 getSampleId(int32 fxNo);
202 void playFX(int32 fxID, int32 type, uint8 *wavData, uint32 vol[2]);
203 void stopFX(int32 fxID);
204 int32 checkSampleStatus(int32
id);
206 bool expandSpeech(byte *src, byte *dst, uint32 dstSize,
207 bool *endiannessCheck =
nullptr, uint32 *sizeForEndiannessCheck =
nullptr);
208 int32 getSpeechSize(byte *compData, uint32 compSize);
210 bool prepareMusicStreaming(
const Common::Path &filename,
int newHandleId, int32 tuneId,
211 uint32 volume, int8 pan, MusCompMode assignedMode);
213 void reduceMusicVolume();
214 void restoreMusicVolume();
216 int8 scalePan(
int pan);
220 uint32 _cowHeaderSize;
221 uint8 _currentCowFile;
230 bool _bigEndianSpeech;
231 static const char _musicList[270];
232 static const uint16 _roomsFixedFx[TOTAL_ROOMS][TOTAL_FX_PER_ROOM];
233 static const FxDef _fxList[312];
234 static const char _tuneList[TOTAL_TUNES][8];
237 bool _crossFadeIncrement =
false;
240 int32 _speechLipsyncCounter = 0;
241 int32 _speechSize = 0;
242 bool _speechSampleBusy =
false;
250 bool _musicStreamPlaying[MAX_MUSIC] = {
false,
false };
251 bool _streamLoopingFlag[MAX_MUSIC] = {
false,
false };
252 int32 _musicStreamFading[MAX_MUSIC] = { 0, 0 };
253 MusCompMode _musicStreamFormat[MAX_MUSIC] = { MusWav, MusWav };
259 int32 _fxSampleId[MAX_FX] = { 0, 0, 0, 0 };
262 bool _speechPaused =
false;
263 bool _fxPaused[MAX_FX] = {
false,
false,
false,
false };
264 bool _musicPaused[MAX_MUSIC] = {
false,
false };
Definition: animation.h:38
Definition: audiostream.h:109
Definition: audiostream.h:370
Definition: control.h:120