ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sound.h
1 /* ScummVM - Graphic Adventure Engine
2  *
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.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
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.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TWINE_SOUND_H
23 #define TWINE_SOUND_H
24 
25 #include "audio/audiostream.h"
26 #include "audio/mixer.h"
27 #include "common/scummsys.h"
28 #include "common/types.h"
29 #include "twine/shared.h"
30 
31 namespace TwinE {
32 
33 class TextEntry;
34 
35 #define NUM_CHANNELS 32
36 
37 namespace Samples {
38 enum _Samples {
39  TwinsenHit = 0,
40  SoldierHit = 4,
41  ItemPopup = 11,
42  Explode = 37,
43  BigItemFound = 41,
44  TaskCompleted = 41,
45  Hit = 86,
46  ItemFound = 97,
47  WalkFloorBegin = 126, // BASE_STEP_SOUND
48  WalkFloorRightBegin = 141
49 };
50 }
51 
52 class TwinEEngine;
53 class Sound {
54 private:
55  TwinEEngine *_engine;
56 
58  Audio::SoundHandle _samplesPlaying[NUM_CHANNELS];
59 
61  int32 _samplesPlayingActors[NUM_CHANNELS]{0};
62 
63  bool playSample(int32 channelIdx, int32 index, Audio::SeekableAudioStream *audioStream, int32 loop, const char *name, Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
64 
65  bool isChannelPlaying(int32 channelIdx);
66 
68  int32 getFreeSampleChannelIndex();
69 
71  void removeChannelWatch(int32 channelIdx);
72 public:
73  Sound(TwinEEngine *engine);
74  ~Sound();
75 
77  int32 getSampleChannel(int32 index);
78 
84  void playFlaSample(int32 index, int16 rate, int32 repeat, uint8 volumeLeft, uint8 volumeRight);
85 
86  void setChannelBalance(int32 channelIdx, uint8 volumeLeft, uint8 volumeRight);
87 
88  void setChannelRate(int32 channelIdx, uint32 rate);
89 
91  void setChannelPosition(int32 channelIdx, int32 x, int32 y, int32 z);
92 
93  inline void setChannelPosition(int32 channelIdx, const IVec3 &pos) {
94  setChannelPosition(channelIdx, pos.x, pos.y, pos.z);
95  }
96 
104  void mixSample3D(int32 index, uint16 pitchbend, int32 repeat, const IVec3 &pos, int32 actorIdx); // HQ_3D_MixSample
105 
106  void mixSample(int32 index, uint16 pitchbend, int32 repeat, uint8 volumeLeft, uint8 volumeRight); // HQ_MixSample
107 
109  void pauseSamples();
110 
112  void resumeSamples();
113 
114  void startRainSample();
115 
117  void stopSamples();
118 
120  int32 getActorChannel(int32 actorIdx);
121 
123  void stopSample(int32 index); // HQ_StopOneSample
124 
126  int32 isSamplePlaying(int32 index);
127 
129  bool playVoxSample(const TextEntry *text);
130 };
131 
132 } // namespace TwinE
133 
134 #endif
Definition: text.h:33
Definition: sound.h:53
Definition: shared.h:125
Definition: audiostream.h:212
Definition: mixer.h:49
SoundType
Definition: mixer.h:62
Definition: twine.h:207
Definition: achievements_tables.h:27
Definition: mixer.h:63