ScummVM API documentation
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,
48  WalkFloorRightBegin = 141
49 };
50 }
51 
52 class TwinEEngine;
53 class Sound {
54 private:
55  TwinEEngine *_engine;
56 
58  int32 getSampleChannel(int32 index);
59 
61  Audio::SoundHandle samplesPlaying[NUM_CHANNELS];
62 
64  int32 samplesPlayingActors[NUM_CHANNELS]{0};
65 
66  bool playSample(int channelIdx, int index, Audio::SeekableAudioStream *audioStream, int32 loop, const char *name, Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
67 
68  bool isChannelPlaying(int32 channel);
69 
71  int32 getFreeSampleChannelIndex();
72 
74  void removeSampleChannel(int32 index);
75 
76 public:
77  Sound(TwinEEngine *engine);
78  ~Sound();
79 
85  void playFlaSample(int32 index, int32 repeat, uint8 balance, int32 volumeLeft, int32 volumeRight);
86 
88  void setSamplePosition(int32 channelIdx, int32 x, int32 y, int32 z);
89 
90  inline void setSamplePosition(int32 channelIdx, const IVec3 &pos) {
91  setSamplePosition(channelIdx, pos.x, pos.y, pos.z);
92  }
93 
103  void playSample(int32 index, int32 repeat = 1, int32 x = 128, int32 y = 128, int32 z = 128, int32 actorIdx = -1); // HQ_3D_MixSample
104  void playSample(int32 index, int32 repeat, const IVec3 &pos, int32 actorIdx = -1) { // HQ_MixSample
105  playSample(index, repeat, pos.x, pos.y, pos.z, actorIdx);
106  }
107 
109  void pauseSamples();
110 
112  void resumeSamples();
113 
114  void startRainSample();
115 
117  void stopSamples();
118 
120  int32 getActorChannel(int32 index);
121 
123  void stopSample(int32 index); // HQ_StopOneSample
124 
126  int32 isSamplePlaying(int32 index); // IsSamplePlaying
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:122
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