Move actors to the first frame on entering a room.
[scummvm-innocent.git] / engines / sword1 / sound.h
blobc105d06b50173d92da1cbd274295cbbb7bc16285
1 /* ScummVM - Graphic Adventure Engine
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * $URL$
22 * $Id$
26 #ifndef SWORD1_SOUND_H
27 #define SWORD1_SOUND_H
29 #include "sword1/object.h"
30 #include "sword1/sworddefs.h"
31 #include "common/file.h"
32 #include "sound/mixer.h"
33 #include "common/util.h"
35 namespace Audio {
36 class Mixer;
39 namespace Sword1 {
41 #define TOTAL_FX_PER_ROOM 7 // total loop & random fx per room (see fx_list.c)
42 #define MAX_ROOMS_PER_FX 7 // max no. of rooms in the fx's room,vol list
43 #define MAX_FXQ_LENGTH 32 // max length of sound queue - ie. max number of fx that can be stored up/playing together
45 #define FX_SPOT 1
46 #define FX_LOOP 2
47 #define FX_RANDOM 3
49 struct QueueElement {
50 uint32 id, delay;
51 Audio::SoundHandle handle;
54 struct RoomVol {
55 int32 roomNo, leftVol, rightVol;
58 struct FxDef {
59 uint32 sampleId, type, delay;
60 RoomVol roomVolList[MAX_ROOMS_PER_FX];
63 class ResMan;
64 #define WAVE_VOL_TAB_LENGTH 480
65 #define WAVE_VOL_THRESHOLD 190000 //120000
67 enum CowMode {
68 CowWave = 0,
69 CowFlac,
70 CowVorbis,
71 CowMp3,
72 CowDemo,
73 CowPSX
76 class Sound {
77 public:
78 Sound(const char *searchPath, Audio::Mixer *mixer, ResMan *pResMan);
79 ~Sound(void);
80 void setSpeechVol(uint8 volL, uint8 volR) { _speechVolL = volL; _speechVolR = volR; }
81 void setSfxVol(uint8 volL, uint8 volR) { _sfxVolL = volL; _sfxVolR = volR; }
82 void giveSpeechVol(uint8 *volL, uint8 *volR) { *volL = _speechVolL; *volR = _speechVolR; }
83 void giveSfxVol(uint8 *volL, uint8 *volR) { *volL = _sfxVolL; *volR = _sfxVolR; }
84 void newScreen(uint32 screen);
85 void quitScreen(void);
86 void closeCowSystem(void);
88 bool startSpeech(uint16 roomNo, uint16 localNo);
89 bool speechFinished(void);
90 void stopSpeech();
91 bool amISpeaking(void);
93 void fnStopFx(int32 fxNo);
94 int addToQueue(int32 fxNo);
96 void engine(void);
98 void checkSpeechFileEndianness();
100 private:
101 uint8 _sfxVolL, _sfxVolR, _speechVolL, _speechVolR;
102 void playSample(QueueElement *elem);
103 void initCowSystem(void);
105 int16 *uncompressSpeech(uint32 index, uint32 cSize, uint32 *size);
106 void calcWaveVolume(int16 *data, uint32 length);
107 bool _waveVolume[WAVE_VOL_TAB_LENGTH];
108 uint16 _waveVolPos;
109 Common::File _cowFile;
110 uint32 *_cowHeader;
111 uint32 _cowHeaderSize;
112 uint8 _currentCowFile;
113 CowMode _cowMode;
114 Audio::SoundHandle _speechHandle, _fxHandle;
115 Common::RandomSource _rnd;
117 QueueElement _fxQueue[MAX_FXQ_LENGTH];
118 uint8 _endOfQueue;
119 Audio::Mixer *_mixer;
120 ResMan *_resMan;
121 bool _bigEndianSpeech;
122 char _filePath[100];
123 static const char _musicList[270];
124 static const uint16 _roomsFixedFx[TOTAL_ROOMS][TOTAL_FX_PER_ROOM];
125 static const FxDef _fxList[312];
129 } // End of namespace Sword1
131 #endif //BSSOUND_H